-
-
Notifications
You must be signed in to change notification settings - Fork 163
Oil Ninja Build
andychu edited this page Sep 6, 2022
·
16 revisions
Back to Contributing / Oil Dev Cheat Sheet
-
./NINJA-config.sh
invokesbuild/dynamic_deps.py
, and then callsNINJA_main.py
-
NINJA_main.py
imports the files{build,cpp,mycpp}/NINJA_subgraph.py
- Each of those files writes a subset of the NINJA rules (a "subgraph").
- This is a little but like a BUILD file in Google's build system Bazel, but not quite. We should probably move more toward that structure.
There are essentially only two statements in Ninja: rule
and build
.
-
build
defines a graph edge from multiple inputs to (potentially) multiple outputs -
rule
tells what action to perform- which often delegates to
build/NINJA-steps.sh
- or sometimes
_bin/shwrap/${foo}_main
, which allows us to get incremental builds right with textual code generation- for example, if you change
frontend/consts.py
, then that should invalidatefrontend/consts_gen.py
, which will invalidate_gen/frontend/consts.{cc,h}
. - Note: this is the thing where it's unclear how other build systems like CMake handle it.
- It's analogous to
gcc -MD
with the Makefile fragments and.d
files.
- for example, if you change
- which often delegates to
The incremental build is correct in almost all cases. EXCEPTIONS:
- If you change the lexer (e.g.
frontend/lexer_def.py
),ninja _bin/cxx-dbg/osh_eval
won't reflect it. Because that is shared with the Python buildbuild/py.sh all
. - If you change
*/NINJA-steps.sh
, it won't be reflected. (TODO: add these as implicit deps?) - If you set
CXXFLAGS='-D ALLOCLOG' ninja
, then objects in_build/obj/cxx-dbg
will be compiled differently. And then future incremental builds may not be correct.
2022-09-06
- there is a
GC_RUNTIME
var inmycpp/NINJA_subgraph.py
- there is a list of C++ unit tests in
mycpp/NINJA_subgraph.py