0Pricing
Zig Academy · レッスン

build.zig.zonとパッケージマネージャー

マニフェストで依存関係を宣言します

「build.zig.zonとパッケージマネージャー」はCoddyKit上の無料Zig Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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.gz

The 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時間対応のAIチューター)、Zig Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Zig Academyコースには全4レッスンが含まれています。

「build.zig.zonとパッケージマネージャー」で何を学びますか?

マニフェストで依存関係を宣言します ブラウザで直接実行するハンズオンコードでZig Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Zig Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのZig Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「build.zig.zonとパッケージマネージャー」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このZig Academyレッスンでコードを書いて実行できますか?

はい。すべてのZig Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. @importでファイルをインポートする
  2. 複数ファイルプロジェクトの構成
  3. build.zig.zonとパッケージマネージャー
  4. サードパーティモジュールの追加
← Zig Academyに戻る