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 'clang_warning_flags': [
76 # yasm passes a `const elf_machine_sym*` through `void*`.
77 '-Wno-incompatible-pointer-types',
81 'source/patched-yasm/frontends/yasm/yasm-options.c',
82 'source/patched-yasm/frontends/yasm/yasm.c',
83 'source/patched-yasm/libyasm/assocdat.c',
84 'source/patched-yasm/libyasm/bc-align.c',
85 'source/patched-yasm/libyasm/bc-data.c',
86 'source/patched-yasm/libyasm/bc-incbin.c',
87 'source/patched-yasm/libyasm/bc-org.c',
88 'source/patched-yasm/libyasm/bc-reserve.c',
89 'source/patched-yasm/libyasm/bitvect.c',
90 'source/patched-yasm/libyasm/bytecode.c',
91 'source/patched-yasm/libyasm/errwarn.c',
92 'source/patched-yasm/libyasm/expr.c',
93 'source/patched-yasm/libyasm/file.c',
94 'source/patched-yasm/libyasm/floatnum.c',
95 'source/patched-yasm/libyasm/hamt.c',
96 'source/patched-yasm/libyasm/insn.c',
97 'source/patched-yasm/libyasm/intnum.c',
98 'source/patched-yasm/libyasm/inttree.c',
99 'source/patched-yasm/libyasm/linemap.c',
100 'source/patched-yasm/libyasm/md5.c',
101 'source/patched-yasm/libyasm/mergesort.c',
102 'source/patched-yasm/libyasm/section.c',
103 'source/patched-yasm/libyasm/strcasecmp.c',
104 'source/patched-yasm/libyasm/strsep.c',
105 'source/patched-yasm/libyasm/symrec.c',
106 'source/patched-yasm/libyasm/valparam.c',
107 'source/patched-yasm/libyasm/value.c',
108 'source/patched-yasm/modules/arch/lc3b/lc3barch.c',
109 'source/patched-yasm/modules/arch/lc3b/lc3bbc.c',
110 'source/patched-yasm/modules/arch/x86/x86arch.c',
111 'source/patched-yasm/modules/arch/x86/x86bc.c',
112 'source/patched-yasm/modules/arch/x86/x86expr.c',
113 'source/patched-yasm/modules/arch/x86/x86id.c',
114 'source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c',
115 'source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c',
116 'source/patched-yasm/modules/dbgfmts/codeview/cv-type.c',
117 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c',
118 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c',
119 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c',
120 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c',
121 'source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c',
122 'source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c',
123 'source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c',
124 'source/patched-yasm/modules/objfmts/bin/bin-objfmt.c',
125 'source/patched-yasm/modules/objfmts/coff/coff-objfmt.c',
126 'source/patched-yasm/modules/objfmts/coff/win64-except.c',
127 'source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c',
128 'source/patched-yasm/modules/objfmts/elf/elf-objfmt.c',
129 'source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c',
130 'source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c',
131 'source/patched-yasm/modules/objfmts/elf/elf.c',
132 'source/patched-yasm/modules/objfmts/macho/macho-objfmt.c',
133 'source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c',
134 'source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c',
135 'source/patched-yasm/modules/parsers/gas/gas-parse.c',
136 'source/patched-yasm/modules/parsers/gas/gas-parse-intel.c',
137 'source/patched-yasm/modules/parsers/gas/gas-parser.c',
138 'source/patched-yasm/modules/parsers/nasm/nasm-parse.c',
139 'source/patched-yasm/modules/parsers/nasm/nasm-parser.c',
140 'source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c',
141 'source/patched-yasm/modules/preprocs/nasm/nasm-eval.c',
142 'source/patched-yasm/modules/preprocs/nasm/nasm-pp.c',
143 'source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c',
144 'source/patched-yasm/modules/preprocs/nasm/nasmlib.c',
145 'source/patched-yasm/modules/preprocs/raw/raw-preproc.c',
147 # Sources needed by re2c.
148 'source/patched-yasm/modules/parsers/gas/gas-token.re',
149 'source/patched-yasm/modules/parsers/nasm/nasm-token.re',
151 # Sources needed by genperf. Make sure the generated gperf files
152 # (the ones in shared_generated_dir) are synced with the outputs
153 # for the related generate_*_insn actions in the generate_files
155 '<(shared_generated_dir)/x86insn_nasm.gperf',
156 '<(shared_generated_dir)/x86insn_gas.gperf',
157 '<(shared_generated_dir)/x86cpu.c',
158 '<(shared_generated_dir)/x86regtmod.c',
161 '<@(yasm_include_dirs)',
162 '<(shared_generated_dir)',
165 'defines': [ '<@(yasm_defines)' ],
166 'cflags': [ '<@(yasm_cflags)', ],
167 'msvs_disabled_warnings': [ 4267 ],
170 'rule_name': 'generate_gperf',
171 'extension': 'gperf',
172 'inputs': [ '<(PRODUCT_DIR)/'
173 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
175 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
177 'action': ['<(PRODUCT_DIR)/genperf',
178 '<(RULE_INPUT_PATH)',
179 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
181 # These files are #included, so do not treat them as sources.
182 'process_outputs_as_sources': 0,
183 'message': 'yasm gperf for <(RULE_INPUT_PATH)',
186 'rule_name': 'generate_re2c',
188 'inputs': [ '<(PRODUCT_DIR)/'
189 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
190 'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
192 '<(PRODUCT_DIR)/re2c',
195 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
196 '<(RULE_INPUT_PATH)',
198 'process_outputs_as_sources': 1,
199 'message': 'yasm re2c for <(RULE_INPUT_PATH)',
207 'action_name': 'generate_nasm_macros',
209 'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
210 'varname': 'nasm_standard_mac',
211 'outfile': '<(generated_dir)/nasm-macros.c',
213 'inputs': [ '<(PRODUCT_DIR)/'
214 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
216 'outputs': [ '<(outfile)', ],
217 'action': ['<(PRODUCT_DIR)/genmacro',
218 '<(outfile)', '<(varname)', '<(infile)', ],
219 # Not a direct source because this is #included by
220 # source/patched-yasm/modules/parsers/nasm/nasm-parser.c
221 'process_outputs_as_sources': 1,
222 'message': 'yasm genmacro for <(infile)',
225 'action_name': 'generate_nasm_version',
227 'infile': '<(shared_generated_dir)/<(version_file)',
228 'varname': 'nasm_version_mac',
229 'outfile': '<(generated_dir)/nasm-version.c',
231 'inputs': [ '<(PRODUCT_DIR)/'
232 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
234 'outputs': [ '<(outfile)', ],
235 'action': ['<(PRODUCT_DIR)/genmacro',
236 '<(outfile)', '<(varname)', '<(infile)',
238 # Not a direct source because this is #included by
239 # source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c
240 'process_outputs_as_sources': 0,
241 'message': 'yasm genmacro for <(infile)',
244 'action_name': 'generate_win64_gas',
246 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
247 'varname': 'win64_gas_stdmac',
248 'outfile': '<(generated_dir)/win64-gas.c',
250 'inputs': [ '<(PRODUCT_DIR)/'
251 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
253 'outputs': [ '<(outfile)', ],
254 'action': ['<(PRODUCT_DIR)/genmacro',
255 '<(outfile)', '<(varname)', '<(infile)',
257 # Not a direct source because this is #included by
258 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
259 'process_outputs_as_sources': 0,
260 'message': 'yasm genmacro for <(infile)',
263 'action_name': 'generate_win64_nasm',
265 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
266 'varname': 'win64_nasm_stdmac',
267 'outfile': '<(generated_dir)/win64-nasm.c',
269 'inputs': [ '<(PRODUCT_DIR)/'
270 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
272 'outputs': [ '<(outfile)', ],
273 'action': ['<(PRODUCT_DIR)/genmacro',
278 # Not a direct source because this is #included by
279 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
280 'process_outputs_as_sources': 0,
281 'message': 'yasm genmacro for <(infile)',
288 'action_name': 'generate_license',
290 'infile': 'source/patched-yasm/COPYING',
291 'varname': 'license_msg',
292 'outfile': '<(generated_dir)/license.c',
294 'inputs': [ '<(PRODUCT_DIR)/'
295 '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
297 'outputs': [ '<(outfile)', ],
298 'action': ['<(PRODUCT_DIR)/genstring',
303 # Not a direct source because this is #included by
304 # source/patched-yasm/frontends/yasm/yasm.c
305 'process_outputs_as_sources': 0,
306 'message': 'Generating yasm embeddable license',
310 ### A re2c call that doesn't fit into the rule below.
313 'action_name': 'generate_lc3b_token',
315 'infile': 'source/patched-yasm/modules/arch/lc3b/lc3bid.re',
316 # The license file is #included by yasm.c.
317 'outfile': '<(generated_dir)/lc3bid.c',
319 'inputs': [ '<(PRODUCT_DIR)/'
320 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
322 'outputs': [ '<(outfile)', ],
324 '<(PRODUCT_DIR)/re2c',
329 'process_outputs_as_sources': 1,
330 'message': 'Generating yasm tokens for lc3b',
337 'action_name': 'generate_module',
339 'makefile': 'source/config/<(OS)/Makefile',
340 'module_in': 'source/patched-yasm/libyasm/module.in',
341 'outfile': '<(generated_dir)/module.c',
344 '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
348 'outputs': [ '<(generated_dir)/module.c' ],
350 '<(PRODUCT_DIR)/genmodule',
355 'process_outputs_as_sources': 1,
356 'message': 'Generating yasm module information',
361 'target_name': 'config_sources',
363 'toolsets': ['host'],
365 'source/config/<(OS)/Makefile',
366 'source/config/<(OS)/config.h',
367 'source/config/<(OS)/libyasm-stdint.h',
371 'target_name': 'generate_files',
373 'toolsets': ['host'],
379 'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
380 'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
384 'rule_name': 'generate_gperf',
385 'extension': 'gperf',
386 'inputs': [ '<(PRODUCT_DIR)/'
387 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
388 'outputs': [ '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c', ],
390 '<(PRODUCT_DIR)/genperf',
391 '<(RULE_INPUT_PATH)',
392 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
394 'process_outputs_as_sources': 0,
395 'message': 'yasm genperf for <(RULE_INPUT_PATH)',
400 'action_name': 'generate_x86_insn',
403 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
405 'inputs': [ '<(gen_insn_path)', ],
407 '<(shared_generated_dir)/x86insns.c',
408 '<(shared_generated_dir)/x86insn_gas.gperf',
409 '<(shared_generated_dir)/x86insn_nasm.gperf',
414 '<(shared_generated_dir)',
416 'message': 'Running <(gen_insn_path)',
417 'process_outputs_as_sources': 0,
420 'action_name': 'generate_version',
421 'inputs': [ '<(PRODUCT_DIR)/'
422 '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
423 'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
425 '<(PRODUCT_DIR)/genversion',
426 '<(shared_generated_dir)/<(version_file)'
428 'message': 'Generating yasm version file: '
429 '<(shared_generated_dir)/<(version_file)',
430 'process_outputs_as_sources': 0,
435 'target_name': 'genperf_libs',
436 'type': 'static_library',
437 'toolsets': ['host'],
438 'dependencies': [ 'config_sources', ],
440 'source/patched-yasm/libyasm/phash.c',
441 'source/patched-yasm/libyasm/xmalloc.c',
442 'source/patched-yasm/libyasm/xstrdup.c',
445 '<@(yasm_include_dirs)',
447 'defines': [ '<@(yasm_defines)' ],
453 'target_name': 'genstring',
454 'type': 'executable',
455 'toolsets': ['host'],
456 'dependencies': [ 'config_sources', ],
458 'source/patched-yasm/genstring.c',
461 '<@(yasm_include_dirs)',
468 'target_name': 'genperf',
469 'type': 'executable',
470 'toolsets': ['host'],
475 'source/patched-yasm/tools/genperf/genperf.c',
476 'source/patched-yasm/tools/genperf/perfect.c',
479 '<@(yasm_include_dirs)',
486 'target_name': 'genmacro',
487 'type': 'executable',
488 'toolsets': ['host'],
489 'dependencies': [ 'config_sources', ],
491 'source/patched-yasm/tools/genmacro/genmacro.c',
494 '<@(yasm_include_dirs)',
501 'target_name': 'genversion',
502 'type': 'executable',
503 'toolsets': ['host'],
504 'dependencies': [ 'config_sources', ],
506 'source/patched-yasm/modules/preprocs/nasm/genversion.c',
509 '<@(yasm_include_dirs)',
516 'target_name': 're2c',
517 'type': 'executable',
518 'toolsets': ['host'],
519 'dependencies': [ 'config_sources', ],
521 'source/patched-yasm/tools/re2c/main.c',
522 'source/patched-yasm/tools/re2c/code.c',
523 'source/patched-yasm/tools/re2c/dfa.c',
524 'source/patched-yasm/tools/re2c/parser.c',
525 'source/patched-yasm/tools/re2c/actions.c',
526 'source/patched-yasm/tools/re2c/scanner.c',
527 'source/patched-yasm/tools/re2c/mbo_getopt.c',
528 'source/patched-yasm/tools/re2c/substr.c',
529 'source/patched-yasm/tools/re2c/translate.c',
532 '<@(yasm_include_dirs)',
538 # re2c is missing CLOSEVOP from one switch.
539 'clang_warning_flags': [ '-Wno-switch' ],
541 'msvs_disabled_warnings': [ 4267 ],
544 'target_name': 'genmodule',
545 'type': 'executable',
546 'toolsets': ['host'],
551 'source/patched-yasm/libyasm/genmodule.c',
554 '<@(yasm_include_dirs)',