[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / third_party / yasm / yasm.gyp
blob6a5e6920bb93e8872d50f65c335d0f1ab5220645
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   'target_defaults': {
60     # Silence warnings in libc++ builds (C code doesn't need this flag).
61     'ldflags!': [ '-stdlib=libc++', ],
62   },
63   'targets': [
64     {
65       'target_name': 'yasm',
66       'type': 'executable',
67       'toolsets': ['host'],
68       'dependencies': [
69         'config_sources',
70         'genmacro',
71         'genmodule',
72         'genperf',
73         'genperf_libs',
74         'generate_files',  # Needed to generate gperf and instruction files.
75         'genstring',
76         're2c',
77       ],
78       'variables': {
79         'clang_warning_flags': [
80           # yasm passes a `const elf_machine_sym*` through `void*`.
81           '-Wno-incompatible-pointer-types',
82         ],
83       },
84       'conditions': [
85         ['OS=="win"', {
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
90           # bug for details:
91           # https://connect.microsoft.com/VisualStudio/feedback/details/1014799/internal-compiler-error-when-using-analyze
92           'msvs_settings': {
93             'VCCLCompilerTool': {
94               'AdditionalOptions!': [ '/analyze' ]
95             },
96           },
97         }],
98       ],
99       'sources': [
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
173          # target below.
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',
178       ],
179       'include_dirs': [
180         '<@(yasm_include_dirs)',
181         '<(shared_generated_dir)',
182         '<(generated_dir)',
183       ],
184       'defines': [ '<@(yasm_defines)' ],
185       'cflags': [ '<@(yasm_cflags)', ],
186       'msvs_disabled_warnings': [ 4267 ],
187       'rules': [
188         {
189           'rule_name': 'generate_gperf',
190           'extension': 'gperf',
191           'inputs': [ '<(PRODUCT_DIR)/'
192                       '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
193           'outputs': [
194             '<(generated_dir)/<(RULE_INPUT_ROOT).c',
195           ],
196           'action': ['<(PRODUCT_DIR)/genperf',
197                      '<(RULE_INPUT_PATH)',
198                      '<(generated_dir)/<(RULE_INPUT_ROOT).c',
199           ],
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)',
203         },
204         {
205           'rule_name': 'generate_re2c',
206           'extension': 're',
207           'inputs': [ '<(PRODUCT_DIR)/'
208                       '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
209           'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
210           'action': [
211             '<(PRODUCT_DIR)/re2c',
212             '-b',
213             '-o',
214             '<(generated_dir)/<(RULE_INPUT_ROOT).c',
215             '<(RULE_INPUT_PATH)',
216           ],
217           'process_outputs_as_sources': 1,
218           'message': 'yasm re2c for <(RULE_INPUT_PATH)',
219         },
220       ],
221       'actions': [
222         ###
223         ###  genmacro calls.
224         ###
225         {
226           'action_name': 'generate_nasm_macros',
227           'variables': {
228             'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
229             'varname': 'nasm_standard_mac',
230             'outfile': '<(generated_dir)/nasm-macros.c',
231           },
232           'inputs': [ '<(PRODUCT_DIR)/'
233                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
234                       '<(infile)', ],
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)',
242         },
243         {
244           'action_name': 'generate_nasm_version',
245           'variables': {
246             'infile': '<(shared_generated_dir)/<(version_file)',
247             'varname': 'nasm_version_mac',
248             'outfile': '<(generated_dir)/nasm-version.c',
249           },
250           'inputs': [ '<(PRODUCT_DIR)/'
251                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
252                       '<(infile)', ],
253           'outputs': [ '<(outfile)', ],
254           'action': ['<(PRODUCT_DIR)/genmacro',
255                      '<(outfile)', '<(varname)', '<(infile)',
256           ],
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)',
261         },
262         {
263           'action_name': 'generate_win64_gas',
264           'variables': {
265             'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
266             'varname': 'win64_gas_stdmac',
267             'outfile': '<(generated_dir)/win64-gas.c',
268           },
269           'inputs': [ '<(PRODUCT_DIR)/'
270                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
271                       '<(infile)', ],
272           'outputs': [ '<(outfile)', ],
273           'action': ['<(PRODUCT_DIR)/genmacro',
274                      '<(outfile)', '<(varname)', '<(infile)',
275           ],
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)',
280         },
281         {
282           'action_name': 'generate_win64_nasm',
283           'variables': {
284             'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
285             'varname': 'win64_nasm_stdmac',
286             'outfile': '<(generated_dir)/win64-nasm.c',
287           },
288           'inputs': [ '<(PRODUCT_DIR)/'
289                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
290                       '<(infile)', ],
291           'outputs': [ '<(outfile)', ],
292           'action': ['<(PRODUCT_DIR)/genmacro',
293                      '<(outfile)',
294                      '<(varname)',
295                      '<(infile)',
296           ],
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)',
301         },
303         ###
304         ###  genstring call.
305         ###
306         {
307           'action_name': 'generate_license',
308           'variables': {
309             'infile': 'source/patched-yasm/COPYING',
310             'varname': 'license_msg',
311             'outfile': '<(generated_dir)/license.c',
312           },
313           'inputs': [ '<(PRODUCT_DIR)/'
314                       '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
315                       '<(infile)', ],
316           'outputs': [ '<(outfile)', ],
317           'action': ['<(PRODUCT_DIR)/genstring',
318                      '<(varname)',
319                      '<(outfile)',
320                      '<(infile)',
321           ],
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',
326         },
328         ###
329         ###  A re2c call that doesn't fit into the rule below.
330         ###
331         {
332           'action_name': 'generate_lc3b_token',
333           'variables': {
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',
337           },
338           'inputs': [ '<(PRODUCT_DIR)/'
339                       '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
340                       '<(infile)', ],
341           'outputs': [ '<(outfile)', ],
342           'action': [
343             '<(PRODUCT_DIR)/re2c',
344             '-s',
345             '-o', '<(outfile)',
346             '<(infile)'
347           ],
348           'process_outputs_as_sources': 1,
349           'message': 'Generating yasm tokens for lc3b',
350         },
352         ###
353         ###  genmodule call.
354         ###
355         {
356           'action_name': 'generate_module',
357           'variables': {
358             'makefile': 'source/config/<(OS)/Makefile',
359             'module_in': 'source/patched-yasm/libyasm/module.in',
360             'outfile': '<(generated_dir)/module.c',
361           },
362           'inputs': [
363             '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
364             '<(module_in)',
365             '<(makefile)'
366           ],
367           'outputs': [ '<(generated_dir)/module.c' ],
368           'action': [
369             '<(PRODUCT_DIR)/genmodule',
370             '<(module_in)',
371             '<(makefile)',
372             '<(outfile)'
373           ],
374           'process_outputs_as_sources': 1,
375           'message': 'Generating yasm module information',
376         },
377       ],
378     },
379     {
380       'target_name': 'config_sources',
381       'type': 'none',
382       'toolsets': ['host'],
383       'sources': [
384         'source/config/<(OS)/Makefile',
385         'source/config/<(OS)/config.h',
386         'source/config/<(OS)/libyasm-stdint.h',
387       ],
388     },
389     {
390       'target_name': 'generate_files',
391       'type': 'none',
392       'toolsets': ['host'],
393       'dependencies': [
394         'genperf',
395         'genversion',
396       ],
397       'sources': [
398          'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
399          'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
400       ],
401       'rules': [
402         {
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', ],
408           'action': [
409             '<(PRODUCT_DIR)/genperf',
410             '<(RULE_INPUT_PATH)',
411             '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
412           ],
413           'process_outputs_as_sources': 0,
414           'message': 'yasm genperf for <(RULE_INPUT_PATH)',
415         },
416       ],
417       'actions': [
418         {
419           'action_name': 'generate_x86_insn',
420           'variables': {
421             'gen_insn_path':
422                 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
423           },
424           'inputs': [ '<(gen_insn_path)', ],
425           'outputs': [
426             '<(shared_generated_dir)/x86insns.c',
427             '<(shared_generated_dir)/x86insn_gas.gperf',
428             '<(shared_generated_dir)/x86insn_nasm.gperf',
429           ],
430           'action': [
431             'python',
432             '<(gen_insn_path)',
433             '<(shared_generated_dir)',
434           ],
435           'message': 'Running <(gen_insn_path)',
436           'process_outputs_as_sources': 0,
437         },
438         {
439           'action_name': 'generate_version',
440           'inputs': [ '<(PRODUCT_DIR)/'
441                       '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
442           'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
443           'action': [
444             '<(PRODUCT_DIR)/genversion',
445             '<(shared_generated_dir)/<(version_file)'
446           ],
447           'message': 'Generating yasm version file: '
448                      '<(shared_generated_dir)/<(version_file)',
449           'process_outputs_as_sources': 0,
450         },
451       ],
452     },
453     {
454       'target_name': 'genperf_libs',
455       'type': 'static_library',
456       'toolsets': ['host'],
457       'dependencies': [ 'config_sources', ],
458       'sources': [
459          'source/patched-yasm/libyasm/phash.c',
460          'source/patched-yasm/libyasm/xmalloc.c',
461          'source/patched-yasm/libyasm/xstrdup.c',
462       ],
463       'include_dirs': [
464         '<@(yasm_include_dirs)',
465       ],
466       'defines': [ '<@(yasm_defines)' ],
467       'cflags': [
468         '<@(yasm_cflags)',
469       ],
470     },
471     {
472       'target_name': 'genstring',
473       'type': 'executable',
474       'toolsets': ['host'],
475       'dependencies': [ 'config_sources', ],
476       'sources': [
477          'source/patched-yasm/genstring.c',
478       ],
479       'include_dirs': [
480         '<@(yasm_include_dirs)',
481       ],
482       'cflags': [
483         '-std=gnu99',
484       ],
485     },
486     {
487       'target_name': 'genperf',
488       'type': 'executable',
489       'toolsets': ['host'],
490       'dependencies': [
491         'genperf_libs',
492       ],
493       'sources': [
494          'source/patched-yasm/tools/genperf/genperf.c',
495          'source/patched-yasm/tools/genperf/perfect.c',
496       ],
497       'include_dirs': [
498         '<@(yasm_include_dirs)',
499       ],
500       'cflags': [
501         '-std=gnu99',
502       ],
503     },
504     {
505       'target_name': 'genmacro',
506       'type': 'executable',
507       'toolsets': ['host'],
508       'dependencies': [ 'config_sources', ],
509       'sources': [
510         'source/patched-yasm/tools/genmacro/genmacro.c',
511       ],
512       'include_dirs': [
513         '<@(yasm_include_dirs)',
514       ],
515       'cflags': [
516         '-std=gnu99',
517       ],
518     },
519     {
520       'target_name': 'genversion',
521       'type': 'executable',
522       'toolsets': ['host'],
523       'dependencies': [ 'config_sources', ],
524       'sources': [
525          'source/patched-yasm/modules/preprocs/nasm/genversion.c',
526       ],
527       'include_dirs': [
528         '<@(yasm_include_dirs)',
529       ],
530       'cflags': [
531         '-std=gnu99',
532       ],
533     },
534     {
535       'target_name': 're2c',
536       'type': 'executable',
537       'toolsets': ['host'],
538       'dependencies': [ 'config_sources', ],
539       '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',
549       ],
550       'include_dirs': [
551         '<@(yasm_include_dirs)',
552       ],
553       'cflags': [
554         '-std=gnu99',
555       ],
556       'variables': {
557           # re2c is missing CLOSEVOP from one switch.
558         'clang_warning_flags': [ '-Wno-switch' ],
559       },
560       'msvs_disabled_warnings': [ 4267 ],
561     },
562     {
563       'target_name': 'genmodule',
564       'type': 'executable',
565       'toolsets': ['host'],
566       'dependencies': [
567         'config_sources',
568       ],
569       'sources': [
570         'source/patched-yasm/libyasm/genmodule.c',
571       ],
572       'include_dirs': [
573         '<@(yasm_include_dirs)',
575       ],
576       'cflags': [
577         '-std=gnu99',
578       ],
579     },
580   ],