forked from xuzhongxing/fuchsia-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.txt
139 lines (115 loc) · 3.67 KB
/
build.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
如何增加自己的包?
fx set x64 --products topaz/products/default --packages your/thing
在toolchain定义里面的{{}}不是对变量进行取值,而是一个placeholder.
在之后生成编译命令时展开。
gn args out/x64/ --list --short
这个命令显示所有的变量的预设值。
gn desc out/x64 //garnet/bin/appmgr:bin
描述一个target的全部信息。
fx set arm64 out/mydir
fx调用gn工具处理.gn文件,生成.ninja文件。ninja根据.ninja文件进行构建。
https://chromium.googlesource.com/chromium/src/tools/gn/
https://ninja-build.org/
/home/xzx/fuchsia/buildtools/gn gen /home/xzx/fuchsia/out/x64
--check '--args=target_cpu="x64" fuchsia_packages=["topaz/packages/default",]'
gn gen是生成ninja文件。
--args=设置一些变量供gn使用。
target_cpu="x64"
fuchsia_packages=["topaz/packages/default",]
gn的缺省变量:
- host_cpu
- host_os
- current_cpu
- current_os
- target_cpu
- target_os
target_os = "fuchsia"
target_cpu="x64"
current_cpu = target_cpu
current_os = target_os
select_variant = []
select_variant_canonical = []
select_variant_shortcuts = [{
select_variant = [{
variant = "asan_no_detect_leaks"
host = true
dir = ["//third_party/yasm", "//third_party/vboot_reference", "//garnet/tools/vboot_reference"]
}, {
variant = "asan"
host = true
}]
name = "host_asan"
}]
gn启动之后第一件事是寻找当前目录以及父目录里的.gn文件,确定源码树的根。从.gn文件开始执行。
.gn可能会定义secondary_source目录。gn也会去这里找文件。
寻找buildconfig文件,执行。
执行//BUILD.gn, fuchsia设置了root = "//build/gn", 所以会去这里找BUILD.gn
root
Label of the root build target. The GN build will start by loading the
build file containing this target name. This defaults to "//:" which will
cause the file //BUILD.gn to be loaded.
当一个target完整之后,输出ninja文件。
最后输出build.ninja
gn 预定义的变量:
target_out_dir
{{source_out_dir}}
The object file directory (*) corresponding to the source file's path,
relative to the build directory. this us be different than the target's
out directory if the source file is in a different directory than the
build.gn file.
"//foo/bar/baz.txt" => "obj/foo/bar"
label包括target, config, toolchain
All targets encountered in the default toolchain (see "gn help toolchain")
will have build rules generated for them, even if no other targets reference
them.
buildconfig [required]
Path to the build config file. This file will be used to set up the
build file execution environment for each toolchain.
gn 定义变量:
var = value
host_toolchain = "//build/toolchain:host_x64"
target_toolchain = "//build/toolchain/fuchsia:x64"
toolchain_variant = {
base = "//build/toolchain/fuchsia:x64"
}
toolchain_variant.name = ""
toolchain_variant.suffix = ""
toolchain_variant.configs = []
toolchain_variant.remove_common_configs = []
toolchain_variant.remove_shared_configs = []
toolchain_variant.deps = []
toolchain_variant.is_pic_default = false
is_linux = true
default_library_type = "static_library"
toolchain_variant = {
base = "//build/toolchain/fuchsia:x64"
}
universal_variants = [{
toolchain_args = {
is_debug = false
}
configs = []
name = "release"
}]
clang_toolchain_suite("x64")
is_host = false
只有下列variant:
{
base = "//build/toolchain/fuchsia:x64"
configs = []
remove_shared_configs = []
remove_common_configs = []
suffix = ""
deps = []
name = ""
}
variant_used
{
base = "//build/toolchain:host_x64"
configs = []
remove_shared_configs = []
remove_common_configs = []
suffix = ""
deps = []
name = ""
}