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',
60 # Silence warnings in libc++ builds (C code doesn't need this flag).
61 'ldflags!': [ '-stdlib=libc++', ],
62 # https://crbug.com/489901
63 'cflags!': [ '-fsanitize=bounds' ],
67 'target_name': 'yasm',
76 'generate_files', # Needed to generate gperf and instruction files.
81 'clang_warning_flags': [
82 # yasm passes a `const elf_machine_sym*` through `void*`.
83 '-Wno-incompatible-pointer-types',
88 # As of VS 2013 Update 3, building this project with /analyze hits an
89 # internal compiler error on elf-x86-amd64.c in release builds with
90 # the amd64_x86 compiler. This halts the build and prevents subsequent
91 # analysis. Therefore, /analyze is disabled for this project. See this
93 # https://connect.microsoft.com/VisualStudio/feedback/details/1014799/internal-compiler-error-when-using-analyze
96 'AdditionalOptions!': [ '/analyze' ]
102 'source/patched-yasm/frontends/yasm/yasm-options.c',
103 'source/patched-yasm/frontends/yasm/yasm.c',
104 'source/patched-yasm/libyasm/assocdat.c',
105 'source/patched-yasm/libyasm/bc-align.c',
106 'source/patched-yasm/libyasm/bc-data.c',
107 'source/patched-yasm/libyasm/bc-incbin.c',
108 'source/patched-yasm/libyasm/bc-org.c',
109 'source/patched-yasm/libyasm/bc-reserve.c',
110 'source/patched-yasm/libyasm/bitvect.c',
111 'source/patched-yasm/libyasm/bytecode.c',
112 'source/patched-yasm/libyasm/errwarn.c',
113 'source/patched-yasm/libyasm/expr.c',
114 'source/patched-yasm/libyasm/file.c',
115 'source/patched-yasm/libyasm/floatnum.c',
116 'source/patched-yasm/libyasm/hamt.c',
117 'source/patched-yasm/libyasm/insn.c',
118 'source/patched-yasm/libyasm/intnum.c',
119 'source/patched-yasm/libyasm/inttree.c',
120 'source/patched-yasm/libyasm/linemap.c',
121 'source/patched-yasm/libyasm/md5.c',
122 'source/patched-yasm/libyasm/mergesort.c',
123 'source/patched-yasm/libyasm/section.c',
124 'source/patched-yasm/libyasm/strcasecmp.c',
125 'source/patched-yasm/libyasm/strsep.c',
126 'source/patched-yasm/libyasm/symrec.c',
127 'source/patched-yasm/libyasm/valparam.c',
128 'source/patched-yasm/libyasm/value.c',
129 'source/patched-yasm/modules/arch/lc3b/lc3barch.c',
130 'source/patched-yasm/modules/arch/lc3b/lc3bbc.c',
131 'source/patched-yasm/modules/arch/x86/x86arch.c',
132 'source/patched-yasm/modules/arch/x86/x86bc.c',
133 'source/patched-yasm/modules/arch/x86/x86expr.c',
134 'source/patched-yasm/modules/arch/x86/x86id.c',
135 'source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c',
136 'source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c',
137 'source/patched-yasm/modules/dbgfmts/codeview/cv-type.c',
138 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c',
139 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c',
140 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c',
141 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c',
142 'source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c',
143 'source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c',
144 'source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c',
145 'source/patched-yasm/modules/objfmts/bin/bin-objfmt.c',
146 'source/patched-yasm/modules/objfmts/coff/coff-objfmt.c',
147 'source/patched-yasm/modules/objfmts/coff/win64-except.c',
148 'source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c',
149 'source/patched-yasm/modules/objfmts/elf/elf-objfmt.c',
150 'source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c',
151 'source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c',
152 'source/patched-yasm/modules/objfmts/elf/elf.c',
153 'source/patched-yasm/modules/objfmts/macho/macho-objfmt.c',
154 'source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c',
155 'source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c',
156 'source/patched-yasm/modules/parsers/gas/gas-parse.c',
157 'source/patched-yasm/modules/parsers/gas/gas-parse-intel.c',
158 'source/patched-yasm/modules/parsers/gas/gas-parser.c',
159 'source/patched-yasm/modules/parsers/nasm/nasm-parse.c',
160 'source/patched-yasm/modules/parsers/nasm/nasm-parser.c',
161 'source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c',
162 'source/patched-yasm/modules/preprocs/nasm/nasm-eval.c',
163 'source/patched-yasm/modules/preprocs/nasm/nasm-pp.c',
164 'source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c',
165 'source/patched-yasm/modules/preprocs/nasm/nasmlib.c',
166 'source/patched-yasm/modules/preprocs/raw/raw-preproc.c',
168 # Sources needed by re2c.
169 'source/patched-yasm/modules/parsers/gas/gas-token.re',
170 'source/patched-yasm/modules/parsers/nasm/nasm-token.re',
172 # Sources needed by genperf. Make sure the generated gperf files
173 # (the ones in shared_generated_dir) are synced with the outputs
174 # for the related generate_*_insn actions in the generate_files
176 '<(shared_generated_dir)/x86insn_nasm.gperf',
177 '<(shared_generated_dir)/x86insn_gas.gperf',
178 '<(shared_generated_dir)/x86cpu.c',
179 '<(shared_generated_dir)/x86regtmod.c',
182 '<@(yasm_include_dirs)',
183 '<(shared_generated_dir)',
186 'defines': [ '<@(yasm_defines)' ],
187 'cflags': [ '<@(yasm_cflags)', ],
188 'msvs_disabled_warnings': [ 4267 ],
191 'rule_name': 'generate_gperf',
192 'extension': 'gperf',
193 'inputs': [ '<(PRODUCT_DIR)/'
194 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
196 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
198 'action': ['<(PRODUCT_DIR)/genperf',
199 '<(RULE_INPUT_PATH)',
200 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
202 # These files are #included, so do not treat them as sources.
203 'process_outputs_as_sources': 0,
204 'message': 'yasm gperf for <(RULE_INPUT_PATH)',
207 'rule_name': 'generate_re2c',
209 'inputs': [ '<(PRODUCT_DIR)/'
210 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
211 'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
213 '<(PRODUCT_DIR)/re2c',
216 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
217 '<(RULE_INPUT_PATH)',
219 'process_outputs_as_sources': 1,
220 'message': 'yasm re2c for <(RULE_INPUT_PATH)',
228 'action_name': 'generate_nasm_macros',
230 'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
231 'varname': 'nasm_standard_mac',
232 'outfile': '<(generated_dir)/nasm-macros.c',
234 'inputs': [ '<(PRODUCT_DIR)/'
235 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
237 'outputs': [ '<(outfile)', ],
238 'action': ['<(PRODUCT_DIR)/genmacro',
239 '<(outfile)', '<(varname)', '<(infile)', ],
240 # Not a direct source because this is #included by
241 # source/patched-yasm/modules/parsers/nasm/nasm-parser.c
242 'process_outputs_as_sources': 1,
243 'message': 'yasm genmacro for <(infile)',
246 'action_name': 'generate_nasm_version',
248 'infile': '<(shared_generated_dir)/<(version_file)',
249 'varname': 'nasm_version_mac',
250 'outfile': '<(generated_dir)/nasm-version.c',
252 'inputs': [ '<(PRODUCT_DIR)/'
253 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
255 'outputs': [ '<(outfile)', ],
256 'action': ['<(PRODUCT_DIR)/genmacro',
257 '<(outfile)', '<(varname)', '<(infile)',
259 # Not a direct source because this is #included by
260 # source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c
261 'process_outputs_as_sources': 0,
262 'message': 'yasm genmacro for <(infile)',
265 'action_name': 'generate_win64_gas',
267 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
268 'varname': 'win64_gas_stdmac',
269 'outfile': '<(generated_dir)/win64-gas.c',
271 'inputs': [ '<(PRODUCT_DIR)/'
272 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
274 'outputs': [ '<(outfile)', ],
275 'action': ['<(PRODUCT_DIR)/genmacro',
276 '<(outfile)', '<(varname)', '<(infile)',
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)',
284 'action_name': 'generate_win64_nasm',
286 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
287 'varname': 'win64_nasm_stdmac',
288 'outfile': '<(generated_dir)/win64-nasm.c',
290 'inputs': [ '<(PRODUCT_DIR)/'
291 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
293 'outputs': [ '<(outfile)', ],
294 'action': ['<(PRODUCT_DIR)/genmacro',
299 # Not a direct source because this is #included by
300 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
301 'process_outputs_as_sources': 0,
302 'message': 'yasm genmacro for <(infile)',
309 'action_name': 'generate_license',
311 'infile': 'source/patched-yasm/COPYING',
312 'varname': 'license_msg',
313 'outfile': '<(generated_dir)/license.c',
315 'inputs': [ '<(PRODUCT_DIR)/'
316 '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
318 'outputs': [ '<(outfile)', ],
319 'action': ['<(PRODUCT_DIR)/genstring',
324 # Not a direct source because this is #included by
325 # source/patched-yasm/frontends/yasm/yasm.c
326 'process_outputs_as_sources': 0,
327 'message': 'Generating yasm embeddable license',
331 ### A re2c call that doesn't fit into the rule below.
334 'action_name': 'generate_lc3b_token',
336 'infile': 'source/patched-yasm/modules/arch/lc3b/lc3bid.re',
337 # The license file is #included by yasm.c.
338 'outfile': '<(generated_dir)/lc3bid.c',
340 'inputs': [ '<(PRODUCT_DIR)/'
341 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
343 'outputs': [ '<(outfile)', ],
345 '<(PRODUCT_DIR)/re2c',
350 'process_outputs_as_sources': 1,
351 'message': 'Generating yasm tokens for lc3b',
358 'action_name': 'generate_module',
360 'makefile': 'source/config/<(OS)/Makefile',
361 'module_in': 'source/patched-yasm/libyasm/module.in',
362 'outfile': '<(generated_dir)/module.c',
365 '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
369 'outputs': [ '<(generated_dir)/module.c' ],
371 '<(PRODUCT_DIR)/genmodule',
376 'process_outputs_as_sources': 1,
377 'message': 'Generating yasm module information',
382 'target_name': 'config_sources',
384 'toolsets': ['host'],
386 'source/config/<(OS)/Makefile',
387 'source/config/<(OS)/config.h',
388 'source/config/<(OS)/libyasm-stdint.h',
392 'target_name': 'generate_files',
394 'toolsets': ['host'],
400 'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
401 'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
405 'rule_name': 'generate_gperf',
406 'extension': 'gperf',
407 'inputs': [ '<(PRODUCT_DIR)/'
408 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
409 'outputs': [ '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c', ],
411 '<(PRODUCT_DIR)/genperf',
412 '<(RULE_INPUT_PATH)',
413 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
415 'process_outputs_as_sources': 0,
416 'message': 'yasm genperf for <(RULE_INPUT_PATH)',
421 'action_name': 'generate_x86_insn',
424 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
426 'inputs': [ '<(gen_insn_path)', ],
428 '<(shared_generated_dir)/x86insns.c',
429 '<(shared_generated_dir)/x86insn_gas.gperf',
430 '<(shared_generated_dir)/x86insn_nasm.gperf',
435 '<(shared_generated_dir)',
437 'message': 'Running <(gen_insn_path)',
438 'process_outputs_as_sources': 0,
441 'action_name': 'generate_version',
442 'inputs': [ '<(PRODUCT_DIR)/'
443 '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
444 'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
446 '<(PRODUCT_DIR)/genversion',
447 '<(shared_generated_dir)/<(version_file)'
449 'message': 'Generating yasm version file: '
450 '<(shared_generated_dir)/<(version_file)',
451 'process_outputs_as_sources': 0,
456 'target_name': 'genperf_libs',
457 'type': 'static_library',
458 'toolsets': ['host'],
459 'dependencies': [ 'config_sources', ],
461 'source/patched-yasm/libyasm/phash.c',
462 'source/patched-yasm/libyasm/xmalloc.c',
463 'source/patched-yasm/libyasm/xstrdup.c',
466 '<@(yasm_include_dirs)',
468 'defines': [ '<@(yasm_defines)' ],
474 'target_name': 'genstring',
475 'type': 'executable',
476 'toolsets': ['host'],
477 'dependencies': [ 'config_sources', ],
479 'source/patched-yasm/genstring.c',
482 '<@(yasm_include_dirs)',
489 'target_name': 'genperf',
490 'type': 'executable',
491 'toolsets': ['host'],
496 'source/patched-yasm/tools/genperf/genperf.c',
497 'source/patched-yasm/tools/genperf/perfect.c',
500 '<@(yasm_include_dirs)',
507 'target_name': 'genmacro',
508 'type': 'executable',
509 'toolsets': ['host'],
510 'dependencies': [ 'config_sources', ],
512 'source/patched-yasm/tools/genmacro/genmacro.c',
515 '<@(yasm_include_dirs)',
522 'target_name': 'genversion',
523 'type': 'executable',
524 'toolsets': ['host'],
525 'dependencies': [ 'config_sources', ],
527 'source/patched-yasm/modules/preprocs/nasm/genversion.c',
530 '<@(yasm_include_dirs)',
537 'target_name': 're2c',
538 'type': 'executable',
539 'toolsets': ['host'],
540 'dependencies': [ 'config_sources', ],
542 'source/patched-yasm/tools/re2c/main.c',
543 'source/patched-yasm/tools/re2c/code.c',
544 'source/patched-yasm/tools/re2c/dfa.c',
545 'source/patched-yasm/tools/re2c/parser.c',
546 'source/patched-yasm/tools/re2c/actions.c',
547 'source/patched-yasm/tools/re2c/scanner.c',
548 'source/patched-yasm/tools/re2c/mbo_getopt.c',
549 'source/patched-yasm/tools/re2c/substr.c',
550 'source/patched-yasm/tools/re2c/translate.c',
553 '<@(yasm_include_dirs)',
559 # re2c is missing CLOSEVOP from one switch.
560 'clang_warning_flags': [ '-Wno-switch' ],
562 'msvs_disabled_warnings': [ 4267 ],
565 'target_name': 'genmodule',
566 'type': 'executable',
567 'toolsets': ['host'],
572 'source/patched-yasm/libyasm/genmodule.c',
575 '<@(yasm_include_dirs)',