Projects
This guide covers the files zane keeps for a project, how dependencies and their versions are recorded, and which compiler a project uses.
The project’s files
A project is a directory with a zane.coda at its root:
zane.coda the manifest: what the project wants
zane-lock.coda the lock file: the exact commits the manifest resolves to
lib/ library packages, which other projects can import
bin/ program packages, each built into a program
test/ test packages
out/ build output, ignored by Git
A package’s directory holds its .zn files, and may also hold C code and a
c.coda with its C build settings (Calling C).
Both .coda files are committed, and zane writes them for you: the
commands below change them together, so they never disagree. zane finds
the project from any directory inside it.
The manifest
After zane add https://github.com/zane-lang/std --from-source, a
zane.coda reads:
zane-version v0.53
version-pattern v*.+.++
deps [
key version from
std v0.18 source
]
zane-versionis the compiler release that builds the project.version-patterndefines which versions of this project can replace one another (below). It is chosen when the project is created and stays fixed.depslists the dependencies, each under a key: the name thatzanecommands use for the dependency.versionis the tag the dependency is pinned to, andfromgives the source of its code:releasefor the prebuilt archive the library publishes,sourceto compile it in your project, or a local path such as../geometry.
A test-deps table, with the same columns, holds dependencies that only the
test packages use. fixed-region and spawned-fixed-region (such as
fixed-region 1GiB) set how much memory a program’s nested scopes may take,
and how much each spawned call’s nested scopes may take.
The lock file
zane-commit 617c32da19d95789ae942213608fbba825127333
resolutions [
key url commit
std https://github.com/zane-lang/std cf261378362579a8e6e6a98e823bfcf4cdcbff45
]
The lock file records each pinned tag with the commit that the tag pointed to
when the dependency was added, and zane-commit records the compiler’s commit
the same way. A tag that later points
at another commit is refused as a security error, unless you accept the move
with --accept-tag-move. A package is identified by its repository URL; the
key is only a local label.
Working with dependencies
| Command | Effect |
|---|---|
zane add <url> [tag] |
Depends on a library at its newest tag or at the tag you name, and prints the import lines for the library’s packages |
zane add <url> --from-source |
Adds the library the same way, but compiles it in your project instead of linking it from a release |
zane add <url> --test |
Adds the library to test-deps |
zane update [key [tag]] |
Moves one dependency, or all of them, to the newest tag or to the tag you name |
zane remove <key> |
Drops a dependency, and warns about imports that still use it |
zane dev <key> <path> |
Compiles the dependency from a local checkout while you work on both |
zane dev off <key> |
Switches the dependency back to its release |
zane tree |
Shows the resolved dependency graph |
zane fetch |
Downloads everything a build needs, so the next build works offline |
zane tree for the project above prints:
hello
└── std v0.18 (core, math, regex), https://github.com/zane-lang/std, from source
A package’s code imports a dependency’s packages by their own names, such as
import core$;, never by the key. When two dependencies have packages of the
same name, zane add --rename pkg=name or zane rename <key> <pkg> <name>
imports one of the packages under another name.
Every dependency’s own dependencies are fetched as releases, at the versions
that dependency pinned. Two versions of the same library can be linked into
one program side by side; zane remap <url> instead links a single version in
place of all the versions that the library’s version-pattern marks as
interchangeable.
Versions
A release is a Git tag such as v0.15. The version pattern v*.+.++ reads
“the first number must match (*); among the matches, take the highest
second number (+), then the highest third (++)”. The pattern lets zane remap
pick one version for every project that depends on the library.
Fetched packages are kept in a cache shared by all projects, under
~/.zane/packages. zane cache list shows the cache’s contents, and
zane cache clean empties the cache.
The compiler a project uses
Each project pins its compiler, so projects on different compilers build side
by side. Installing a newer compiler (zane toolchain install) doesn’t change
any project. To move a project to another compiler:
zane toolchain update # the newest release of the project's major version
zane toolchain update v0.53 # or the release you name
zane toolchain update checks the dependency graph against the new compiler
before changing zane-version and zane-commit.
To build with a compiler you built yourself, set ZANE_COMPILER to that
compiler’s path; zane then uses it instead of the pinned compiler. When
ZANE_COMPILER is unset and the pinned compiler is not installed, zane uses
a zanec on your PATH. zane checks neither compiler against the pin.