| ... | @@ -45,11 +45,11 @@ dependencies: | ... | @@ -45,11 +45,11 @@ dependencies: |
| 45 | - src: git https://github.com/jecolon/ziglyph | 45 | - src: git https://github.com/jecolon/ziglyph |
| 46 | ``` | 46 | ``` |
| 47 | | 47 | |
| 48 | Here I assume that you initialized your project with `zig init-exe` or `zig init-lib`, so your `build.zig` the `addExecutable()` or `addStaticLibrary()` call points to `src/main.zig`. | 48 | Here I assume that you initialized your project with `zig init-exe` or `zig init-lib`, so in your `build.zig` the respective `addExecutable()` or `addStaticLibrary()` call points to `src/main.zig`. |
| 49 | | 49 | |
| 50 | In this case you can `@import("ziglyph")` in `src/lib.zig`, but not in `src/main.zig`. However you can `@import("my-package")` in `src/main.zig`. | 50 | In this case you can `@import("ziglyph")` in `src/lib.zig`, but not in `src/main.zig`. However you can `@import("my-package")` in `src/main.zig`. |
| 51 | | 51 | |
| 52 | Please note, that using `zig init-exe` or `zig init-lib` for creating a project does not mean that you have to use `zigmod init` in application or library mode. Creating a `zigmod.yml` file with proper `name` and `main` only makes your package importable by other projects. This is usually not needed with applications, but quite useful in case of libraries; hence the name. | 52 | > Note: using `zig init-exe` or `zig init-lib` for creating a project does not mean that you have to use `zigmod init` in application or library mode. Creating a `zigmod.yml` file with proper `name` and `main` only makes your package importable by other projects. This is usually not needed with applications, but quite useful in case of libraries; hence the name. |
| 53 | | 53 | |
| 54 | ### Zig and Zigmod package handling explained | 54 | ### Zig and Zigmod package handling explained |
| 55 | | 55 | |
| ... | @@ -66,7 +66,7 @@ root | ... | @@ -66,7 +66,7 @@ root |
| 66 | | 66 | |
| 67 | `root` can `@import` `A`, `B` and `D`, but `E` can be imported only from `D`. `B` can not import anything. (Everybody can import relative files, this limitation is only for packages.) | 67 | `root` can `@import` `A`, `B` and `D`, but `E` can be imported only from `D`. `B` can not import anything. (Everybody can import relative files, this limitation is only for packages.) |
| 68 | | 68 | |
| 69 | In library `zigmod.yml` example the tree looks like this: | 69 | In the library `zigmod.yml` example from above, the tree looks like this: |
| 70 | | 70 | |
| 71 | ``` | 71 | ``` |
| 72 | root (src/main.zig) | 72 | root (src/main.zig) |
| ... | @@ -78,9 +78,9 @@ root (src/main.zig) | ... | @@ -78,9 +78,9 @@ root (src/main.zig) |
| 78 | | 78 | |
| 79 | It is very important to understand, that `my-package` is _below_ `root`, as `name/main` in `zigmod.yml` will create a separate package (it will not be chained to `root`). | 79 | It is very important to understand, that `my-package` is _below_ `root`, as `name/main` in `zigmod.yml` will create a separate package (it will not be chained to `root`). |
| 80 | | 80 | |
| 81 | If you want to use the dependencies from `root`, then make sure that your `zigmod.yml` does _not_ contain a `main` line **and** use `root_dependencies` instead of `dependencies`. This is what `zigmod init` does in application mode. | 81 | If you want to use the dependencies from `root`, then make sure that your `zigmod.yml` lists them under `root_dependencies` instead of `dependencies`. |
| 82 | | 82 | |
| 83 | On the other hand using `root_dependencies` and `dependencies` is not mutually exclusive, you can take advantage of using both, like zigmod does. Using `dependencies` requires a proper `main` field in your `zigmod.yml`. | 83 | Note: Using `root_dependencies` and `dependencies` is not mutually exclusive, you can take advantage of using both like Zigmod itself does. Using `dependencies` requires a proper `main` field in your `zigmod.yml`. |
| 84 | | 84 | |
| 85 | ## Running `zigmod fetch` | 85 | ## Running `zigmod fetch` |
| 86 | This command will inspect your `zigmod.yml` and download any new dependencies as well as pulling updates for any ones already download. It will recursively do this for your entire tree until it is full constructed which will culminate in the generation of two output files: `deps.zig` and `zigmod.lock`. | 86 | This command will inspect your `zigmod.yml` and download any new dependencies as well as pulling updates for any ones already download. It will recursively do this for your entire tree until it is full constructed which will culminate in the generation of two output files: `deps.zig` and `zigmod.lock`. |
| ... | @@ -91,6 +91,8 @@ This command will inspect your `zigmod.yml` and download any new dependencies as | ... | @@ -91,6 +91,8 @@ This command will inspect your `zigmod.yml` and download any new dependencies as |
| 91 | | 91 | |
| 92 | Add `--no-update` if you do want it to fetch remote updates and only regenerate `deps.zig`. | 92 | Add `--no-update` if you do want it to fetch remote updates and only regenerate `deps.zig`. |
| 93 | | 93 | |
| | 94 | Alternatively, if you want to download updates exactly as defined by the lockfile, use [`zigmod ci`](./commands/ci.md) instead of `zigmod fetch`. |
| | 95 | |
| 94 | > Ref: See [`zigmod fetch`](commands/fetch.md) reference for more info. | 96 | > Ref: See [`zigmod fetch`](commands/fetch.md) reference for more info. |
| 95 | | 97 | |
| 96 | --- | 98 | --- |