1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
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.
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)
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) config_sources -- Checked in version of files generated by manually
19 # running configure that are used by all binaries.
20 # 3) generate_files -- Actions and rules for files of type #3.
21 # 4) genperf_libs -- Object files shared between yasm and the genperf
23 # 5) genmacro, genmodule, etc. -- One executable target for each subprogram.
25 # You will notice that a lot of the action targets seem very similar --
26 # especially for genmacro invocations. This makes it seem like they should
27 # be a rule. The problem is that the correct invocation cannot be inferred
28 # purely from the file name, or extension. Nor is it obvious whether the
29 # output should be processed as a source or not. Thus, we are left with a
30 # large amount of repetitive code.
34 'yasm_include_dirs': [
35 'source/config/<(OS)',
36 'source/patched-yasm',
39 # The cflags used by any target that will be directly linked into yasm.
40 # These are specifically not used when building the subprograms. While
41 # it would probably be safe to use these flags there as well, the
42 # ./configure based build does not use the same flags between the main
43 # yasm executable, and its subprograms.
44 'yasm_defines': ['HAVE_CONFIG_H'],
51 # Locations for various generated artifacts.
52 'shared_generated_dir': '<(SHARED_INTERMEDIATE_DIR)/third_party/yasm',
53 'generated_dir': '<(INTERMEDIATE_DIR)/third_party/yasm',
55 # Various files referenced by multiple targets.
56 'version_file': 'version.mac', # Generated by genversion.
57 'genmodule_source': 'genmodule_outfile.c',
61 'target_name': 'yasm',
70 'generate_files', # Needed to generate gperf and instruction files.
75 'source/patched-yasm/frontends/yasm/yasm-options.c',
76 'source/patched-yasm/frontends/yasm/yasm.c',
77 'source/patched-yasm/libyasm/assocdat.c',
78 'source/patched-yasm/libyasm/bc-align.c',
79 'source/patched-yasm/libyasm/bc-data.c',
80 'source/patched-yasm/libyasm/bc-incbin.c',
81 'source/patched-yasm/libyasm/bc-org.c',
82 'source/patched-yasm/libyasm/bc-reserve.c',
83 'source/patched-yasm/libyasm/bitvect.c',
84 'source/patched-yasm/libyasm/bytecode.c',
85 'source/patched-yasm/libyasm/errwarn.c',
86 'source/patched-yasm/libyasm/expr.c',
87 'source/patched-yasm/libyasm/file.c',
88 'source/patched-yasm/libyasm/floatnum.c',
89 'source/patched-yasm/libyasm/hamt.c',
90 'source/patched-yasm/libyasm/insn.c',
91 'source/patched-yasm/libyasm/intnum.c',
92 'source/patched-yasm/libyasm/inttree.c',
93 'source/patched-yasm/libyasm/linemap.c',
94 'source/patched-yasm/libyasm/md5.c',
95 'source/patched-yasm/libyasm/mergesort.c',
96 'source/patched-yasm/libyasm/section.c',
97 'source/patched-yasm/libyasm/strcasecmp.c',
98 'source/patched-yasm/libyasm/strsep.c',
99 'source/patched-yasm/libyasm/symrec.c',
100 'source/patched-yasm/libyasm/valparam.c',
101 'source/patched-yasm/libyasm/value.c',
102 'source/patched-yasm/modules/arch/lc3b/lc3barch.c',
103 'source/patched-yasm/modules/arch/lc3b/lc3bbc.c',
104 'source/patched-yasm/modules/arch/x86/x86arch.c',
105 'source/patched-yasm/modules/arch/x86/x86bc.c',
106 'source/patched-yasm/modules/arch/x86/x86expr.c',
107 'source/patched-yasm/modules/arch/x86/x86id.c',
108 'source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c',
109 'source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c',
110 'source/patched-yasm/modules/dbgfmts/codeview/cv-type.c',
111 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c',
112 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c',
113 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c',
114 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c',
115 'source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c',
116 'source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c',
117 'source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c',
118 'source/patched-yasm/modules/objfmts/bin/bin-objfmt.c',
119 'source/patched-yasm/modules/objfmts/coff/coff-objfmt.c',
120 'source/patched-yasm/modules/objfmts/coff/win64-except.c',
121 'source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c',
122 'source/patched-yasm/modules/objfmts/elf/elf-objfmt.c',
123 'source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c',
124 'source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c',
125 'source/patched-yasm/modules/objfmts/elf/elf.c',
126 'source/patched-yasm/modules/objfmts/macho/macho-objfmt.c',
127 'source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c',
128 'source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c',
129 'source/patched-yasm/modules/parsers/gas/gas-parse.c',
130 'source/patched-yasm/modules/parsers/gas/gas-parse-intel.c',
131 'source/patched-yasm/modules/parsers/gas/gas-parser.c',
132 'source/patched-yasm/modules/parsers/nasm/nasm-parse.c',
133 'source/patched-yasm/modules/parsers/nasm/nasm-parser.c',
134 'source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c',
135 'source/patched-yasm/modules/preprocs/nasm/nasm-eval.c',
136 'source/patched-yasm/modules/preprocs/nasm/nasm-pp.c',
137 'source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c',
138 'source/patched-yasm/modules/preprocs/nasm/nasmlib.c',
139 'source/patched-yasm/modules/preprocs/raw/raw-preproc.c',
141 # Sources needed by re2c.
142 'source/patched-yasm/modules/parsers/gas/gas-token.re',
143 'source/patched-yasm/modules/parsers/nasm/nasm-token.re',
145 # Sources needed by genperf. Make sure the generated gperf files
146 # (the ones in shared_generated_dir) are synced with the outputs
147 # for the related generate_*_insn actions in the generate_files
149 '<(shared_generated_dir)/x86insn_nasm.gperf',
150 '<(shared_generated_dir)/x86insn_gas.gperf',
151 '<(shared_generated_dir)/x86cpu.c',
152 '<(shared_generated_dir)/x86regtmod.c',
155 '<@(yasm_include_dirs)',
156 '<(shared_generated_dir)',
159 'defines': [ '<@(yasm_defines)' ],
160 'cflags': [ '<@(yasm_cflags)', ],
165 # yasm passes a `const elf_machine_sym*` through `void*`.
166 '-Wno-incompatible-pointer-types',
170 '-Wno-incompatible-pointer-types',
174 'msvs_disabled_warnings': [ 4267 ],
177 'rule_name': 'generate_gperf',
178 'extension': 'gperf',
179 'inputs': [ '<(PRODUCT_DIR)/'
180 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
182 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
184 'action': ['<(PRODUCT_DIR)/genperf',
185 '<(RULE_INPUT_PATH)',
186 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
188 # These files are #included, so do not treat them as sources.
189 'process_outputs_as_sources': 0,
190 'message': 'yasm gperf for <(RULE_INPUT_PATH)',
193 'rule_name': 'generate_re2c',
195 'inputs': [ '<(PRODUCT_DIR)/'
196 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
197 'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
199 '<(PRODUCT_DIR)/re2c',
202 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
203 '<(RULE_INPUT_PATH)',
205 'process_outputs_as_sources': 1,
206 'message': 'yasm re2c for <(RULE_INPUT_PATH)',
214 'action_name': 'generate_nasm_macros',
216 'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
217 'varname': 'nasm_standard_mac',
218 'outfile': '<(generated_dir)/nasm-macros.c',
220 'inputs': [ '<(PRODUCT_DIR)/'
221 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
223 'outputs': [ '<(outfile)', ],
224 'action': ['<(PRODUCT_DIR)/genmacro',
225 '<(outfile)', '<(varname)', '<(infile)', ],
226 # Not a direct source because this is #included by
227 # source/patched-yasm/modules/parsers/nasm/nasm-parser.c
228 'process_outputs_as_sources': 1,
229 'message': 'yasm genmacro for <(infile)',
232 'action_name': 'generate_nasm_version',
234 'infile': '<(shared_generated_dir)/<(version_file)',
235 'varname': 'nasm_version_mac',
236 'outfile': '<(generated_dir)/nasm-version.c',
238 'inputs': [ '<(PRODUCT_DIR)/'
239 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
241 'outputs': [ '<(outfile)', ],
242 'action': ['<(PRODUCT_DIR)/genmacro',
243 '<(outfile)', '<(varname)', '<(infile)',
245 # Not a direct source because this is #included by
246 # source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c
247 'process_outputs_as_sources': 0,
248 'message': 'yasm genmacro for <(infile)',
251 'action_name': 'generate_win64_gas',
253 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
254 'varname': 'win64_gas_stdmac',
255 'outfile': '<(generated_dir)/win64-gas.c',
257 'inputs': [ '<(PRODUCT_DIR)/'
258 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
260 'outputs': [ '<(outfile)', ],
261 'action': ['<(PRODUCT_DIR)/genmacro',
262 '<(outfile)', '<(varname)', '<(infile)',
264 # Not a direct source because this is #included by
265 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
266 'process_outputs_as_sources': 0,
267 'message': 'yasm genmacro for <(infile)',
270 'action_name': 'generate_win64_nasm',
272 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
273 'varname': 'win64_nasm_stdmac',
274 'outfile': '<(generated_dir)/win64-nasm.c',
276 'inputs': [ '<(PRODUCT_DIR)/'
277 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
279 'outputs': [ '<(outfile)', ],
280 'action': ['<(PRODUCT_DIR)/genmacro',
285 # Not a direct source because this is #included by
286 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
287 'process_outputs_as_sources': 0,
288 'message': 'yasm genmacro for <(infile)',
295 'action_name': 'generate_license',
297 'infile': 'source/patched-yasm/COPYING',
298 'varname': 'license_msg',
299 'outfile': '<(generated_dir)/license.c',
301 'inputs': [ '<(PRODUCT_DIR)/'
302 '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
304 'outputs': [ '<(outfile)', ],
305 'action': ['<(PRODUCT_DIR)/genstring',
310 # Not a direct source because this is #included by
311 # source/patched-yasm/frontends/yasm/yasm.c
312 'process_outputs_as_sources': 0,
313 'message': 'Generating yasm embeddable license',
317 ### A re2c call that doesn't fit into the rule below.
320 'action_name': 'generate_lc3b_token',
322 'infile': 'source/patched-yasm/modules/arch/lc3b/lc3bid.re',
323 # The license file is #included by yasm.c.
324 'outfile': '<(generated_dir)/lc3bid.c',
326 'inputs': [ '<(PRODUCT_DIR)/'
327 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
329 'outputs': [ '<(outfile)', ],
331 '<(PRODUCT_DIR)/re2c',
336 'process_outputs_as_sources': 1,
337 'message': 'Generating yasm tokens for lc3b',
344 'action_name': 'generate_module',
346 'makefile': 'source/config/<(OS)/Makefile',
347 'module_in': 'source/patched-yasm/libyasm/module.in',
348 'outfile': '<(generated_dir)/module.c',
351 '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
355 'outputs': [ '<(generated_dir)/module.c' ],
357 '<(PRODUCT_DIR)/genmodule',
362 'process_outputs_as_sources': 1,
363 'message': 'Generating yasm module information',
368 'target_name': 'config_sources',
370 'toolsets': ['host'],
372 'source/config/<(OS)/Makefile',
373 'source/config/<(OS)/config.h',
374 'source/config/<(OS)/libyasm-stdint.h',
378 'target_name': 'generate_files',
380 'toolsets': ['host'],
386 'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
387 'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
391 'rule_name': 'generate_gperf',
392 'extension': 'gperf',
393 'inputs': [ '<(PRODUCT_DIR)/'
394 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
395 'outputs': [ '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c', ],
397 '<(PRODUCT_DIR)/genperf',
398 '<(RULE_INPUT_PATH)',
399 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
401 'process_outputs_as_sources': 0,
402 'message': 'yasm genperf for <(RULE_INPUT_PATH)',
407 'action_name': 'generate_x86_insn',
410 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
412 'inputs': [ '<(gen_insn_path)', ],
414 '<(shared_generated_dir)/x86insns.c',
415 '<(shared_generated_dir)/x86insn_gas.gperf',
416 '<(shared_generated_dir)/x86insn_nasm.gperf',
421 '<(shared_generated_dir)',
423 'message': 'Running <(gen_insn_path)',
424 'process_outputs_as_sources': 0,
427 'action_name': 'generate_version',
428 'inputs': [ '<(PRODUCT_DIR)/'
429 '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
430 'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
432 '<(PRODUCT_DIR)/genversion',
433 '<(shared_generated_dir)/<(version_file)'
435 'message': 'Generating yasm version file: '
436 '<(shared_generated_dir)/<(version_file)',
437 'process_outputs_as_sources': 0,
442 'target_name': 'genperf_libs',
443 'type': 'static_library',
444 'toolsets': ['host'],
445 'dependencies': [ 'config_sources', ],
447 'source/patched-yasm/libyasm/phash.c',
448 'source/patched-yasm/libyasm/xmalloc.c',
449 'source/patched-yasm/libyasm/xstrdup.c',
452 '<@(yasm_include_dirs)',
454 'defines': [ '<@(yasm_defines)' ],
460 'target_name': 'genstring',
461 'type': 'executable',
462 'toolsets': ['host'],
463 'dependencies': [ 'config_sources', ],
465 'source/patched-yasm/genstring.c',
468 '<@(yasm_include_dirs)',
475 'target_name': 'genperf',
476 'type': 'executable',
477 'toolsets': ['host'],
482 'source/patched-yasm/tools/genperf/genperf.c',
483 'source/patched-yasm/tools/genperf/perfect.c',
486 '<@(yasm_include_dirs)',
493 'target_name': 'genmacro',
494 'type': 'executable',
495 'toolsets': ['host'],
496 'dependencies': [ 'config_sources', ],
498 'source/patched-yasm/tools/genmacro/genmacro.c',
501 '<@(yasm_include_dirs)',
508 'target_name': 'genversion',
509 'type': 'executable',
510 'toolsets': ['host'],
511 'dependencies': [ 'config_sources', ],
513 'source/patched-yasm/modules/preprocs/nasm/genversion.c',
516 '<@(yasm_include_dirs)',
523 'target_name': 're2c',
524 'type': 'executable',
525 'toolsets': ['host'],
526 'dependencies': [ 'config_sources', ],
528 'source/patched-yasm/tools/re2c/main.c',
529 'source/patched-yasm/tools/re2c/code.c',
530 'source/patched-yasm/tools/re2c/dfa.c',
531 'source/patched-yasm/tools/re2c/parser.c',
532 'source/patched-yasm/tools/re2c/actions.c',
533 'source/patched-yasm/tools/re2c/scanner.c',
534 'source/patched-yasm/tools/re2c/mbo_getopt.c',
535 'source/patched-yasm/tools/re2c/substr.c',
536 'source/patched-yasm/tools/re2c/translate.c',
539 '<@(yasm_include_dirs)',
548 # re2c is missing CLOSEVOP from one switch.
557 'msvs_disabled_warnings': [ 4267 ],
560 'target_name': 'genmodule',
561 'type': 'executable',
562 'toolsets': ['host'],
567 'source/patched-yasm/libyasm/genmodule.c',
570 '<@(yasm_include_dirs)',