You can find more info about the options used to build Fuchsia in Rust CI in the
[build_fuchsia_from_rust_ci.sh] script invoked by [build-fuchsia.sh].
The Fuchsia build system uses [GN], a metabuild system that generates [Ninja]
files and then hands off the work of running the build to Ninja.
Fuchsia developers use `fx` to run builds and perform other development tasks.
This tool is located in `.jiri_root/bin` of the Fuchsia checkout; you may need
to add this to your `$PATH` for some workflows.
There are a few `fx` subcommands that are relevant, including:
- `fx set` accepts build arguments, writes them to `out/default/args.gn`, and
runs GN.
- `fx build` builds the Fuchsia project using Ninja. It will automatically pick
up changes to build arguments and rerun GN. By default it builds everything,
but it also accepts target paths to build specific targets (see below).
- `fx clippy` runs Clippy on specific Rust targets (or all of them). We use this
in the Rust CI build to avoid running codegen on most Rust targets. Underneath
it invokes Ninja, just like `fx build`. The clippy results are saved in json
files inside the build output directory before being printed.
#### Target paths
GN uses paths like the following to identify build targets:
```
//src/starnix/kernel:starnix_core
```
The initial `//` means the root of the checkout, and the remaining slashes are
directory names. The string after `:` is the _target name_ of a target defined
in the `BUILD.gn` file of that directory.
The target name can be omitted if it is the same as the directory name. In other
words, `//src/starnix/kernel` is the same as `//src/starnix/kernel:kernel`.
These target paths are used inside `BUILD.gn` files to reference dependencies,
and can also be used in `fx build`.
#### Modifying compiler flags
You can put custom compiler flags inside a GN `config` that is added to a
target. As a simple example:
```
config("everybody_loops") {
rustflags = [ "-Zeverybody-loops" ]
}
rustc_binary("example") {
crate_root = "src/bin.rs"
# ...existing keys here...