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++', ],
65 'target_name': 'yasm',
74 'generate_files', # Needed to generate gperf and instruction files.
79 'clang_warning_flags': [
80 # yasm passes a `const elf_machine_sym*` through `void*`.
81 '-Wno-incompatible-pointer-types',
86 # As of VS 2013 Update 3, building this project with /analyze hits an
87 # internal compiler error on elf-x86-amd64.c in release builds with
88 # the amd64_x86 compiler. This halts the build and prevents subsequent
89 # analysis. Therefore, /analyze is disabled for this project. See this
91 # https://connect.microsoft.com/VisualStudio/feedback/details/1014799/internal-compiler-error-when-using-analyze
94 'AdditionalOptions!': [ '/analyze' ]
100 'source/patched-yasm/frontends/yasm/yasm-options.c',
101 'source/patched-yasm/frontends/yasm/yasm.c',
102 'source/patched-yasm/libyasm/assocdat.c',
103 'source/patched-yasm/libyasm/bc-align.c',
104 'source/patched-yasm/libyasm/bc-data.c',
105 'source/patched-yasm/libyasm/bc-incbin.c',
106 'source/patched-yasm/libyasm/bc-org.c',
107 'source/patched-yasm/libyasm/bc-reserve.c',
108 'source/patched-yasm/libyasm/bitvect.c',
109 'source/patched-yasm/libyasm/bytecode.c',
110 'source/patched-yasm/libyasm/errwarn.c',
111 'source/patched-yasm/libyasm/expr.c',
112 'source/patched-yasm/libyasm/file.c',
113 'source/patched-yasm/libyasm/floatnum.c',
114 'source/patched-yasm/libyasm/hamt.c',
115 'source/patched-yasm/libyasm/insn.c',
116 'source/patched-yasm/libyasm/intnum.c',
117 'source/patched-yasm/libyasm/inttree.c',
118 'source/patched-yasm/libyasm/linemap.c',
119 'source/patched-yasm/libyasm/md5.c',
120 'source/patched-yasm/libyasm/mergesort.c',
121 'source/patched-yasm/libyasm/section.c',
122 'source/patched-yasm/libyasm/strcasecmp.c',
123 'source/patched-yasm/libyasm/strsep.c',
124 'source/patched-yasm/libyasm/symrec.c',
125 'source/patched-yasm/libyasm/valparam.c',
126 'source/patched-yasm/libyasm/value.c',
127 'source/patched-yasm/modules/arch/lc3b/lc3barch.c',
128 'source/patched-yasm/modules/arch/lc3b/lc3bbc.c',
129 'source/patched-yasm/modules/arch/x86/x86arch.c',
130 'source/patched-yasm/modules/arch/x86/x86bc.c',
131 'source/patched-yasm/modules/arch/x86/x86expr.c',
132 'source/patched-yasm/modules/arch/x86/x86id.c',
133 'source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c',
134 'source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c',
135 'source/patched-yasm/modules/dbgfmts/codeview/cv-type.c',
136 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c',
137 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c',
138 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c',
139 'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c',
140 'source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c',
141 'source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c',
142 'source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c',
143 'source/patched-yasm/modules/objfmts/bin/bin-objfmt.c',
144 'source/patched-yasm/modules/objfmts/coff/coff-objfmt.c',
145 'source/patched-yasm/modules/objfmts/coff/win64-except.c',
146 'source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c',
147 'source/patched-yasm/modules/objfmts/elf/elf-objfmt.c',
148 'source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c',
149 'source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c',
150 'source/patched-yasm/modules/objfmts/elf/elf.c',
151 'source/patched-yasm/modules/objfmts/macho/macho-objfmt.c',
152 'source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c',
153 'source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c',
154 'source/patched-yasm/modules/parsers/gas/gas-parse.c',
155 'source/patched-yasm/modules/parsers/gas/gas-parse-intel.c',
156 'source/patched-yasm/modules/parsers/gas/gas-parser.c',
157 'source/patched-yasm/modules/parsers/nasm/nasm-parse.c',
158 'source/patched-yasm/modules/parsers/nasm/nasm-parser.c',
159 'source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c',
160 'source/patched-yasm/modules/preprocs/nasm/nasm-eval.c',
161 'source/patched-yasm/modules/preprocs/nasm/nasm-pp.c',
162 'source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c',
163 'source/patched-yasm/modules/preprocs/nasm/nasmlib.c',
164 'source/patched-yasm/modules/preprocs/raw/raw-preproc.c',
166 # Sources needed by re2c.
167 'source/patched-yasm/modules/parsers/gas/gas-token.re',
168 'source/patched-yasm/modules/parsers/nasm/nasm-token.re',
170 # Sources needed by genperf. Make sure the generated gperf files
171 # (the ones in shared_generated_dir) are synced with the outputs
172 # for the related generate_*_insn actions in the generate_files
174 '<(shared_generated_dir)/x86insn_nasm.gperf',
175 '<(shared_generated_dir)/x86insn_gas.gperf',
176 '<(shared_generated_dir)/x86cpu.c',
177 '<(shared_generated_dir)/x86regtmod.c',
180 '<@(yasm_include_dirs)',
181 '<(shared_generated_dir)',
184 'defines': [ '<@(yasm_defines)' ],
185 'cflags': [ '<@(yasm_cflags)', ],
186 'msvs_disabled_warnings': [ 4267 ],
189 'rule_name': 'generate_gperf',
190 'extension': 'gperf',
191 'inputs': [ '<(PRODUCT_DIR)/'
192 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
194 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
196 'action': ['<(PRODUCT_DIR)/genperf',
197 '<(RULE_INPUT_PATH)',
198 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
200 # These files are #included, so do not treat them as sources.
201 'process_outputs_as_sources': 0,
202 'message': 'yasm gperf for <(RULE_INPUT_PATH)',
205 'rule_name': 'generate_re2c',
207 'inputs': [ '<(PRODUCT_DIR)/'
208 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
209 'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
211 '<(PRODUCT_DIR)/re2c',
214 '<(generated_dir)/<(RULE_INPUT_ROOT).c',
215 '<(RULE_INPUT_PATH)',
217 'process_outputs_as_sources': 1,
218 'message': 'yasm re2c for <(RULE_INPUT_PATH)',
226 'action_name': 'generate_nasm_macros',
228 'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
229 'varname': 'nasm_standard_mac',
230 'outfile': '<(generated_dir)/nasm-macros.c',
232 'inputs': [ '<(PRODUCT_DIR)/'
233 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
235 'outputs': [ '<(outfile)', ],
236 'action': ['<(PRODUCT_DIR)/genmacro',
237 '<(outfile)', '<(varname)', '<(infile)', ],
238 # Not a direct source because this is #included by
239 # source/patched-yasm/modules/parsers/nasm/nasm-parser.c
240 'process_outputs_as_sources': 1,
241 'message': 'yasm genmacro for <(infile)',
244 'action_name': 'generate_nasm_version',
246 'infile': '<(shared_generated_dir)/<(version_file)',
247 'varname': 'nasm_version_mac',
248 'outfile': '<(generated_dir)/nasm-version.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/preprocs/nasm/nasm-preproc.c
259 'process_outputs_as_sources': 0,
260 'message': 'yasm genmacro for <(infile)',
263 'action_name': 'generate_win64_gas',
265 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
266 'varname': 'win64_gas_stdmac',
267 'outfile': '<(generated_dir)/win64-gas.c',
269 'inputs': [ '<(PRODUCT_DIR)/'
270 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
272 'outputs': [ '<(outfile)', ],
273 'action': ['<(PRODUCT_DIR)/genmacro',
274 '<(outfile)', '<(varname)', '<(infile)',
276 # Not a direct source because this is #included by
277 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
278 'process_outputs_as_sources': 0,
279 'message': 'yasm genmacro for <(infile)',
282 'action_name': 'generate_win64_nasm',
284 'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
285 'varname': 'win64_nasm_stdmac',
286 'outfile': '<(generated_dir)/win64-nasm.c',
288 'inputs': [ '<(PRODUCT_DIR)/'
289 '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
291 'outputs': [ '<(outfile)', ],
292 'action': ['<(PRODUCT_DIR)/genmacro',
297 # Not a direct source because this is #included by
298 # source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
299 'process_outputs_as_sources': 0,
300 'message': 'yasm genmacro for <(infile)',
307 'action_name': 'generate_license',
309 'infile': 'source/patched-yasm/COPYING',
310 'varname': 'license_msg',
311 'outfile': '<(generated_dir)/license.c',
313 'inputs': [ '<(PRODUCT_DIR)/'
314 '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
316 'outputs': [ '<(outfile)', ],
317 'action': ['<(PRODUCT_DIR)/genstring',
322 # Not a direct source because this is #included by
323 # source/patched-yasm/frontends/yasm/yasm.c
324 'process_outputs_as_sources': 0,
325 'message': 'Generating yasm embeddable license',
329 ### A re2c call that doesn't fit into the rule below.
332 'action_name': 'generate_lc3b_token',
334 'infile': 'source/patched-yasm/modules/arch/lc3b/lc3bid.re',
335 # The license file is #included by yasm.c.
336 'outfile': '<(generated_dir)/lc3bid.c',
338 'inputs': [ '<(PRODUCT_DIR)/'
339 '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
341 'outputs': [ '<(outfile)', ],
343 '<(PRODUCT_DIR)/re2c',
348 'process_outputs_as_sources': 1,
349 'message': 'Generating yasm tokens for lc3b',
356 'action_name': 'generate_module',
358 'makefile': 'source/config/<(OS)/Makefile',
359 'module_in': 'source/patched-yasm/libyasm/module.in',
360 'outfile': '<(generated_dir)/module.c',
363 '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
367 'outputs': [ '<(generated_dir)/module.c' ],
369 '<(PRODUCT_DIR)/genmodule',
374 'process_outputs_as_sources': 1,
375 'message': 'Generating yasm module information',
380 'target_name': 'config_sources',
382 'toolsets': ['host'],
384 'source/config/<(OS)/Makefile',
385 'source/config/<(OS)/config.h',
386 'source/config/<(OS)/libyasm-stdint.h',
390 'target_name': 'generate_files',
392 'toolsets': ['host'],
398 'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
399 'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
403 'rule_name': 'generate_gperf',
404 'extension': 'gperf',
405 'inputs': [ '<(PRODUCT_DIR)/'
406 '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
407 'outputs': [ '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c', ],
409 '<(PRODUCT_DIR)/genperf',
410 '<(RULE_INPUT_PATH)',
411 '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
413 'process_outputs_as_sources': 0,
414 'message': 'yasm genperf for <(RULE_INPUT_PATH)',
419 'action_name': 'generate_x86_insn',
422 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
424 'inputs': [ '<(gen_insn_path)', ],
426 '<(shared_generated_dir)/x86insns.c',
427 '<(shared_generated_dir)/x86insn_gas.gperf',
428 '<(shared_generated_dir)/x86insn_nasm.gperf',
433 '<(shared_generated_dir)',
435 'message': 'Running <(gen_insn_path)',
436 'process_outputs_as_sources': 0,
439 'action_name': 'generate_version',
440 'inputs': [ '<(PRODUCT_DIR)/'
441 '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
442 'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
444 '<(PRODUCT_DIR)/genversion',
445 '<(shared_generated_dir)/<(version_file)'
447 'message': 'Generating yasm version file: '
448 '<(shared_generated_dir)/<(version_file)',
449 'process_outputs_as_sources': 0,
454 'target_name': 'genperf_libs',
455 'type': 'static_library',
456 'toolsets': ['host'],
457 'dependencies': [ 'config_sources', ],
459 'source/patched-yasm/libyasm/phash.c',
460 'source/patched-yasm/libyasm/xmalloc.c',
461 'source/patched-yasm/libyasm/xstrdup.c',
464 '<@(yasm_include_dirs)',
466 'defines': [ '<@(yasm_defines)' ],
472 'target_name': 'genstring',
473 'type': 'executable',
474 'toolsets': ['host'],
475 'dependencies': [ 'config_sources', ],
477 'source/patched-yasm/genstring.c',
480 '<@(yasm_include_dirs)',
487 'target_name': 'genperf',
488 'type': 'executable',
489 'toolsets': ['host'],
494 'source/patched-yasm/tools/genperf/genperf.c',
495 'source/patched-yasm/tools/genperf/perfect.c',
498 '<@(yasm_include_dirs)',
505 'target_name': 'genmacro',
506 'type': 'executable',
507 'toolsets': ['host'],
508 'dependencies': [ 'config_sources', ],
510 'source/patched-yasm/tools/genmacro/genmacro.c',
513 '<@(yasm_include_dirs)',
520 'target_name': 'genversion',
521 'type': 'executable',
522 'toolsets': ['host'],
523 'dependencies': [ 'config_sources', ],
525 'source/patched-yasm/modules/preprocs/nasm/genversion.c',
528 '<@(yasm_include_dirs)',
535 'target_name': 're2c',
536 'type': 'executable',
537 'toolsets': ['host'],
538 'dependencies': [ 'config_sources', ],
540 'source/patched-yasm/tools/re2c/main.c',
541 'source/patched-yasm/tools/re2c/code.c',
542 'source/patched-yasm/tools/re2c/dfa.c',
543 'source/patched-yasm/tools/re2c/parser.c',
544 'source/patched-yasm/tools/re2c/actions.c',
545 'source/patched-yasm/tools/re2c/scanner.c',
546 'source/patched-yasm/tools/re2c/mbo_getopt.c',
547 'source/patched-yasm/tools/re2c/substr.c',
548 'source/patched-yasm/tools/re2c/translate.c',
551 '<@(yasm_include_dirs)',
557 # re2c is missing CLOSEVOP from one switch.
558 'clang_warning_flags': [ '-Wno-switch' ],
560 'msvs_disabled_warnings': [ 4267 ],
563 'target_name': 'genmodule',
564 'type': 'executable',
565 'toolsets': ['host'],
570 'source/patched-yasm/libyasm/genmodule.c',
573 '<@(yasm_include_dirs)',