Skip to content
Snippets Groups Projects
Commit 77c3837c authored by Roland McGrath's avatar Roland McGrath
Browse files

[build] Replace mentions of `gen.py` with direct `gn gen`

Change-Id: I2204a3d7ca413019213d6cd8c3afe7218b709ebc
parent c8308fdc
No related branches found
No related tags found
No related merge requests found
......@@ -68,14 +68,14 @@ packages to incorporate:
# fuchsia_base is typically "default".
# my_stuff is a possibly-empty list of extra packages to include.
$ build/gn/gen.py --packages build/gn/fuchsia_base,build/gn/my_stuff
$ buildtools/gn gen out/x64 --args='fuchsia_packages="build/gn/fuchsia_base,build/gn/my_stuff"'
```
This will create an `out/debug-<arch>` directory containing Ninja files.
This will create an `out/x64` directory containing Ninja files.
This is what gets run under the hood by `fx set`.
For a list of all `gen.py` options, run `gen.py --help`.
For documentation on the `--variants` flag, see [Variants](variants.md).
For a list of all GN build arguments, run `buildtools/gn args out/x64 --list`.
For documentation on the `select_variant` argument, see [Variants](variants.md).
### C
......
......@@ -13,21 +13,18 @@ in which variants. It applies automatically to every `executable`,
mechanism in which you give a list of matching rules to apply to each
target to decide which variant to use (if any). To support this
flexibility, the value for `select_variant` uses a detailed GN syntax.
For simple cases, this can just be a list of strings.
Some shorthands for common cases are provided by the `gen.py` script that
is the usual way to run `gn gen` in the Fuchsia build, via `--variant`
switches. Each `--variant` switch adds one matching rule.
Here's an example running `gen.py` directly:
Here's an example running `gn gen` directly:
```sh
./build/gn/gen.py --variant=host_asan --variant=asan=cat,ledger
./buildtools/gn gen out/x64 --args='select_variant=["host_asan", "asan/cat", "asan/ledger"]'
```
This does the same thing using the `fx set` tool:
```sh
fx set x64 --variant host_asan --variant asan=cat,ledger
fx set x64 --variant={host_asan,asan/cat,asan/ledger}
```
1. The first switch applies the `host_asan` matching rule, which enables
......@@ -36,71 +33,43 @@ fx set x64 --variant host_asan --variant asan=cat,ledger
2. The second switch applies the `asan` matching rule, which enables
AddressSanitizer for executables built to run on the target (i.e. the
Fuchsia device). The `=...` suffix constrains this matching rule only
to the binaries named `cat` and `ledger`.
Fuchsia device). The `/cat` suffix constrains this matching rule only
to the binary named `cat`.
The switch `--variant=help` will make `gen.py` show the list of recognized
shorthands, and which ones can work with the `=...` suffix.
3. The third switch is like the second, but matches the binary named `ledger`.
The GN code supports much more flexible matching rules than just the binary
name, but there are no shorthands for those. To do something more complex,
set the `select_variant` GN build argument directly.
* You can do this via the `--args` switch to `gen.py` once you have the
* You can do this via the `--args` switch to `gn gen` once you have the
syntax down.
* The easiest way to experiment is to start with some `--variant` switches that
approximate what you want and then edit the `select_variant` value `gen.py`
approximate what you want and then edit the `select_variant` value `fx set`
produces:
* You can just edit the `args.gn` file in the GN output directory
(e.g. `out/debug-x64/args.gn`) and the next `ninja` run (aka `fx build`)
(e.g. `out/x64/args.gn`) and the next `ninja` run (aka `fx build`)
will re-run `gn gen` with those changes.
* You can use the command `./buildtools gn args out/debug-x64`, which
* You can use the command `./buildtools gn args out/x64`, which
will run your `$EDITOR` on the `args.gn` file and then do `gn gen`
immediately so you can see any errors in your GN syntax.
Like all GN build arguments, `select_variant` is documented in comments in
the `.gn` source file that defines the argument, and these can be displayed
using `./buildtools/gn args --list`. The `--help-args` switch to `gen.py`
using `./buildtools/gn args --list`. The `--help-args` switch to `fx set`
also runs GN this way:
```sh
./build/gn/gen.py -p topaz/packages/default --help-args=select_variant
./buildtools/gn args out/x64 --list=select_variant
```
You can also use the `fx set` tool to run `gen.py` for you:
You can also use the `fx set` tool to run `gn args` for you:
```sh
fx set x64 --help-args select_variant
```
If you combine this with one or more `--variant` switches, GN will show you
the actual value of `select_variant` that `gen.py` chose. For example:
```sh
./build/gn/gen.py -p topaz/packages/default --help-args=select_variant --variant=asan=cat,ledger
```
or:
```sh
fx set x64 --help-args select_variant --variant asan=cat,ledger
```
prints out:
```
select_variant
Current value = [{
output_name = ["cat", "ledger"]
variant = "asan"
host = false
}]
From :1
Overridden from the default = []
...
fx set x64 --help-args=select_variant
```
To see the list of variants available and learn more about how to define
knew ones, use `--help-args known_variants` with `gen.py` or `fx set`
knew ones, use `--help-args=known_variants` or `fx set`
(or `gn args out/... --list=known_variants`).
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment