OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
brettw
2014/05/09 20:17:54
This file is very complicated. I'm curious how lon
awong
2014/05/10 08:55:34
http://pastebin.com/AtMzHWqj
3 seconds to parse,
brettw
2014/05/11 20:30:34
Those are milliseconds so I think we're OK. Thanks
| |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 # The yasm build process creates a slew of small C subprograms that | |
6 # dynamically generate files at various point in the build process. This makes | |
7 # the build integration moderately complex. | |
8 # | |
9 # There are three classes of dynamically generated files: | |
10 # 1) C source files that should be included in the build (eg., lc3bid.c) | |
11 # 2) C source files that are #included by static C sources (eg., license.c) | |
12 # 3) Intermediate files that are used as input by other subprograms to | |
13 # further generate files in category #1 or #2. (eg., version.mac) | |
14 # | |
15 # This structure is represented with the following targets: | |
16 # 1) yasm -- Sources, flags for the main yasm executable. Also has most of | |
17 # of the actions and rules that invoke the subprograms. | |
18 # 2) yasm_config -- General build configuration including setting a | |
19 # source_prereqs listing the checked in version of files | |
20 # generated by manually running configure. These manually | |
21 # generated files are used by all binaries. | |
22 # 3) yasm_libs -- Object files with memory management and hashing utilities | |
23 # shared between yasm and the genperf subprogram. | |
24 # 4) genmacro, genmodule, etc. -- One executable target for each subprogram. | |
25 # 5) generate_license, generate_module, etc. -- Actions that invoke programs | |
26 # built in #4 to generate .c files. | |
27 # 6) compile_gperf, compile_re2c, etc. -- Actions that invoke programs that | |
28 # turn intermediate files into .c files. | |
29 | |
30 if (default_toolchain == host_toolchain) { | |
31 | |
32 # Various files referenced by multiple targets. | |
33 yasm_gen_include_dir = "$target_gen_dir/include" | |
34 config_makefile = "source/config/$os/Makefile" | |
35 version_file = "version.mac" | |
36 | |
37 import("//build/gn_helper_scripts.gni") | |
38 | |
39 config("yasm_config") { | |
40 include_dirs = [ | |
41 "source/config/$os", | |
42 "source/patched-yasm", | |
43 ] | |
44 source_prereqs = [ | |
45 config_makefile, | |
46 "source/config/$os/config.h", | |
47 "source/config/$os/libyasm-stdint.h", | |
48 ] | |
49 defines = [ "HAVE_CONFIG_H" ] | |
50 cflags = [ "-std=gnu99" ] | |
51 } | |
52 | |
53 executable("genmacro") { | |
54 sources = [ "source/patched-yasm/tools/genmacro/genmacro.c" ] | |
55 configs -= [ "//build/config/compiler:chromium_code" ] | |
56 configs += [ ":yasm_config", | |
57 "//build/config/compiler:no_chromium_code" ] | |
58 } | |
59 | |
60 executable("genmodule") { | |
61 sources = [ "source/patched-yasm/libyasm/genmodule.c" ] | |
62 configs -= [ "//build/config/compiler:chromium_code" ] | |
63 configs += [ ":yasm_config", | |
64 "//build/config/compiler:no_chromium_code" ] | |
65 } | |
66 | |
67 executable("genperf") { | |
68 sources = [ | |
69 "source/patched-yasm/tools/genperf/genperf.c", | |
70 "source/patched-yasm/tools/genperf/perfect.c", | |
71 ] | |
72 | |
73 configs -= [ "//build/config/compiler:chromium_code" ] | |
74 configs += [ ":yasm_config", | |
75 "//build/config/compiler:no_chromium_code" ] | |
76 | |
77 deps = [ ":yasm_libs" ] | |
78 } | |
79 | |
80 # Used by both yasm and genperf binaries. | |
81 source_set("yasm_libs") { | |
82 sources = [ | |
83 "source/patched-yasm/libyasm/phash.c", | |
84 "source/patched-yasm/libyasm/xmalloc.c", | |
85 "source/patched-yasm/libyasm/xstrdup.c", | |
86 ] | |
87 | |
88 configs -= [ "//build/config/compiler:chromium_code" ] | |
89 configs += [ ":yasm_config", | |
90 "//build/config/compiler:no_chromium_code" ] | |
91 } | |
92 | |
93 executable("genstring") { | |
94 sources = [ "source/patched-yasm/genstring.c", ] | |
95 configs -= [ "//build/config/compiler:chromium_code" ] | |
96 configs += [ ":yasm_config", | |
97 "//build/config/compiler:no_chromium_code" ] | |
98 } | |
99 | |
100 executable("genversion") { | |
101 sources = [ "source/patched-yasm/modules/preprocs/nasm/genversion.c" ] | |
102 configs -= [ "//build/config/compiler:chromium_code" ] | |
103 configs += [ ":yasm_config", | |
104 "//build/config/compiler:no_chromium_code" ] | |
105 } | |
106 | |
107 executable("re2c") { | |
108 sources = [ | |
109 "source/patched-yasm/tools/re2c/main.c", | |
110 "source/patched-yasm/tools/re2c/code.c", | |
111 "source/patched-yasm/tools/re2c/dfa.c", | |
112 "source/patched-yasm/tools/re2c/parser.c", | |
113 "source/patched-yasm/tools/re2c/actions.c", | |
114 "source/patched-yasm/tools/re2c/scanner.c", | |
115 "source/patched-yasm/tools/re2c/mbo_getopt.c", | |
116 "source/patched-yasm/tools/re2c/substr.c", | |
117 "source/patched-yasm/tools/re2c/translate.c", | |
118 ] | |
119 | |
120 configs -= [ "//build/config/compiler:chromium_code" ] | |
121 configs += [ ":yasm_config", | |
122 "//build/config/compiler:no_chromium_code" ] | |
123 | |
124 # re2c is missing CLOSEVOP from one switch. | |
125 cflags = [ "-Wno-switch" ] | |
126 } | |
127 | |
128 executable("yasm") { | |
129 sources = [ | |
130 "source/patched-yasm/frontends/yasm/yasm-options.c", | |
131 "source/patched-yasm/frontends/yasm/yasm.c", | |
132 "source/patched-yasm/libyasm/assocdat.c", | |
133 "source/patched-yasm/libyasm/bc-align.c", | |
134 "source/patched-yasm/libyasm/bc-data.c", | |
135 "source/patched-yasm/libyasm/bc-incbin.c", | |
136 "source/patched-yasm/libyasm/bc-org.c", | |
137 "source/patched-yasm/libyasm/bc-reserve.c", | |
138 "source/patched-yasm/libyasm/bitvect.c", | |
139 "source/patched-yasm/libyasm/bytecode.c", | |
140 "source/patched-yasm/libyasm/errwarn.c", | |
141 "source/patched-yasm/libyasm/expr.c", | |
142 "source/patched-yasm/libyasm/file.c", | |
143 "source/patched-yasm/libyasm/floatnum.c", | |
144 "source/patched-yasm/libyasm/hamt.c", | |
145 "source/patched-yasm/libyasm/insn.c", | |
146 "source/patched-yasm/libyasm/intnum.c", | |
147 "source/patched-yasm/libyasm/inttree.c", | |
148 "source/patched-yasm/libyasm/linemap.c", | |
149 "source/patched-yasm/libyasm/md5.c", | |
150 "source/patched-yasm/libyasm/mergesort.c", | |
151 "source/patched-yasm/libyasm/section.c", | |
152 "source/patched-yasm/libyasm/strcasecmp.c", | |
153 "source/patched-yasm/libyasm/strsep.c", | |
154 "source/patched-yasm/libyasm/symrec.c", | |
155 "source/patched-yasm/libyasm/valparam.c", | |
156 "source/patched-yasm/libyasm/value.c", | |
157 "source/patched-yasm/modules/arch/lc3b/lc3barch.c", | |
158 "source/patched-yasm/modules/arch/lc3b/lc3bbc.c", | |
159 "source/patched-yasm/modules/arch/x86/x86arch.c", | |
160 "source/patched-yasm/modules/arch/x86/x86bc.c", | |
161 "source/patched-yasm/modules/arch/x86/x86expr.c", | |
162 "source/patched-yasm/modules/arch/x86/x86id.c", | |
163 "source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c", | |
164 "source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c", | |
165 "source/patched-yasm/modules/dbgfmts/codeview/cv-type.c", | |
166 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c", | |
167 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c", | |
168 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c", | |
169 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c", | |
170 "source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c", | |
171 "source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c", | |
172 "source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c", | |
173 "source/patched-yasm/modules/objfmts/bin/bin-objfmt.c", | |
174 "source/patched-yasm/modules/objfmts/coff/coff-objfmt.c", | |
175 "source/patched-yasm/modules/objfmts/coff/win64-except.c", | |
176 "source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c", | |
177 "source/patched-yasm/modules/objfmts/elf/elf-objfmt.c", | |
178 "source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c", | |
179 "source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c", | |
180 "source/patched-yasm/modules/objfmts/elf/elf.c", | |
181 "source/patched-yasm/modules/objfmts/macho/macho-objfmt.c", | |
182 "source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c", | |
183 "source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c", | |
184 "source/patched-yasm/modules/parsers/gas/gas-parse.c", | |
185 "source/patched-yasm/modules/parsers/gas/gas-parse-intel.c", | |
186 "source/patched-yasm/modules/parsers/gas/gas-parser.c", | |
187 "source/patched-yasm/modules/parsers/nasm/nasm-parse.c", | |
188 "source/patched-yasm/modules/parsers/nasm/nasm-parser.c", | |
189 "source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c", | |
190 "source/patched-yasm/modules/preprocs/nasm/nasm-eval.c", | |
191 "source/patched-yasm/modules/preprocs/nasm/nasm-pp.c", | |
192 "source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c", | |
193 "source/patched-yasm/modules/preprocs/nasm/nasmlib.c", | |
194 "source/patched-yasm/modules/preprocs/raw/raw-preproc.c", | |
195 | |
196 # Files generated by compile_gperf | |
197 "$target_gen_dir/x86cpu.c", | |
198 "$target_gen_dir/x86regtmod.c", | |
199 | |
200 # Files generated by compile_re2c | |
201 "$target_gen_dir/gas-token.c", | |
202 "$target_gen_dir/nasm-token.c", | |
203 | |
204 # File generated by compile_re2c_lc3b | |
205 "$target_gen_dir/lc3bid.c", | |
206 | |
207 # File generated by generate_module | |
208 "$target_gen_dir/module.c" | |
209 ] | |
210 | |
211 configs -= [ "//build/config/compiler:chromium_code" ] | |
212 configs += [ ":yasm_config", | |
213 "//build/config/compiler:no_chromium_code" ] | |
214 | |
215 # Yasm generates a bunch of .c files which its source file #include. | |
216 # Add the |target_gen_dir| into the include path so it can find them. | |
217 # Ideally, these generated .c files would be placed into a separate | |
218 # directory, but the gen_x86_insn.py script does not make this easy. | |
219 include_dirs = [ yasm_gen_include_dir ] | |
220 | |
221 cflags = [ "-ansi", "-pedantic" ] | |
222 if (is_clang) { | |
223 cflags += [ "-Wno-incompatible-pointer-types" ] | |
224 } | |
225 | |
226 # TODO(ajwong): This should take most of the generated output as | |
227 # source_prereqs. | |
228 deps = [ | |
229 ":compile_gperf", | |
230 ":compile_gperf_for_include", | |
231 ":compile_nasm_macros", | |
232 ":compile_nasm_version", | |
233 ":compile_win64_gas", | |
234 ":compile_win64_nasm", | |
235 ":compile_re2c", | |
236 ":generate_license", | |
237 ":generate_module", | |
238 ":generate_version", | |
239 ":yasm_libs", | |
240 ] | |
241 } | |
242 | |
243 run_executable_foreach("compile_gperf") { | |
244 sources = [ | |
245 "source/patched-yasm/modules/arch/x86/x86cpu.gperf", | |
246 "source/patched-yasm/modules/arch/x86/x86regtmod.gperf", | |
247 ] | |
248 | |
249 outputs = [ "$target_gen_dir/{{source_name_part}}.c" ] | |
250 binary_name = "genperf" | |
251 args = [ | |
252 "{{source}}", | |
253 rebase_path(target_gen_dir, ".") + "/{{source_name_part}}.c", | |
254 ] | |
255 deps = [ | |
256 ":genperf", | |
257 ":generate_x86_insn" | |
258 ] | |
259 } | |
260 | |
261 # This differs from |compile_gperf| in where it places it output files. | |
262 run_executable_foreach("compile_gperf_for_include") { | |
263 sources = [ | |
264 # Make sure the generated gperf files in $target_gen_dir are synced with | |
265 # the outputs for the related generate_*_insn actions in the | |
266 # generate_files target below. | |
267 # | |
268 # The output for these two are #included by | |
269 # source/patched-yasm/modules/arch/x86/x86id.c | |
270 "$yasm_gen_include_dir/x86insn_gas.gperf", | |
271 "$yasm_gen_include_dir/x86insn_nasm.gperf", | |
272 ] | |
273 | |
274 outputs = [ "$yasm_gen_include_dir/{{source_name_part}}.c" ] | |
275 binary_name = "genperf" | |
276 args = [ | |
277 "{{source}}", | |
278 rebase_path(yasm_gen_include_dir, ".") + "/{{source_name_part}}.c", | |
279 ] | |
280 deps = [ | |
281 ":genperf", | |
282 ":generate_x86_insn" | |
283 ] | |
284 } | |
285 | |
286 template("compile_macro") { | |
287 run_executable(target_name) { | |
288 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
289 sources = invoker.sources | |
290 outputs = invoker.outputs | |
291 binary_name = "genmacro" | |
292 args = [ | |
293 rebase_path(outputs[0], root_build_dir), | |
294 invoker.macro_varname, | |
295 rebase_path(sources[0], root_build_dir), | |
296 ] | |
297 deps = [ ":genmacro" ] | |
298 if (defined(invoker.deps)) { | |
299 deps += invoker.deps | |
300 } | |
301 } | |
302 } | |
303 | |
304 compile_macro("compile_nasm_macros") { | |
305 # Output #included by | |
306 # source/patched-yasm/modules/preprocs/nasm/nasm-parser.c | |
307 sources = [ "source/patched-yasm/modules/parsers/nasm/nasm-std.mac" ] | |
308 outputs = [ "$yasm_gen_include_dir/nasm-macros.c" ] | |
309 macro_varname = "nasm_standard_mac" | |
310 } | |
311 | |
312 compile_macro("compile_nasm_version") { | |
313 # Output #included by | |
314 # source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c | |
315 sources = [ "$target_gen_dir/$version_file" ] | |
316 outputs = [ "$yasm_gen_include_dir/nasm-version.c" ] | |
317 macro_varname = "nasm_version_mac" | |
318 deps = [ ":generate_version" ] | |
319 } | |
320 | |
321 compile_macro("compile_win64_gas") { | |
322 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
323 sources = [ "source/patched-yasm/modules/objfmts/coff/win64-gas.mac" ] | |
324 outputs = [ "$yasm_gen_include_dir/win64-gas.c" ] | |
325 macro_varname = "win64_gas_stdmac" | |
326 } | |
327 | |
328 compile_macro("compile_win64_nasm") { | |
329 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
330 sources = [ "source/patched-yasm/modules/objfmts/coff/win64-nasm.mac" ] | |
331 outputs = [ "$yasm_gen_include_dir/win64-nasm.c" ] | |
332 macro_varname = "win64_nasm_stdmac" | |
333 } | |
334 | |
335 run_executable_foreach("compile_re2c") { | |
336 sources = [ | |
337 "source/patched-yasm/modules/parsers/gas/gas-token.re", | |
338 "source/patched-yasm/modules/parsers/nasm/nasm-token.re", | |
339 ] | |
340 outputs = [ "$target_gen_dir/{{source_name_part}}.c" ] | |
341 binary_name = "re2c" | |
342 args = [ | |
343 "-b", | |
344 "-o", | |
345 rebase_path(target_gen_dir, ".") + "/{{source_name_part}}.c", | |
346 "{{source}}", | |
347 ] | |
348 deps = [ ":re2c" ] | |
349 } | |
350 | |
351 # This call doesn't fit into the re2c template above. | |
352 run_executable("compile_re2c_lc3b") { | |
353 sources = [ "source/patched-yasm/modules/arch/lc3b/lc3bid.re" ] | |
354 outputs = [ "$target_gen_dir/lc3bid.c" ] | |
355 binary_name = "re2c" | |
356 args = [ | |
357 "-s", | |
358 "-o", | |
359 rebase_path(outputs[0], root_build_dir), | |
360 rebase_path(sources[0], root_build_dir), | |
361 ] | |
362 deps = [ ":re2c" ] | |
363 } | |
364 | |
365 run_executable("generate_license") { | |
366 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
367 sources = [ "source/patched-yasm/COPYING" ] | |
368 outputs = [ "$yasm_gen_include_dir/license.c" ] | |
369 binary_name = "genstring" | |
370 args = [ | |
371 "license_msg", | |
372 rebase_path(outputs[0], root_build_dir), | |
373 rebase_path(sources[0], root_build_dir), | |
374 ] | |
375 | |
376 deps = [ ":genstring" ] | |
377 } | |
378 | |
379 run_executable("generate_module") { | |
380 sources = [ "source/patched-yasm/libyasm/module.in" ] | |
381 outputs = [ "$target_gen_dir/module.c" ] | |
382 binary_name = "genmodule" | |
383 args = [ | |
384 rebase_path(sources[0], root_build_dir), | |
385 rebase_path(config_makefile, root_build_dir), | |
386 rebase_path(outputs[0], root_build_dir), | |
387 ] | |
388 deps = [ ":genmodule" ] | |
389 } | |
390 | |
391 run_executable("generate_version") { | |
392 outputs = [ "$target_gen_dir/$version_file" ] | |
393 binary_name = "genversion" | |
394 args = [ | |
395 rebase_path(outputs[0], | |
396 root_build_dir) | |
397 ] | |
398 deps = [ ":genversion" ] | |
399 } | |
400 | |
401 action("generate_x86_insn") { | |
402 script = "source/patched-yasm/modules/arch/x86/gen_x86_insn.py" | |
403 # Output eventually #included by source/patched-yasm/frontends/yasm/x86id.c | |
404 outputs = [ | |
405 "$yasm_gen_include_dir/x86insns.c", | |
406 "$yasm_gen_include_dir/x86insn_gas.gperf", | |
407 "$yasm_gen_include_dir/x86insn_nasm.gperf", | |
408 ] | |
409 args = [ rebase_path(yasm_gen_include_dir, root_build_dir) ] | |
410 } | |
411 | |
412 } | |
OLD | NEW |