The zane command
zane is the tool a Zane programmer runs. It creates projects, manages their
dependencies, and builds and runs them. It does not compile anything itself.
The zane-version of the project being built names the compiler that builds
it and every package it depends on, and zane installs and runs that
compiler, zanec
(dependencies.md §14).
This document lists every command, says which parts of the spec each one
carries out, and states what zane needs from zanec. The spec is the source
of truth for the files and the rules; this document cites it rather than
restating it.
1. What zane owns, and what it leaves to zanec
zane is not pinned by any project, so one installed copy must build projects
pinned to any compiler version. Everything whose behavior a pin has to fix
belongs to the compiler instead.
zane |
zanec (the pinned compiler) |
|---|---|
| Creating projects | Parsing, checking, lowering, code generation |
Reading, validating and writing zane.coda and zane-lock.coda |
Rewriting the ! placeholder prefix of a library’s exports |
| Resolving tags, verifying commits and archive hashes | Linking a program with the runtime it carries |
| The global package cache | Cross-compilation for --target |
| Installing compilers and running the pinned compiler, and updating itself (§4.2) | Writing a library’s objects for a release |
| Listing a project’s builds for an editor, and starting the language server (§2.7, §2.8) | The language server: what an editor shows of a project’s code |
The interface between the two is a contract (§5). A change to it is the one kind of change that can break a project nobody touched.
zane is written in Crystal for now, and is to be
ported to Zane once Zane can carry it. It reads and writes .coda files
through the Crystal binding of zane-lang/coda,
vendored as a submodule, and it hashes with its own SHA-256, so a release links
no TLS or crypto library. Repositories are fetched with git and archives
downloaded with curl, which every supported system ships. zane reads a release archive’s tar format
itself, decompressing it with the zlib Crystal links, so that it checks every
entry before it writes anything (§3.1).
1.1 Progress on a terminal
When stderr is a terminal and TERM is not dumb, every command reports its
slow steps there as they happen: listing a repository’s tags or the
compiler’s releases, finding the compiler init pins, fetching a package’s
checkout, downloading, verifying and unpacking an archive,
rewriting and remapping objects, compiling a dependency or the project’s
packages, and installing a toolchain (§4.1). A finished step stays on screen
with a check mark, what it found and how long it took; the running step is
redrawn in place with a spinner and, when it counts bytes or files, a
progress bar with the amount done and the time left, and the rate for bytes.
The redrawn line is fitted to the terminal’s width. A failed step is marked
✗ above the error.
Versions whose objects the cache already holds, prebuilt or compiled from
source, are named in one line as coming from the cache. Their source code
still reaches an optimized build, which compiles the dependency code it
calls to inline it (compiler
separate-compilation.md
C12), and that build’s step names the inlined dependency.
What zanec writes while it checks or compiles the project’s packages is
held and written once the step is marked done or failed, so it never lands
inside the redrawn line; a program run or test starts writes straight to
the terminal. Compiling a dependency, rewriting and remapping show what the
compiler wrote only when it fails, as part of the error. The lines
commands print to stdout come between steps. A non-empty NO_COLOR turns
colours off. Redirected stderr and dumb terminals get none of this, and see
zanec’s output as it is written.
2. Project commands
2.1 zane init [dir]
Creates a project in dir, or in the current directory when dir is omitted.
dir is created if it does not exist.
The target directory must be empty except for the files a newly created
repository holds: .git/, .github/, README*, LICENSE*, COPYING*,
.gitignore and .gitattributes. Anything else is an error, which lists what
was found and suggests zane init <name>. This stops zane init run by mistake
in a folder of projects from filling that folder with project files.
In a terminal, init asks these questions, showing the default for each:
| Question | Default | Written to |
|---|---|---|
Create the project in <absolute path>? |
yes | — |
| Package name | the directory’s name, converted to camelCase | the first package’s directory |
| Library or application? | application | whether its first package is in lib/ or bin/; it can add the other later |
| Version pattern | v*.+.++ |
version-pattern |
| Initialise a Git repository? | yes, unless already inside one | — |
The name must be a valid package name
(lexical.md §3).
The version-pattern question explains the pattern in one line, because the
spec fixes the pattern when the project is created
(dependencies.md §2.1).
Every question has a flag: --name, --lib / --app, --version-pattern,
--no-git, and --yes to accept every default. When standard input is not a
terminal, init asks nothing: it uses the flags and defaults, and fails if a
default cannot be worked out.
The project is pinned to the newest compiler installed (§4.1), so init works
offline, or to the compiler --zane-version names, when that compiler is
installed. Its tag becomes zane-version, and the commit its toolchain record
names becomes the lock file’s zane-commit.
With no compiler installed, or without the named compiler, init looks the release up
online instead, by listing the tags of zane-lang/compiler with
git ls-remote, so it needs no API access: the highest vMAJOR.MINOR tag, or
the tag --zane-version names, becomes zane-version, and the commit that tag
points to becomes zane-commit. With no release published, init fails.
Either way, init reports which compiler it pinned and where it found it.
The project depends on std, whose core
package the code init writes imports. init lists the tags of
https://github.com/zane-lang/std with git ls-remote, as zane add does
(§3), pins the highest version tag, compiled from source, and checks it out
into the package cache, as zane add --from-source and the next build would.
When std cannot be reached, init pins instead the highest version tag
whose checkout is already in the package cache, which the installers and
zane self update put there (§4.2), so init works offline. With neither,
init fails, writes nothing, and suggests zane self install-std or
--no-std. init also refuses, writing no project files, a std the
project could not build with, though the package cache may by then hold its
checkout: one without a public core package, which the code it writes
imports; one with a package of the first package’s name, which the
project could not import beside its own
(dependencies.md §8),
and one whose zane-version needs a newer compiler than the pinned compiler, or
another major. --no-std skips std: the project then has no dependency, and
its code uses only the intrinsics.
init writes nothing until every question is answered, so cancelling leaves the
directory untouched. It then writes:
zane.coda, withzane-versionandversion-pattern, and adepstable holdingstd(from source), empty under--no-std;zane-lock.coda, holdingzane-commitand aresolutionstable holdingstd’s URL and commit, empty under--no-std;- for an application,
bin/<name>/main.zn, a program package with amainthat printshello world; - for a library,
lib/<name>/<name>.zn, a library package with one public example function, andtest/<name>/main.zn, a test package whosemainimports it, checks that function and aborts when the check fails (packages.md§2.1 and §7); .gitignorelistingout/, appended to if one exists.
2.2 zane check
Runs the compiler up to and including semantic checking and stops. This is the
fast loop while editing. It checks the project’s library packages together, in
a build with no root, then each program package and each test package as the
root of its own build (§5), and stops at the first that fails. A library
package’s C files are compiled in each of those builds, so zane shows a C
warning the compiler gives once, at the first build that gives it; build and
run do the same across their programs.
When a package holds C (a .c file or a c.coda), check first writes
compile_commands.json at the project’s root, the compilation database an
editor’s C language server (clangd) reads, so a binding’s C sees
<zane_ffi.h> and the include and define rows of its c.coda. Each
build’s database comes from zanec --compile-commands, and zane merges
them, each source once; what a build cannot list is left to the check to
report. zane init puts the file in .gitignore. check also copies
zane_ffi.h to include/ of zane’s home (~/.zane/include), a path that
does not move, for an editor set up by hand. It works from
any directory inside the project, as every command below does: zane looks
for zane.coda there and in each directory above.
Before calling the compiler, zane reads the project’s packages from lib/,
bin/ and test/ and holds them to the rules of
packages.md §2 and §7, since zane, not the
compiler, lists the directories: a .zn file directly in one of the three, a
program package with a subdirectory of sources, a nested test package that
mirrors no subpackage, and the names a project keeps apart.
2.3 zane build [PROGRAM] [--target T] [-o OUT] [--build-argument A ...]
Resolves and fetches dependencies
(dependencies.md §13),
then has zanec compile and link every program package in bin/, or only
the program you name. Each goes to out/<target>/<name>, with
out/host/<name> when no target is given, and -o names the file when one
program is built. The program is optimized. T is a target triple, spelled as zig cc reads it,
such as x86_64-windows-gnu
(compiler platforms.md),
and defaults to the host, which zane names the same way: x86_64-linux-gnu,
aarch64-macos or x86_64-windows-gnu. That name is the row it looks up in a
dependency’s zane-artifacts.coda. A dependency with no artifact for T
stops the build with an error that names it and suggests from source. A
project with no program package is refused: its library packages are checked
with check and published with release.
The project’s fixed-region and spawned-fixed-region, when its manifest
gives them, set how much memory each thread of execution’s nested scopes may
take, in every program and test package it builds
(memory.md §3.7).
zane checks that each is a positive whole number of MiB or GiB whose
byte count fits its Int64 representation, and passes it in bytes (§5).
There is no 32GiB cap: native addresses let the runtime reserve whatever
range the target system permits. A dependency’s manifest cannot set either
(dependencies.md §2.1).
--build-argument A, given any number of times, adds A to the arguments
the build is started with, in order: inside a call marked comptime, the
runtime’s arguments gives them
(effects.md §5.6).
build, run, test and inspect take it, and pass it to every compiler
run of the program’s or test package’s own build, both tiers of run and
test included, so the two tiers compute the same values. Each dependency
compiled from source or a path is compiled with them too, and fetch takes
it for those dependencies alone.
Only the root package reaches the runtime
(packages.md §6.1),
but an exported lambda has the rights of root-package code wherever it is
declared
(§8.4),
so a library’s exported lambda can read them. The compiler marks an object
whose marked calls read them (§5), and the cache reuses such an object only
for the same arguments; an object without the mark is reused whatever they
are (§3.1). A release whose prebuilt objects carry the mark was compiled with
its publisher’s arguments, so zane compiles it from source instead. With
none given, nothing is passed, so a compiler released before comptime
still builds the project.
2.4 zane run [PROGRAM] [--build-argument A ...] [-- ARGS]
Builds a program package for the host into out/run/<name>, then runs it with
ARGS and exits with its status. In a project with several programs, you name
the program to run. run uses the build that gives the program’s result
soonest, counting the build and the run together: the compiler’s tiered build
(compiler tiers.md).
zane starts the optimized build, tier 1, in the background, builds the
unoptimized build, tier 0, and runs it as soon as it is linked, with
ZANE_TIER_UP naming tier 1’s library beside it, <name>.tier1.so
(.dylib on macOS, .dll on Windows). Tier 0 moves each of its functions to
tier 1 once that library is there, so a short program never waits for the
optimizer and a long one finishes on optimized code. A tier-1 build still
going when the program ends is stopped, and what an earlier run left beside
the program is removed before the build. The compiler keeps tier-1 libraries
in its cache, so a program run again unchanged takes optimized code within
its first moments. The program behaves the same either way, so only its speed
differs from the program build makes.
2.5 zane test [TEST] [--build-argument A ...] [-- ARGS]
Builds every test package in test/, or only the test package named by its
directory under test/, such as gui/opengl, for the host into out/test/,
and runs each with ARGS, each built and run as run builds and runs a
program, so the two never differ. Each test package is the root of its
own build, and the project’s library packages are compiled with it
(packages.md §7.2).
The graph is the project’s deps and test-deps together
(dependencies.md §13).
Run on one test package, test exits with its status. Run on all, it names
each as it starts, then says how many passed or which failed, and exits with
1 when any did. A project with no test package is refused.
Each test package defines its own tests and their reporting: zane runs
one program for each test package and passes on that program’s exit status, so a
testing library in test-deps decides how failures are counted and shown.
2.6 zane clean
Deletes out/.
2.7 zane builds
Prints the builds zane check checks, as one JSON object on standard output,
and runs no compiler:
{"builds": [{"label": "the library packages", "flags": ["--no-root", "--package", "geo=/p/lib/geo", "..."]},
{"label": "bin/app/", "flags": ["--root", "--package", "app=/p/bin/app", "..."]}]}
Each build has the label zane check shows for it and the flags check
passes the compiler (§5), without --check. The language server (§2.8) runs
zane builds in each project an editor opens and checks each file in the
first build that holds it, so an editor shows the problems zane check
reports. Like check, builds fetches what the project’s graph needs
first, and its progress and warnings go to standard error.
2.8 zane lsp
Runs the language server an editor starts for Zane files: the compiler’s own
server, zanec --lsp --zane ZANE, on zane lsp’s standard input and output,
with ZANE the path of this zane, which the server runs as zane builds
(§2.7). The server’s log passes through to standard error.
Started inside a project, zane lsp runs the project’s compiler, as every
other command does. Started anywhere else, it runs the compiler
ZANE_COMPILER names, then the newest toolchain installed, then zanec on
PATH. A compiler released before the language server prints its usage
for --lsp, and zane lsp then says so and names zane toolchain update.
The server itself, and what it offers an editor, is described in the
compiler’s
language-server.md.
3. Dependency commands
These and zane toolchain update (§4) are the only commands that write
zane.coda and zane-lock.coda, and they always change the two files together
(dependencies.md §2.3).
| Command | Does |
|---|---|
zane add <url> [tag] [--as key] [--from-source] [--test] [--rename package=name …] |
Resolves the tag, newest when omitted, and pins its commit. The newest is the highest tag of a v and dot-separated numbers. The key defaults to the last part of the URL path. Resolves the graph with the library in it before writing either file, so a library that cannot be resolved is never recorded. Refuses a project with no public library package. Refuses, too, a graph in which a package linked as a release has no zane-artifacts.coda, since no build could link it: the library itself, unless --from-source is given, or one of its own dependencies, which are always linked as releases. A release whose artifact manifest lists no archive for the host is recorded with a warning, since the project may build for the targets it lists. Prints the import lines for its public library packages. With --test, writes the row into test-deps instead of deps. With --from-source, for a library the project already depends on at that URL, in the block --test names, sets its from to source at the version it pins; zane dev off sets it back to release. A dependency compiled from a local project is left as it is. Each --rename writes a renames row for the new dependency, held to the rules zane rename checks, so a library whose package’s name clashes with one the project already imports can be added under another name, or with that package dropped. |
zane remove <key> |
Removes the key, from deps or test-deps, from both files, with its renames rows, and warns about each line of the project’s packages that still imports one of its packages. |
zane update [key [tag]] [--accept-tag-move] |
Moves one key, or every key, to the tag named, or else the newest, and pins its commit. When the tag named is the tag the lock file already pins, and that tag now points to another commit, the tag has moved: without the flag, zane update refuses it with a security error. Refuses, as add does, a release it would move to a tag that publishes no prebuilt objects. |
zane dev <key> <path> / zane dev off <key> |
Sets the key’s from to a local project, or back to release. The path is given from where the command runs and written from the project’s root. dev off refuses, as add does, a release that publishes no prebuilt objects. |
zane remap <url> / zane unremap <url> |
Adds the URL to the remaps list, or takes it out. Warns when no package of the graph has the URL. |
zane rename <key> <package> <name> / zane rename off <key> <package> |
Writes the renames row that has the project import the key’s package by the name, replacing the package’s row if it has one, or drops the package when the name is _; rename off removes the row (dependencies.md §2.1, §2.3, §8). The name is a package name that is neither test nor the package’s own; the package must be a public library package of the version the key pins, and the rows must not drop every one. The changed graph is resolved before the file is written, so a name that would clash with another package the project imports is refused, and so is a rename off that would bring one back. off is the first argument only while the project has no dependency of that key; zane rename <key> <package> <package>, naming the package’s own name, removes the row too, whatever the keys are. |
zane fetch [--target T …] [--build-argument A …] |
Runs the build flow up to linking, for each target. For CI and offline work. It links no program, so it compiles a source dependency for any program; a build compiles it again for the program it links into, which needs nothing online (§3). It compiles a dependency whose marked calls read the build’s arguments with those given here, which a build reuses only when it is given the same --build-argument values (§2.3). |
zane tree [--test] |
With --test, prints the test build’s graph, the test-deps rows marked. Prints the resolved graph: each package under what depends on it, with its key, tag, public library packages, URL and where its code comes from; a package its dependent’s renames rows rename is shown as math as twoMath, and one they drop as extra dropped. A version reached again is printed once more, marked, without what it depends on, and a version remapping displaced is marked with the version chosen in its place, whose dependencies follow beneath it. Then it lists the versions of each package linked side by side, and those remapping collapsed. |
update, dev and rename apply to a test-deps key as to a deps key. add, update,
dev and rename resolve the changed graph, test-deps included, before writing either
file: each version’s source is checked out to read its manifest, and the graph
is held to the rules of §3.1 that need no objects, its packages’ zane-version
included, so a change that leaves it unable to resolve is refused and nothing is
written. They download no archive and compile nothing; the next build, run,
test or fetch does that, once, for the pins it finds, and a dependency that
does not build is reported there. remove, remap and unremap write without
resolving. check, build, run and test resolve and fetch the graph as §3.1 says,
and warn about each URL in remaps that names no package of the graph
(dependencies.md §2.1).
3.1 Fetching
check, build, run, test and fetch each read the graph from the
project’s two files and, recursively, from each dependency’s own two files at
its pinned commit (dependencies.md §13).
Only check stops before the objects: it needs the sources alone.
The project’s compiler compiles the project and each source and path
dependency, reads every package of the graph, and rewrites and links every
object; a release dependency’s objects come from its own zane-version. Once the sources are read, and before any archive is downloaded,
zane refuses a package whose zane-version is of a major other than the
project’s, or newer than the project’s, naming each such package
(§14).
When a newer compiler of the project’s major would build them all, the error
names the zane toolchain update that moves the project to it. The
project’s test-deps rows join the graph for test, fetch, and the test
packages check checks, and never for build or run; a dependency’s own
test-deps never join it
(dependencies.md §2.1).
- Sources. Each version of each package is cloned at its tag into the
cache,
~/.zane/packages/<normalized url>/<tag>/src/, and refused with a security error unless the tag is the commit the lock file pins (§4). A checkout already in the cache at the pinned commit is used without going online. The commit fixes what the checkout holds, so a tag that moved since cannot change it, and builds work offline oncezane fetchhas run. - Archives. For a
releasedependency,zanereads the target’s row of the checkout’szane-artifacts.coda, downloads its URL withcurl --proto =https --proto-redir =https, and refuses the file unless its SHA-256 matches the committed hash (§5). It then unpacks the archive intoartifacts/<target>/build/, refusing it whole if any entry is not a directory or regular file underbuild/. - Rewriting.
zanec --rewrite(§5) turns each object’s placeholder into the package’s stamp, intobuild/<target>/, and stamps the packages of the file of C module hashes beside them. Last,zanewritesbuild/<target>.coda, recording the commit, target, archive hash and compiler pin (zane-versionandzane-commit) the objects were made with. The objects are reused only while all five match; otherwise they are rewritten again, from the kept archive when its hash still matches. An archive that holds the compiler’s mark of a read of the build’s arguments (§5) is not rewritten: its objects hold its publisher’s arguments, sobuild/<target>.codarecords that the archive read them, and the dependency is compiled from source as asourcedependency is. - Compiling from source. A
sourcedependency is compiled on its own, optimized, from its checkout, intobuild-from-source/<target>/package.o, with the files the compiler writes beside it (§5), named with its stamp, against the versions its own lock file pins (§12.1).build-from-source/<target>.codarecords the commit, target and compiler pin it was compiled with, and that it was optimized, and the object is reused only while all five match, and, for one compiled for a program, the hash below. When the compiler marked the object as reading the build’s arguments (§5), the record also keeps the hash of those arguments, and the object is reused only for a build given the same--build-argumentvalues; a build given other values compiles it again in its place. The object is the code a program runs wherever it calls the dependency without inlining it, so it is optimized, once, and reused. Before a program or test is linked,zanec --write-backswrites the file of the places its spawned calls write back into, into a file of its own inout/write-backs/, removed once the dependencies are compiled, and eachsourceand path dependency is compiled for that program alone with--program-write-backs, so its reads of every other place are plain loads rather than snapshots (compilerlowering.md§9, “Snapshots”). Such an object is kept inbuild-from-source/<target>.<places>/,<places>being the first 16 digits of the file’s SHA-256, with<target>.<places>.codarecording the whole hash too, so it is reused only for programs that write back into the same places: programs that write back into none all write one file, and share one object. When the compiler cannot write the file, as for a program the compiler refuses, and while remapping moves what the objects name, which those places do not follow, a dependency is compiled for any program, intobuild-from-source/<target>/. A path dependency is compiled the same way on every build, but unoptimized, so a build stays quick while it changes, into the project’sout/deps/<target>/, emptied first so it holds only that build’s files, and never enters the cache (§12.2). - Remapping. For each URL in
remaps, the versions in the graph are grouped by theversion-patterneach one’s manifest declares, and within a group by their*components; each group of more than one version is collapsed onto its best version by the pattern’s priorities (§15.3). A tag of another shape is kept apart quietly, and versions whose patterns differ are kept apart with a note (§15.4). A displaced version is neither compiled against nor linked: every key that named it names the chosen version, andzanec --remap(§5) moves each linked object’s references to it, into the project’sout/remapped/<target>/, since which versions are displaced is the project’s choice. - Linking. The compiler is given each version linked with
--package STAMPNAME=DIR, each package’s keys, the project’s included, with--import, and every object with--link(compilerseparate-compilation.mdC10), and, forbuild, each file of C module hashes with--c-hashes. Each version is a package of its own, so versions of one package, and packages of one name, are linked side by side (§11), and a key need not be its package’s name. The keys a package of a project imports by are its dependencies’ packages’ names, or the names the project’srenamesrows give them, and a dropped package has none (§8); each fetched project’s own rows give its own packages’ keys.
Each part of a cache entry is made beside where it goes and renamed into place once whole, so an interrupted fetch leaves nothing that looks ready.
4. Publishing, toolchains and the cache
| Command | Does |
|---|---|
zane release <tag> [--targets T…] |
Refuses a dirty tree, a tag that does not fit version-pattern, and any path from in deps. For a project with library packages, has the compiler its zane-version names write their !-prefixed objects for each target, with the files it writes beside them (§5), packs one archive per target of all of them, writes zane-artifacts.coda, commits and tags. An object whose marked calls read the build’s arguments is packed with the compiler’s mark (§5), so a project that depends on the release compiles it from source with its own arguments (§3.1). Archives are left in out/release/<tag>/. |
zane release upload <tag> |
Uploads those exact archives to the GitHub Release, then downloads each one and checks its hash. The only GitHub-specific step; fetching needs only HTTPS. |
zane toolchain install [tag] |
Installs the latest published compiler release, or the tag named, into the shared toolchain directory (§4.1). Works outside a project. |
zane toolchain update [tag] [--accept-tag-move] |
Installs the tag named, or else the newest release of the project’s major, found by listing the tags of zane-lang/compiler with git ls-remote, as install does, then moves the project’s compiler pin to it: zane-version and zane-commit together. Resolves the project’s graph with that pin first, as update does (§3), so a pin older than a package’s zane-version, or of another major, is refused and nothing is written. It compiles nothing, so a dependency the new compiler cannot build as pinned does not stop it: zane update then moves that dependency to a version the compiler builds, and the next build compiles them. When the tag named is the project’s current zane-version, and that tag now points to another commit than zane-commit, the tag has moved: without the flag, zane toolchain update refuses it with a security error. |
zane self update [tag] |
Replaces the running zane with the latest published CLI release, or the tag named, then puts the newest std in the package cache (§4.2). Works outside a project and changes none, though it writes the package cache. |
zane self install-std |
Puts the newest std in the package cache, for zane init to use offline (§2.1, §4.2). The installers run it. Works outside a project and changes none, though it writes the package cache. |
zane cache list / path / clean [--stale] |
Lists each version in ~/.zane/packages with the targets its objects are ready for and its size, prints the directory, or empties it. With --stale, removes only what no build uses: the parts an interrupted fetch left beside where they go, and rewritten objects without their record. |
zane inspect cst|sst|decls|tst|cgt|ll [PROGRAM] [--optimize] [--target T] [--build-argument A ...] |
One of the pinned compiler’s debug views of a program, printed, for the project’s only program or, when there are several, the program you name. decls, tst, cgt and ll view the program’s build, given the packages build gives it (§5), and --optimize, --target and --build-argument (§2.3) show it as zane build makes it, which is how a reader sees what an optimized build computed while it compiled. cst and sst view each source file of the program package, in name order. |
The design of a release’s output for a project’s programs is still open.
4.1 Installed toolchains
zane keeps what projects share in ~/.zane, or in the directory ZANE_HOME
names. Each installed compiler is a directory toolchains/<tag>/ holding the
compiler at bin/zanec and its record, toolchain.coda:
url https://github.com/zane-lang/compiler
commit 0123456789abcdef0123456789abcdef01234567
url is the repository the compiler was built from, and commit the commit
its tag pointed to, which is what a project’s zane-commit pins. Installation
downloads the selected GitHub Release archive for the CLI’s host and verifies
it against that release’s SHA256SUMS. It checks the archive’s version and
record against the repository tag, then atomically publishes the complete
directory. An already installed matching release is reused; existing incomplete
or conflicting directories are preserved and reported. Installing does not
change any project’s compiler pin. A directory without a record is an interrupted install
and is ignored, as is a toolchain from another url. A toolchain is found from
its record alone; zane never queries the compiler for its version.
4.2 Updating zane itself
zane self update [tag] installs a release of the CLI from
zane-lang/zane over the binary
that is running. It finds the release through the GitHub API, as
toolchain install does, and checks the binary as the installers do. Without a
tag it takes the latest release, and only when that is newer than the running
binary; a tag names any release, older ones included. Versions compare as
numbers, so v0.2 and v0.2.0 are the same release. A release names its
binaries zane-linux-x86_64, zane-macos-arm64 and zane-windows-x86_64.exe,
and the update downloads the binary for its host into a directory beside the
binary, checks it against the release’s SHA256SUMS, runs it with
--version to check that it starts and is that release, and then renames it
over the old binary, so an interrupted update leaves one or the other whole.
Windows does not replace a running executable but does rename it, so there the
old binary is moved aside first, under a name starting .zane-old-, and the
next run of zane deletes it.
A binary whose real path lies in the Nix store or a Homebrew Cellar belongs
to that package manager, and a development build, whose version is not a
release tag, to its source tree, so the update refuses both and names what
updates them instead. The update of the binary writes only in the directory
that holds it, so it needs the access to it that installing did. Updating the
CLI changes no project and installs no compiler (§1); besides that directory,
it writes only the package cache, as below.
After the binary, whether or not it changed, self update puts the newest
release of std in the package cache, as
zane self install-std does: it lists std’s tags with git ls-remote and
checks out the highest version tag into the package cache (packages/ in
~/.zane, or in ZANE_HOME), where
zane add --from-source would, unless that checkout is there already. This is
what zane init falls back to offline (§2.1). The installers run
zane self install-std once the binary is in place. A failure there is only
warned of, since the CLI is installed either way. An older zane, which does
not do this, updates itself without it, so after updating from one, run
zane self install-std once.
5. What zane needs from zanec
A library package is named by its path within its project’s lib/, and
which packages each package may import follows from where it lies
(packages.md §2.2 and §4.3),
which only zane reads off the directories, so the contract is:
--package PATH=DIRnames a package by its path,gui.openglfor a subpackage, whose last part is the name its files declare, and--package STAMPPATH=DIRgives it its stamp as well: the pinned tag,%, the identity hash of its URL and%(dependencies.md§6.1). A package with a stamp is known by its stamped path, so each version of a project is a set of packages of its own. The first--packagecomes first: the program or test package being built, or the first library package of a library build.--import PACKAGE:KEY=PACKAGEgives a package each package it may import, by the key it imports it by, its name, each package named as--packagenames it. Once any--importis given, a package imports through its keys alone, so an import the rules forbid is the compiler’s error. A build whose packages import nothing gives the first package its own name as its key, so the rule still holds.--rootor--no-root. A program’s or a test’s build passes--root: its first package is the root, and one withoutmainis a compile-time error (packages.md§6.2). A library build passes--no-rootand has no root, so none of its packages reaches@program$.--fixed-region BYTESand--spawned-fixed-region BYTES: the size of the main thread of execution’s range of frames and of each spawned call’s, passed in bytes after converting the manifest’s whole number ofMiBorGiB.zanepasses them only for a manifest that sets them; the compiler’s default stands for the other.--build-argument A, any number of times, given to a program’s or a test package’s build, and to each dependency’s--objectbuild, only when the user gives it (§2.3): the arguments the build is started with, which acomptimecall reads.--check,--build OUT,--target Tand--optimize.Tis spelled aszig ccreads it; the compiler hands LLVM its normal form and the C compiler the triple as written.--build OUT --tieredand--tier-up OUT, the two tiersrunandtestbuild at once (§2.4): tier 0, an executable that loads the library named byZANE_TIER_UPwhile it runs, and tier 1, that library. Both take the same packages and imports; tier 1 takes no--link.- A stamped dependency arrives as objects of its own, so the compiler emits
nothing it declares.
--link FILEadds one of them to--build‘s link, and--c-hashes FILEnames the file of its C modules’ hashes, which an optimized build compares before it inlines the dependency’s C (compilerffi.mdF13). A tiered build inlines none, sorunandtestpass no--c-hashes. --object OUTwrites the object of every library package of the project being compiled, the packages that share the first package’s stamp, every symbol they define under the!placeholder, or under their stamp when they have one. BesideOUTit writesSTEM.c.N.o, an object for each C source holding assembly, andSTEM.c.hashes, the hashes of the packages’ C modules,STEMbeingOUTwithout its extension (compilerffi.mdF15); each is as much the package’s as the object is. When acomptimecall of the build read the build’s arguments, it also writesSTEM.arguments, an empty file that marks the read (compilercomptime.md);zanekeys the cache on it and links none of it.zane releasepacks the first (§4), and a dependency compiled from source or a path is the second (§3.1).--write-backs OUT, given a program’s or a test’s flags, writes the file of the places its spawned calls write back into, and--program-write-backs FILE, given with--no-root --object OUT, builds a dependency’s object for that program alone, its reads of every other place plain loads rather than snapshots (compilerlowering.md§9, “Snapshots”). A compiler that refuses--write-backs, one released before it, builds every dependency for any program, as §3 says.--lsp --zane ZANEruns the language server on standard input and output, runningZANE buildsin each project it serves (§2.8).--rewrite STAMP INPUT OUTPUTwrites the objectINPUTwith every!in its symbols replaced bySTAMP, for ELF, Mach-O and COFF objects, and a file of C module hashes with every!of its packages replaced bySTAMPtoo. It is the compiler’s step because the symbol spelling is the compiler’s, so the pinned compiler rewrites what that same version built.--remap FROM TO INPUT OUTPUTwrites the objectINPUTwith every reference to the version stampedFROMmoved to the version of the same package stampedTO, for remapping (dependencies.md§15.6).
zane passes these flags to every compiler alike. While the language is at
major 0, it drives only the compiler releases that take them, and a project
pinned to an earlier one moves its pin to a release zane drives by naming
that release’s tag to zane toolchain update
(dependencies.md §14).
zane passes each build its packages in this order: the first package, the
project’s library packages, then every version its graph links, each with its
library packages. A program’s build gives the program package the project’s
top-level library packages and its dependencies’ public ones; a test
package’s adds those of test-deps, and for a nested test package the
subpackage it tests
(packages.md §7.3).
6. Phases
- Local projects.
init,check,build,run,clean, and thezanecflags of §5. No dependencies, so a project uses the storage primitives (@primitives$) directly, as the compiler’s test fixtures do. - Dependencies.
add,remove,update,dev,remap,rename,fetch,tree, and the cache (§3, §3.1). Built. - Releases.
releaseandrelease upload, and cross-compilation. - Toolchains.
toolchain install [tag]andtoolchain update [tag], andself update [tag]andself install-stdfor the CLI itself (§4.2). Built. - Layout and tests. The
lib/,bin/andtest/layout with subpackages, programs per directory ofbin/,test, thetest-depsblock,add --test,tree --test, and the packagesinitwrites (§2.5). Built. - Inspection.
inspectand its six views, with--optimizeand--targetfor the views of a build (§4). Built. - Editors.
buildsandlsp, which start the compiler’s language server on a project’s builds (§2.7, §2.8). Built.
zane runs the first compiler it finds among these, in this order: the
compiler ZANE_COMPILER names, the toolchain installed for the project’s
zane-version (§4.1), and zanec on PATH; zane lsp outside any
project takes the newest toolchain installed in place of the project’s
(§2.8). A compiler selected by
ZANE_COMPILER or PATH is not checked against the project’s pin.