(zilch lang ninja): document incremental build

Change-Id: I6a6a696472806049b5ecab203487254f32a716b7
This commit is contained in:
puck 2025-10-01 14:59:25 +00:00
parent 0036f464ac
commit 3e23769348
2 changed files with 38 additions and 5 deletions

View file

@ -50,6 +50,11 @@ dev -> #<store path /nix/store/lmdgblqm0prkx3hcs2q76rzcvg1xm6cm-gtest-1.16.0-dev
out -> #<store path /nix/store/b2ylcnfsaf2wmzk51whgq5r86xb955xq-gtest-1.16.0 (/nix/store/ksrbqg2nkgm8zq3g59gzydf5976griis-gtest-1.16.0.drv!out)>
----
It's also possible to use `override-source: "<path>"` inside the configuration
file, which allows skipping the `-s` arguments. This is also used when
<<_rewrite,using cross-project builds>>.
[#source-editing-warning]
WARNING: Zilch will not regenerate the build files when editing source in this
manner, for performance and logistical reasons. To change the build files,
override the `src` attribute of the environment's derivation.
@ -78,7 +83,7 @@ Scheme code:
[,scheme]
----
(environment: "import ./sample.drv"
(environment: "import ./sample.nix"
patch:
(lambda (edge)
(if (string=? (build-edge-rule edge) "foo")
@ -91,6 +96,31 @@ environment variable `$_ZILCH_ROOT` points to the root of the source + build
file tree, and can be used to copy non-symlinked files into the working
directory.
[#_rewrite]
== Cross-project incremental builds
Zilch supports rewriting the input of a Ninja project with another Ninja
project. To do this, you will need the name of the derivation, and a project
configuration:
[,scheme]
----
(environment: "import ./sample.nix"
override-source: "sample-src"
rewrite:
("input-1.2.3"
environment: "import ../input.nix"
override-source: "input-src"
#<...more configuration here>))
----
WARNING: The <<source-editing-warning,warning under "Source editing">> applies
here too. As addition, the boundary between projects is determined by running
the `installPhase` of the project to rewrite. If the installPhase is complex
(e.g. by using compression, rather than just copying inputs to outputs) this
will not work properly. Any code that assumes it can run outputs from the
rewritten project will also not function, as any shared libraries are stubbed
out.
== Automatic file elision
To implement incremental builds efficiently, Zilch automatically slims down the
part of the source directory that is accessible to each target. If a filename