build.zig.zon ومدير الحزم
صرّح بالتبعيات في ملف البيان
build.zig.zon ومدير الحزم درس مجاني في Zig Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Zig Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Zig Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
A Manifest for Your Package
Beside build.zig sits build.zig.zon, the manifest that names your package and lists what it depends on. 📜
ZON Is Zig Object Notation
The file is written in ZON, which looks just like a Zig anonymous struct literal. Dotted field names map to plain Zig values.
.{
.name = .myapp,
.version = "0.1.0",
}Name and Version
Two required fields stand out: name identifies the package and version follows semantic versioning like 1.2.0.
.name = .myapp,
.version = "0.1.0",List Your Dependencies
The dependencies field is a struct of entries, one per external package you want to pull into your build.
.dependencies = .{
.mylib = .{},
},A URL Points to the Source
Each dependency gives a url to a tarball, usually a tagged archive on a code host. Zig fetches and unpacks it for you.
.url = "https://example.com/mylib-1.0.0.tar.gz",The hash Locks It Down
A hash field pins the exact bytes of that download. If the content ever changes, the hash mismatches and the build refuses it.
.hash = "122012ab...",Let zig fetch Fill It In
You rarely type a hash by hand. Run zig fetch with the url and it downloads, computes the hash, and writes the entry for you.
zig fetch --save https://example.com/mylib-1.0.0.tar.gzThe Global Cache
Fetched packages land in a shared cache on your machine. Many projects reuse one copy, so the same dependency is not stored twice.
paths Declares What Ships
The paths field lists the files included when your package is itself a dependency. Use .{""} to ship everything in the folder.
.paths = .{ "build.zig", "src" },Commit the Manifest
Because it carries exact hashes, build.zig.zon makes builds reproducible. Commit it so every teammate fetches the identical code.
build.zig Reads It
The manifest pairs with build.zig, which turns each declared dependency into a usable module. The .zon describes, the build script wires.
const dep = b.dependency("mylib", .{});Quick Check
Recall what guarantees a dependency download has not been tampered with.
Recap
You met build.zig.zon: a ZON manifest with name, version, and dependencies, where each dep carries a url and a hash that zig fetch can fill in. 🎯
الأسئلة الشائعة
هل درس «build.zig.zon ومدير الحزم» مجاني؟
نعم — نص درس «build.zig.zon ومدير الحزم» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Zig Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Zig Academy 4 دروس في المجموع.
ماذا ستتعلم في «build.zig.zon ومدير الحزم»؟
صرّح بالتبعيات في ملف البيان تتمرن على Zig Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Zig Academy؟
لا تُشترط خبرة سابقة. Zig Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «build.zig.zon ومدير الحزم»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Zig Academy هذا؟
نعم. كل درس في Zig Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- استيراد الملفات باستخدام @import
- تنظيم مشروع متعدد الملفات
- build.zig.zon ومدير الحزم
- إضافة وحدة خارجية