[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / third_party / yasm / yasm.gyp
blobf135421bf170332da073509eb3a88031f81184ec
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
22 #                      subprogram.
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.
33   'variables': {
34     'yasm_include_dirs': [
35       'source/config/<(OS)',
36       'source/patched-yasm',
37     ],
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'],
45     'yasm_cflags': [
46       '-std=gnu99',
47       '-ansi',
48       '-pedantic',
49     ],
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',
58   },
59   'targets': [
60     {
61       'target_name': 'yasm',
62       'type': 'executable',
63       'toolsets': ['host'],
64       'dependencies': [
65         'config_sources',
66         'genmacro',
67         'genmodule',
68         'genperf',
69         'genperf_libs',
70         'generate_files',  # Needed to generate gperf and instruction files.
71         'genstring',
72         're2c',
73       ],
74       'sources': [
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
148          # target below.
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',
153       ],
154       'include_dirs': [
155         '<@(yasm_include_dirs)',
156         '<(shared_generated_dir)',
157         '<(generated_dir)',
158       ],
159       'defines': [ '<@(yasm_defines)' ],
160       'cflags': [ '<@(yasm_cflags)', ],
161       'conditions': [
162         ['clang==1', {
163           'xcode_settings': {
164             'WARNING_CFLAGS': [
165               # yasm passes a `const elf_machine_sym*` through `void*`.
166               '-Wno-incompatible-pointer-types',
167             ],
168           },
169           'cflags': [
170             '-Wno-incompatible-pointer-types',
171           ],
172         }],
173       ],
174       'msvs_disabled_warnings': [ 4267 ],
175       'rules': [
176         {
177           'rule_name': 'generate_gperf',
178           'extension': 'gperf',
179           'inputs': [ '<(PRODUCT_DIR)/'
180                       '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
181           'outputs': [
182             '<(generated_dir)/<(RULE_INPUT_ROOT).c',
183           ],
184           'action': ['<(PRODUCT_DIR)/genperf',
185                      '<(RULE_INPUT_PATH)',
186                      '<(generated_dir)/<(RULE_INPUT_ROOT).c',
187           ],
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)',
191         },
192         {
193           'rule_name': 'generate_re2c',
194           'extension': 're',
195           'inputs': [ '<(PRODUCT_DIR)/'
196                       '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
197           'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
198           'action': [
199             '<(PRODUCT_DIR)/re2c',
200             '-b',
201             '-o',
202             '<(generated_dir)/<(RULE_INPUT_ROOT).c',
203             '<(RULE_INPUT_PATH)',
204           ],
205           'process_outputs_as_sources': 1,
206           'message': 'yasm re2c for <(RULE_INPUT_PATH)',
207         },
208       ],
209       'actions': [
210         ###
211         ###  genmacro calls.
212         ###
213         {
214           'action_name': 'generate_nasm_macros',
215           'variables': {
216             'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
217             'varname': 'nasm_standard_mac',
218             'outfile': '<(generated_dir)/nasm-macros.c',
219           },
220           'inputs': [ '<(PRODUCT_DIR)/'
221                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
222                       '<(infile)', ],
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)',
230         },
231         {
232           'action_name': 'generate_nasm_version',
233           'variables': {
234             'infile': '<(shared_generated_dir)/<(version_file)',
235             'varname': 'nasm_version_mac',
236             'outfile': '<(generated_dir)/nasm-version.c',
237           },
238           'inputs': [ '<(PRODUCT_DIR)/'
239                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
240                       '<(infile)', ],
241           'outputs': [ '<(outfile)', ],
242           'action': ['<(PRODUCT_DIR)/genmacro',
243                      '<(outfile)', '<(varname)', '<(infile)',
244           ],
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)',
249         },
250         {
251           'action_name': 'generate_win64_gas',
252           'variables': {
253             'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
254             'varname': 'win64_gas_stdmac',
255             'outfile': '<(generated_dir)/win64-gas.c',
256           },
257           'inputs': [ '<(PRODUCT_DIR)/'
258                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
259                       '<(infile)', ],
260           'outputs': [ '<(outfile)', ],
261           'action': ['<(PRODUCT_DIR)/genmacro',
262                      '<(outfile)', '<(varname)', '<(infile)',
263           ],
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)',
268         },
269         {
270           'action_name': 'generate_win64_nasm',
271           'variables': {
272             'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
273             'varname': 'win64_nasm_stdmac',
274             'outfile': '<(generated_dir)/win64-nasm.c',
275           },
276           'inputs': [ '<(PRODUCT_DIR)/'
277                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
278                       '<(infile)', ],
279           'outputs': [ '<(outfile)', ],
280           'action': ['<(PRODUCT_DIR)/genmacro',
281                      '<(outfile)',
282                      '<(varname)',
283                      '<(infile)',
284           ],
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)',
289         },
291         ###
292         ###  genstring call.
293         ###
294         {
295           'action_name': 'generate_license',
296           'variables': {
297             'infile': 'source/patched-yasm/COPYING',
298             'varname': 'license_msg',
299             'outfile': '<(generated_dir)/license.c',
300           },
301           'inputs': [ '<(PRODUCT_DIR)/'
302                       '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
303                       '<(infile)', ],
304           'outputs': [ '<(outfile)', ],
305           'action': ['<(PRODUCT_DIR)/genstring',
306                      '<(varname)',
307                      '<(outfile)',
308                      '<(infile)',
309           ],
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',
314         },
316         ###
317         ###  A re2c call that doesn't fit into the rule below.
318         ###
319         {
320           'action_name': 'generate_lc3b_token',
321           'variables': {
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',
325           },
326           'inputs': [ '<(PRODUCT_DIR)/'
327                       '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
328                       '<(infile)', ],
329           'outputs': [ '<(outfile)', ],
330           'action': [
331             '<(PRODUCT_DIR)/re2c',
332             '-s',
333             '-o', '<(outfile)',
334             '<(infile)'
335           ],
336           'process_outputs_as_sources': 1,
337           'message': 'Generating yasm tokens for lc3b',
338         },
340         ###
341         ###  genmodule call.
342         ###
343         {
344           'action_name': 'generate_module',
345           'variables': {
346             'makefile': 'source/config/<(OS)/Makefile',
347             'module_in': 'source/patched-yasm/libyasm/module.in',
348             'outfile': '<(generated_dir)/module.c',
349           },
350           'inputs': [
351             '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
352             '<(module_in)',
353             '<(makefile)'
354           ],
355           'outputs': [ '<(generated_dir)/module.c' ],
356           'action': [
357             '<(PRODUCT_DIR)/genmodule',
358             '<(module_in)',
359             '<(makefile)',
360             '<(outfile)'
361           ],
362           'process_outputs_as_sources': 1,
363           'message': 'Generating yasm module information',
364         },
365       ],
366     },
367     {
368       'target_name': 'config_sources',
369       'type': 'none',
370       'toolsets': ['host'],
371       'sources': [
372         'source/config/<(OS)/Makefile',
373         'source/config/<(OS)/config.h',
374         'source/config/<(OS)/libyasm-stdint.h',
375       ],
376     },
377     {
378       'target_name': 'generate_files',
379       'type': 'none',
380       'toolsets': ['host'],
381       'dependencies': [
382         'genperf',
383         'genversion',
384       ],
385       'sources': [
386          'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
387          'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
388       ],
389       'rules': [
390         {
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', ],
396           'action': [
397             '<(PRODUCT_DIR)/genperf',
398             '<(RULE_INPUT_PATH)',
399             '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
400           ],
401           'process_outputs_as_sources': 0,
402           'message': 'yasm genperf for <(RULE_INPUT_PATH)',
403         },
404       ],
405       'actions': [
406         {
407           'action_name': 'generate_x86_insn',
408           'variables': {
409             'gen_insn_path':
410                 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
411           },
412           'inputs': [ '<(gen_insn_path)', ],
413           'outputs': [
414             '<(shared_generated_dir)/x86insns.c',
415             '<(shared_generated_dir)/x86insn_gas.gperf',
416             '<(shared_generated_dir)/x86insn_nasm.gperf',
417           ],
418           'action': [
419             'python',
420             '<(gen_insn_path)',
421             '<(shared_generated_dir)',
422           ],
423           'message': 'Running <(gen_insn_path)',
424           'process_outputs_as_sources': 0,
425         },
426         {
427           'action_name': 'generate_version',
428           'inputs': [ '<(PRODUCT_DIR)/'
429                       '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
430           'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
431           'action': [
432             '<(PRODUCT_DIR)/genversion',
433             '<(shared_generated_dir)/<(version_file)'
434           ],
435           'message': 'Generating yasm version file: '
436                      '<(shared_generated_dir)/<(version_file)',
437           'process_outputs_as_sources': 0,
438         },
439       ],
440     },
441     {
442       'target_name': 'genperf_libs',
443       'type': 'static_library',
444       'toolsets': ['host'],
445       'dependencies': [ 'config_sources', ],
446       'sources': [
447          'source/patched-yasm/libyasm/phash.c',
448          'source/patched-yasm/libyasm/xmalloc.c',
449          'source/patched-yasm/libyasm/xstrdup.c',
450       ],
451       'include_dirs': [
452         '<@(yasm_include_dirs)',
453       ],
454       'defines': [ '<@(yasm_defines)' ],
455       'cflags': [
456         '<@(yasm_cflags)',
457       ],
458     },
459     {
460       'target_name': 'genstring',
461       'type': 'executable',
462       'toolsets': ['host'],
463       'dependencies': [ 'config_sources', ],
464       'sources': [
465          'source/patched-yasm/genstring.c',
466       ],
467       'include_dirs': [
468         '<@(yasm_include_dirs)',
469       ],
470       'cflags': [
471         '-std=gnu99',
472       ],
473     },
474     {
475       'target_name': 'genperf',
476       'type': 'executable',
477       'toolsets': ['host'],
478       'dependencies': [
479         'genperf_libs',
480       ],
481       'sources': [
482          'source/patched-yasm/tools/genperf/genperf.c',
483          'source/patched-yasm/tools/genperf/perfect.c',
484       ],
485       'include_dirs': [
486         '<@(yasm_include_dirs)',
487       ],
488       'cflags': [
489         '-std=gnu99',
490       ],
491     },
492     {
493       'target_name': 'genmacro',
494       'type': 'executable',
495       'toolsets': ['host'],
496       'dependencies': [ 'config_sources', ],
497       'sources': [
498         'source/patched-yasm/tools/genmacro/genmacro.c',
499       ],
500       'include_dirs': [
501         '<@(yasm_include_dirs)',
502       ],
503       'cflags': [
504         '-std=gnu99',
505       ],
506     },
507     {
508       'target_name': 'genversion',
509       'type': 'executable',
510       'toolsets': ['host'],
511       'dependencies': [ 'config_sources', ],
512       'sources': [
513          'source/patched-yasm/modules/preprocs/nasm/genversion.c',
514       ],
515       'include_dirs': [
516         '<@(yasm_include_dirs)',
517       ],
518       'cflags': [
519         '-std=gnu99',
520       ],
521     },
522     {
523       'target_name': 're2c',
524       'type': 'executable',
525       'toolsets': ['host'],
526       'dependencies': [ 'config_sources', ],
527       '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',
537       ],
538       'include_dirs': [
539         '<@(yasm_include_dirs)',
540       ],
541       'cflags': [
542         '-std=gnu99',
543       ],
544       'conditions': [
545         ['clang==1', {
546           'xcode_settings': {
547             'WARNING_CFLAGS': [
548               # re2c is missing CLOSEVOP from one switch.
549               '-Wno-switch',
550             ],
551           },
552           'cflags': [
553             '-Wno-switch',
554           ],
555         }],
556       ],
557       'msvs_disabled_warnings': [ 4267 ],
558     },
559     {
560       'target_name': 'genmodule',
561       'type': 'executable',
562       'toolsets': ['host'],
563       'dependencies': [
564         'config_sources',
565       ],
566       'sources': [
567         'source/patched-yasm/libyasm/genmodule.c',
568       ],
569       'include_dirs': [
570         '<@(yasm_include_dirs)',
572       ],
573       'cflags': [
574         '-std=gnu99',
575       ],
576     },
577   ],