docs: what a source imports is read as its compile reads it
The README said that crafter-build reads the imports of a
configuration's sources from their text without compiling them, so that
one in a string literal, in a comment that spans lines or under #if 0
counted, and that a configuration whose interface units import each
other is refused before anything of it is built. It now says that
clang-scan-deps reads what a .cppm or .cpp declares and imports, with
the command the source is compiled with, as the compiler reads it, once
the configuration's dependencies are built; where the build keeps what
it read, as it keeps objects; that such a configuration is refused once
its sources are read, before any of its .cppm and .cpp is compiled; and
that the scans are among the steps a build runs at most as many of at
once as the machine has hardware threads.
The README's sentence on a project that two paths load with different
lists now names the projects the build stops for, those that export
modules, since DuplicateModuleError refuses a module built twice and
nothing else, and says that such a project is built once where both
lists give it one build directory, as two orders of the same flags of
its own can. The README and the contributor guide also stop naming
nlohmann/json among the vendored headers in lib/, which it left in
4af9280.
This commit is contained in:
parent
15e9831203
commit
efb8fcc8b2
2 changed files with 5 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ crafter-build is a C++26 modules build system. A project is described by a `proj
|
||||||
| `examples/` | Standalone user-facing projects, MIT licensed. |
|
| `examples/` | Standalone user-facing projects, MIT licensed. |
|
||||||
| `build.sh` | Bootstrap script. It compiles everything by hand, without crafter-build. |
|
| `build.sh` | Bootstrap script. It compiles everything by hand, without crafter-build. |
|
||||||
| `wasi-runtime/` | `runtime.js` and `index.html.in`, shipped for browser targets. |
|
| `wasi-runtime/` | `runtime.js` and `index.html.in`, shipped for browser targets. |
|
||||||
| `lib/` | Vendored third-party headers (nlohmann/json, glslang's DirStackFileIncluder). Do not edit. |
|
| `lib/` | Vendored third-party headers (glslang's DirStackFileIncluder). Do not edit. |
|
||||||
| `share/crafter-build/`, `bin/`, `build/`, `lib/*.a` | Generated and gitignored. |
|
| `share/crafter-build/`, `bin/`, `build/`, `lib/*.a` | Generated and gitignored. |
|
||||||
| `packaging/flatpak/`, `.forgejo/workflows/ci.yaml` | The Flatpak manifest with its metainfo, repo and ref files, and the Forgejo Actions CI that builds and publishes it. |
|
| `packaging/flatpak/`, `.forgejo/workflows/ci.yaml` | The Flatpak manifest with its metainfo, repo and ref files, and the Forgejo Actions CI that builds and publishes it. |
|
||||||
| `.review-gates/` | The pre-push review's `config.json` and this repository's lens sections (`lenses/`), read by Crafter.Review. Its `push/` and `trees/` are generated and gitignored. |
|
| `.review-gates/` | The pre-push review's `config.json` and this repository's lens sections (`lenses/`), read by Crafter.Review. Its `push/` and `trees/` are generated and gitignored. |
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ Run `crafter-build` in that directory, outputs land at `bin/myapp-<target>-<marc
|
||||||
|
|
||||||
A `.cpp`, `.c` or `.cu` of a configuration is compiled into an object named from its path: `a/Thing.cpp` into `objects/a/Thing_impl.o` in that `build/` directory, at the source's path from `cfg.path`, and a source outside `cfg.path` into `objects-outside/` there, at its whole path. Two sources may therefore have the same file name in different directories, and a `.c` may lie beside a `.cpp` or a `.cu` of its name. The progress line of such a source's compile names it by the same path, `Compiling a/Thing.cpp`. The link, and the archive step of a static library, read their objects from a file in that directory, `<outputName>.objects`, so the command is no longer for many sources than for one.
|
A `.cpp`, `.c` or `.cu` of a configuration is compiled into an object named from its path: `a/Thing.cpp` into `objects/a/Thing_impl.o` in that `build/` directory, at the source's path from `cfg.path`, and a source outside `cfg.path` into `objects-outside/` there, at its whole path. Two sources may therefore have the same file name in different directories, and a `.c` may lie beside a `.cpp` or a `.cu` of its name. The progress line of such a source's compile names it by the same path, `Compiling a/Thing.cpp`. The link, and the archive step of a static library, read their objects from a file in that directory, `<outputName>.objects`, so the command is no longer for many sources than for one.
|
||||||
|
|
||||||
crafter-build orders a configuration's units by the `import` lines of its sources: a unit is built after the modules and partitions it imports, and a module's primary interface after all of its partitions. Interface units of one configuration that import each other cannot be built in any order: two partitions, a partition and its own module, or two modules. Such a configuration is refused before anything of it is built, with an error that names the units in the order they wait. The imports are read from the source text without compiling it, so one in a string literal, in a comment that spans lines or under `#if 0` counts too, and such text can make a round in a project the compiler accepts.
|
crafter-build orders a configuration's units by what their sources import: a unit is built after the modules and partitions it imports, and a module's primary interface after all of its partitions. What a `.cppm` or `.cpp` declares and imports is read by clang-scan-deps, which preprocesses the source with the command it is compiled with, so it reads them as the compiler does: an import in a comment, in a string literal or in a branch that `#if` leaves out is none, and a define or a header decides one as it does for the compile. It reads them once the configuration's dependencies are built, since the command takes their include paths, and keeps what it found in the `build/` directory, as it keeps objects: in `scans/` at the source's path from `cfg.path`, and in `scans-outside/` at its whole path for a source outside `cfg.path`, until the source, a file it includes or the command changes. Interface units of one configuration that import each other cannot be built in any order: two partitions, a partition and its own module, or two modules. Such a configuration is refused once its sources are read, before any of its `.cppm` and `.cpp` is compiled, with an error that names the units in the order they wait.
|
||||||
|
|
||||||
A build runs at most as many of its steps at once as the machine has hardware threads, however many sources are stale: the compiles of its sources, its shaders and assets, and its links and archives, counted together for the project and the dependencies it is built on. An `ExternalDependency`'s CMake build is not among them and is given that many jobs of its own, and the tests `crafter-build test` runs are counted by `--jobs=`. A step counts as one whatever threads it starts for itself: a link runs on lld's, and an asset is compressed on threads its compressor starts.
|
A build runs at most as many of its steps at once as the machine has hardware threads, however many sources are stale: the scans and the compiles of its sources, its shaders and assets, and its links and archives, counted together for the project and the dependencies it is built on. An `ExternalDependency`'s CMake build is not among them and is given that many jobs of its own, and the tests `crafter-build test` runs are counted by `--jobs=`. A step counts as one whatever threads it starts for itself: a link runs on lld's, and an asset is compressed on threads its compressor starts.
|
||||||
|
|
||||||
### Several configurations
|
### Several configurations
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ Configuration* sibling = LocalProject({ .projectFile = "../Crafter.Math/project.
|
||||||
cfg.dependencies = { math };
|
cfg.dependencies = { math };
|
||||||
```
|
```
|
||||||
|
|
||||||
The sibling's entry point gets the args this `project.cpp` was loaded with (`ProjectArgs()`), so `--target=`, `--march=`, `--debug` and the project's own flags reach every sibling down the chain. That is all of them: `cfg.projectArgs` holds only what `ApplyStandardArgs` did not interpret, and passing it on would drop the target and the build type. Set `.args` to send something else: `{}` for nothing, or a list built from the project's args, such as one without a flag only this project reads. Build such a list once and give it to every sibling. A project that two paths load with different lists would end up in the program twice, so the build stops with an error that names both paths. Releases up to 2.2.0 forward nothing when `.args` is left out.
|
The sibling's entry point gets the args this `project.cpp` was loaded with (`ProjectArgs()`), so `--target=`, `--march=`, `--debug` and the project's own flags reach every sibling down the chain. That is all of them: `cfg.projectArgs` holds only what `ApplyStandardArgs` did not interpret, and passing it on would drop the target and the build type. Set `.args` to send something else: `{}` for nothing, or a list built from the project's args, such as one without a flag only this project reads. Build such a list once and give it to every sibling. A project that exports modules and that two paths load with different lists would end up in the program twice, so the build stops with an error that names both paths, unless both lists give the project one build directory, as two orders of the same flags of its own can: it is then built once. Releases up to 2.2.0 forward nothing when `.args` is left out.
|
||||||
|
|
||||||
The default is read when the spec is made, so make it inside the entry point, `CrafterBuildProject` or `CrafterBuildConfigurations`, on the thread that calls it. A spec made at namespace scope, on a thread of your own or in a script forwards nothing.
|
The default is read when the spec is made, so make it inside the entry point, `CrafterBuildProject` or `CrafterBuildConfigurations`, on the thread that calls it. A spec made at namespace scope, on a thread of your own or in a script forwards nothing.
|
||||||
|
|
||||||
|
|
@ -542,7 +542,7 @@ This project is licensed under the GNU Lesser General Public License, version 3
|
||||||
|
|
||||||
The example code under [examples/](examples/) is licensed under the MIT license (see [examples/LICENSE](examples/LICENSE)), so it can be freely copied into your own projects.
|
The example code under [examples/](examples/) is licensed under the MIT license (see [examples/LICENSE](examples/LICENSE)), so it can be freely copied into your own projects.
|
||||||
|
|
||||||
The [lib/](lib/) directory contains vendored third-party code (nlohmann/json, glslang's DirStackFileIncluder) that remains under its own permissive licenses, see the headers of those files.
|
The [lib/](lib/) directory contains vendored third-party code (glslang's DirStackFileIncluder) that remains under its own permissive license, see the header of that file.
|
||||||
|
|
||||||
## Copyright
|
## Copyright
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue