Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Fuchsia OS
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hacrwang
Fuchsia OS
Commits
77c3837c
Commit
77c3837c
authored
7 years ago
by
Roland McGrath
Browse files
Options
Downloads
Patches
Plain Diff
[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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
development/build/overview.md
+4
-4
4 additions, 4 deletions
development/build/overview.md
development/build/variants.md
+16
-47
16 additions, 47 deletions
development/build/variants.md
with
20 additions
and
51 deletions
development/build/overview.md
+
4
−
4
View file @
77c3837c
...
...
@@ -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
$ build
tools
/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
`
--
variant
s
`
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
...
...
This diff is collapsed.
Click to expand it.
development/build/variants.md
+
16
−
47
View file @
77c3837c
...
...
@@ -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
./build
tools
/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 binar
ies
named
`cat`
and
`ledger`
.
Fuchsia device). The
`
/cat
`
suffix constrains this matching rule only
to the binar
y
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
`g
en.py
`
once you have the
*
You can do this via the
`--args`
switch to
`g
n 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
./build
tools/gn args out/x64
--list
=
select_variant
```
You can also use the
`fx set`
tool to run
`g
en.py
`
for you:
You can also use the
`fx set`
tool to run
`g
n 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`
).
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment