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',
82 # As of VS 2013 Update 3, building this project with /analyze hits an
83 # internal compiler error on elf-x86-amd64.c in release builds with
84 # the amd64_x86 compiler. This halts the build and prevents subsequent
85 # analysis. Therefore, /analyze is disabled for this project. See this
87 # https://connect.microsoft.com/VisualStudio/feedback/details/1014799/internal-compiler-error-when-using-analyze
90 'AdditionalOptions!': [ '/analyze' ]
96 'source/patched-yasm/frontends/yasm/yasm-options.c',
97 'source/patched-yasm/frontends/yasm/yasm.c',
98 'source/patched-yasm/libyasm/assocdat.c',
99 'source/patched-yasm/libyasm/bc-align.c',
100 'source/patched-yasm/libyasm/bc-data.c',
101 'source/patched-yasm/libyasm/bc-incbin.c',
102 'source/patched-yasm/libyasm/bc-org.c',
103 'source/patched-yasm/libyasm/bc-reserve.c',
104 'source/patched-yasm/libyasm/bitvect.c',
105 'source/patched-yasm/libyasm/bytecode.c',
106 'source/patched-yasm/libyasm/errwarn.c',
107 'source/patched-yasm/libyasm/expr.c',
108 'source/patched-yasm/libyasm/file.c',
109 'source/patched-yasm/libyasm/floatnum.c',
110 'source/patched-yasm/libyasm/hamt.c',
111 'source/patched-yasm/libyasm/insn.c',
112 'source/patched-yasm/libyasm/intnum.c',
113 'source/patched-yasm/libyasm/inttree.c',
114 'source/patched-yasm/libyasm/linemap.c',
115 'source/patched-yasm/libyasm/md5.c',
116 'source/patched-yasm/libyasm/mergesort.c',
117 'source/patched-yasm/libyasm/section.c',
118 'source/patched-yasm/libyasm/strcasecmp.c',
119 'source/patched-yasm/libyasm/strsep.c',
120 'source/patched-yasm/libyasm/symrec.c',
121 'source/patched-yasm/libyasm/valparam.c',
122 'source/patched-yasm/libyasm/value.c',
123 'source/patched-yasm/modules/arch/lc3b/lc3barch.c',
124 'source/patched-yasm/modules/arch/lc3b/lc3bbc.c',
125 'source/patched-yasm/modules/arch/x86/x86arch.c',
126 'source/patched-yasm/modules/arch/x86/x86bc.c',
127 'source/patched-yasm/modules/arch/x86/x86expr.c',
128 'source/patched-yasm/modules/arch/x86/x86id.c',
129 'source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c',
130 'source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c',
131 'source/patched-yasm/modules/dbgfmts/codeview/cv-type.c',
132 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c',
133 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c',
134 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c',
135 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c',
136 'source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c',
137 'source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c',
138 'source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c',
139 'source/patched-yasm/modules/objfmts/bin/bin-objfmt.c',
140 'source/patched-yasm/modules/objfmts/coff/coff-objfmt.c',
141 'source/patched-yasm/modules/objfmts/coff/win64-except.c',
142 'source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c',
143 'source/patched-yasm/modules/objfmts/elf/elf-objfmt.c',
144 'source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c',
145 'source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c',
146 'source/patched-yasm/modules/objfmts/elf/elf.c',
147 'source/patched-yasm/modules/objfmts/macho/macho-objfmt.c',
148 'source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c',
149 'source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c',
150 'source/patched-yasm/modules/parsers/gas/gas-parse.c',
151 'source/patched-yasm/modules/parsers/gas/gas-parse-intel.c',
152 'source/patched-yasm/modules/parsers/gas/gas-parser.c',
153 'source/patched-yasm/modules/parsers/nasm/nasm-parse.c',
154 'source/patched-yasm/modules/parsers/nasm/nasm-parser.c',
155 'source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c',
156 'source/patched-yasm/modules/preprocs/nasm/nasm-eval.c',
157 'source/patched-yasm/modules/preprocs/nasm/nasm-pp.c',
158 'source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c',
159 'source/patched-yasm/modules/preprocs/nasm/nasmlib.c',
160 'source/patched-yasm/modules/preprocs/raw/raw-preproc.c',
162 # Sources needed by re2c.
163 'source/patched-yasm/modules/parsers/gas/gas-token.re',
164 'source/patched-yasm/modules/parsers/nasm/nasm-token.re',
166 # Sources needed by genperf. Make sure the generated gperf files
167 # (the ones in shared_generated_dir) are synced with the outputs
168 # for the related generate_*_insn actions in the generate_files
170 '<(shared_generated_dir)/x86insn_nasm.gperf',
171 '<(shared_generated_dir)/x86insn_gas.gperf',
172 '<(shared_generated_dir)/x86cpu.c',
173 '<(shared_generated_dir)/x86regtmod.c',
176 '<@(yasm_include_dirs)',
177 '<(shared_generated_dir)',
180 'defines': [ '<@(yasm_defines)' ],
181 'cflags': [ '<@(yasm_cflags)', ],
182 'msvs_disabled_warnings': [ 4267 ],
185 'rule_name': 'generate_gperf',
186 'extension': 'gperf',
187 'inputs': [ '<(PRODUCT_DIR)/'
188 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
190 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
192 'action': ['<(PRODUCT_DIR)/genperf',
193 '<(RULE_INPUT_PATH)',
194 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
196 # These files are #included, so do not treat them as sources.
197 'process_outputs_as_sources': 0,
198 'message': 'yasm gperf for <(RULE_INPUT_PATH)',
201 'rule_name': 'generate_re2c',
203 'inputs': [ '<(PRODUCT_DIR)/'
204 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
205 'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
207 '<(PRODUCT_DIR)/re2c',
210 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
211 '<(RULE_INPUT_PATH)',
213 'process_outputs_as_sources': 1,
214 'message': 'yasm re2c for <(RULE_INPUT_PATH)',
222 'action_name': 'generate_nasm_macros',
224 'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
225 'varname': 'nasm_standard_mac',
226 'outfile': '<(generated_dir)/nasm-macros.c',
228 'inputs': [ '<(PRODUCT_DIR)/'
229 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
231 'outputs': [ '<(outfile)', ],
232 'action': ['<(PRODUCT_DIR)/genmacro',
233 '<(outfile)', '<(varname)', '<(infile)', ],
234 # Not a direct source because this is #included by
235 # source/patched-yasm/modules/parsers/nasm/nasm-parser.c
236 'process_outputs_as_sources': 1,
237 'message': 'yasm genmacro for <(infile)',
240 'action_name': 'generate_nasm_version',
242 'infile': '<(shared_generated_dir)/<(version_file)',
243 'varname': 'nasm_version_mac',
244 'outfile': '<(generated_dir)/nasm-version.c',
246 'inputs': [ '<(PRODUCT_DIR)/'
247 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
249 'outputs': [ '<(outfile)', ],
250 'action': ['<(PRODUCT_DIR)/genmacro',
251 '<(outfile)', '<(varname)', '<(infile)',
253 # Not a direct source because this is #included by
254 # source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c
255 'process_outputs_as_sources': 0,
256 'message': 'yasm genmacro for <(infile)',
259 'action_name': 'generate_win64_gas',
261 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
262 'varname': 'win64_gas_stdmac',
263 'outfile': '<(generated_dir)/win64-gas.c',
265 'inputs': [ '<(PRODUCT_DIR)/'
266 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
268 'outputs': [ '<(outfile)', ],
269 'action': ['<(PRODUCT_DIR)/genmacro',
270 '<(outfile)', '<(varname)', '<(infile)',
272 # Not a direct source because this is #included by
273 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
274 'process_outputs_as_sources': 0,
275 'message': 'yasm genmacro for <(infile)',
278 'action_name': 'generate_win64_nasm',
280 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
281 'varname': 'win64_nasm_stdmac',
282 'outfile': '<(generated_dir)/win64-nasm.c',
284 'inputs': [ '<(PRODUCT_DIR)/'
285 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
287 'outputs': [ '<(outfile)', ],
288 'action': ['<(PRODUCT_DIR)/genmacro',
293 # Not a direct source because this is #included by
294 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
295 'process_outputs_as_sources': 0,
296 'message': 'yasm genmacro for <(infile)',
303 'action_name': 'generate_license',
305 'infile': 'source/patched-yasm/COPYING',
306 'varname': 'license_msg',
307 'outfile': '<(generated_dir)/license.c',
309 'inputs': [ '<(PRODUCT_DIR)/'
310 '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
312 'outputs': [ '<(outfile)', ],
313 'action': ['<(PRODUCT_DIR)/genstring',
318 # Not a direct source because this is #included by
319 # source/patched-yasm/frontends/yasm/yasm.c
320 'process_outputs_as_sources': 0,
321 'message': 'Generating yasm embeddable license',
325 ### A re2c call that doesn't fit into the rule below.
328 'action_name': 'generate_lc3b_token',
330 'infile': 'source/patched-yasm/modules/arch/lc3b/lc3bid.re',
331 # The license file is #included by yasm.c.
332 'outfile': '<(generated_dir)/lc3bid.c',
334 'inputs': [ '<(PRODUCT_DIR)/'
335 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
337 'outputs': [ '<(outfile)', ],
339 '<(PRODUCT_DIR)/re2c',
344 'process_outputs_as_sources': 1,
345 'message': 'Generating yasm tokens for lc3b',
352 'action_name': 'generate_module',
354 'makefile': 'source/config/<(OS)/Makefile',
355 'module_in': 'source/patched-yasm/libyasm/module.in',
356 'outfile': '<(generated_dir)/module.c',
359 '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
363 'outputs': [ '<(generated_dir)/module.c' ],
365 '<(PRODUCT_DIR)/genmodule',
370 'process_outputs_as_sources': 1,
371 'message': 'Generating yasm module information',
376 'target_name': 'config_sources',
378 'toolsets': ['host'],
380 'source/config/<(OS)/Makefile',
381 'source/config/<(OS)/config.h',
382 'source/config/<(OS)/libyasm-stdint.h',
386 'target_name': 'generate_files',
388 'toolsets': ['host'],
394 'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
395 'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
399 'rule_name': 'generate_gperf',
400 'extension': 'gperf',
401 'inputs': [ '<(PRODUCT_DIR)/'
402 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
403 'outputs': [ '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c', ],
405 '<(PRODUCT_DIR)/genperf',
406 '<(RULE_INPUT_PATH)',
407 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
409 'process_outputs_as_sources': 0,
410 'message': 'yasm genperf for <(RULE_INPUT_PATH)',
415 'action_name': 'generate_x86_insn',
418 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
420 'inputs': [ '<(gen_insn_path)', ],
422 '<(shared_generated_dir)/x86insns.c',
423 '<(shared_generated_dir)/x86insn_gas.gperf',
424 '<(shared_generated_dir)/x86insn_nasm.gperf',
429 '<(shared_generated_dir)',
431 'message': 'Running <(gen_insn_path)',
432 'process_outputs_as_sources': 0,
435 'action_name': 'generate_version',
436 'inputs': [ '<(PRODUCT_DIR)/'
437 '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
438 'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
440 '<(PRODUCT_DIR)/genversion',
441 '<(shared_generated_dir)/<(version_file)'
443 'message': 'Generating yasm version file: '
444 '<(shared_generated_dir)/<(version_file)',
445 'process_outputs_as_sources': 0,
450 'target_name': 'genperf_libs',
451 'type': 'static_library',
452 'toolsets': ['host'],
453 'dependencies': [ 'config_sources', ],
455 'source/patched-yasm/libyasm/phash.c',
456 'source/patched-yasm/libyasm/xmalloc.c',
457 'source/patched-yasm/libyasm/xstrdup.c',
460 '<@(yasm_include_dirs)',
462 'defines': [ '<@(yasm_defines)' ],
468 'target_name': 'genstring',
469 'type': 'executable',
470 'toolsets': ['host'],
471 'dependencies': [ 'config_sources', ],
473 'source/patched-yasm/genstring.c',
476 '<@(yasm_include_dirs)',
483 'target_name': 'genperf',
484 'type': 'executable',
485 'toolsets': ['host'],
490 'source/patched-yasm/tools/genperf/genperf.c',
491 'source/patched-yasm/tools/genperf/perfect.c',
494 '<@(yasm_include_dirs)',
501 'target_name': 'genmacro',
502 'type': 'executable',
503 'toolsets': ['host'],
504 'dependencies': [ 'config_sources', ],
506 'source/patched-yasm/tools/genmacro/genmacro.c',
509 '<@(yasm_include_dirs)',
516 'target_name': 'genversion',
517 'type': 'executable',
518 'toolsets': ['host'],
519 'dependencies': [ 'config_sources', ],
521 'source/patched-yasm/modules/preprocs/nasm/genversion.c',
524 '<@(yasm_include_dirs)',
531 'target_name': 're2c',
532 'type': 'executable',
533 'toolsets': ['host'],
534 'dependencies': [ 'config_sources', ],
536 'source/patched-yasm/tools/re2c/main.c',
537 'source/patched-yasm/tools/re2c/code.c',
538 'source/patched-yasm/tools/re2c/dfa.c',
539 'source/patched-yasm/tools/re2c/parser.c',
540 'source/patched-yasm/tools/re2c/actions.c',
541 'source/patched-yasm/tools/re2c/scanner.c',
542 'source/patched-yasm/tools/re2c/mbo_getopt.c',
543 'source/patched-yasm/tools/re2c/substr.c',
544 'source/patched-yasm/tools/re2c/translate.c',
547 '<@(yasm_include_dirs)',
553 # re2c is missing CLOSEVOP from one switch.
554 'clang_warning_flags': [ '-Wno-switch' ],
556 'msvs_disabled_warnings': [ 4267 ],
559 'target_name': 'genmodule',
560 'type': 'executable',
561 'toolsets': ['host'],
566 'source/patched-yasm/libyasm/genmodule.c',
569 '<@(yasm_include_dirs)',