Update V8 to version 4.7.44.
[chromium-blink-merge.git] / third_party / yasm / yasm.gyp
blob3db601a83f6a7750e0f14038b20704698210ad34
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     # https://crbug.com/489901
63     'cflags!': [ '-fsanitize=bounds' ],
64   },
65   'targets': [
66     {
67       'target_name': 'yasm',
68       'type': 'executable',
69       'toolsets': ['host'],
70       'dependencies': [
71         'config_sources',
72         'genmacro',
73         'genmodule',
74         'genperf',
75         'genperf_libs',
76         'generate_files',  # Needed to generate gperf and instruction files.
77         'genstring',
78         're2c',
79       ],
80       'variables': {
81         'clang_warning_flags': [
82           # yasm passes a `const elf_machine_sym*` through `void*`.
83           '-Wno-incompatible-pointer-types',
84           # reg3264type in x86expr.c is unused.
85           '-Wno-unused-local-typedef',
86         ],
87       },
88       'conditions': [
89         ['OS=="win"', {
90           # As of VS 2013 Update 3, building this project with /analyze hits an
91           # internal compiler error on elf-x86-amd64.c in release builds with
92           # the amd64_x86 compiler. This halts the build and prevents subsequent
93           # analysis. Therefore, /analyze is disabled for this project. See this
94           # bug for details:
95           # https://connect.microsoft.com/VisualStudio/feedback/details/1014799/internal-compiler-error-when-using-analyze
96           'msvs_settings': {
97             'VCCLCompilerTool': {
98               'AdditionalOptions!': [ '/analyze:WX-' ]
99             },
100           },
101         }],
102       ],
103       'sources': [
104          'source/patched-yasm/frontends/yasm/yasm-options.c',
105          'source/patched-yasm/frontends/yasm/yasm.c',
106          'source/patched-yasm/libyasm/assocdat.c',
107          'source/patched-yasm/libyasm/bc-align.c',
108          'source/patched-yasm/libyasm/bc-data.c',
109          'source/patched-yasm/libyasm/bc-incbin.c',
110          'source/patched-yasm/libyasm/bc-org.c',
111          'source/patched-yasm/libyasm/bc-reserve.c',
112          'source/patched-yasm/libyasm/bitvect.c',
113          'source/patched-yasm/libyasm/bytecode.c',
114          'source/patched-yasm/libyasm/errwarn.c',
115          'source/patched-yasm/libyasm/expr.c',
116          'source/patched-yasm/libyasm/file.c',
117          'source/patched-yasm/libyasm/floatnum.c',
118          'source/patched-yasm/libyasm/hamt.c',
119          'source/patched-yasm/libyasm/insn.c',
120          'source/patched-yasm/libyasm/intnum.c',
121          'source/patched-yasm/libyasm/inttree.c',
122          'source/patched-yasm/libyasm/linemap.c',
123          'source/patched-yasm/libyasm/md5.c',
124          'source/patched-yasm/libyasm/mergesort.c',
125          'source/patched-yasm/libyasm/section.c',
126          'source/patched-yasm/libyasm/strcasecmp.c',
127          'source/patched-yasm/libyasm/strsep.c',
128          'source/patched-yasm/libyasm/symrec.c',
129          'source/patched-yasm/libyasm/valparam.c',
130          'source/patched-yasm/libyasm/value.c',
131          'source/patched-yasm/modules/arch/lc3b/lc3barch.c',
132          'source/patched-yasm/modules/arch/lc3b/lc3bbc.c',
133          'source/patched-yasm/modules/arch/x86/x86arch.c',
134          'source/patched-yasm/modules/arch/x86/x86bc.c',
135          'source/patched-yasm/modules/arch/x86/x86expr.c',
136          'source/patched-yasm/modules/arch/x86/x86id.c',
137          'source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c',
138          'source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c',
139          'source/patched-yasm/modules/dbgfmts/codeview/cv-type.c',
140          'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c',
141          'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c',
142          'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c',
143          'source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c',
144          'source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c',
145          'source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c',
146          'source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c',
147          'source/patched-yasm/modules/objfmts/bin/bin-objfmt.c',
148          'source/patched-yasm/modules/objfmts/coff/coff-objfmt.c',
149          'source/patched-yasm/modules/objfmts/coff/win64-except.c',
150          'source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c',
151          'source/patched-yasm/modules/objfmts/elf/elf-objfmt.c',
152          'source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c',
153          'source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c',
154          'source/patched-yasm/modules/objfmts/elf/elf.c',
155          'source/patched-yasm/modules/objfmts/macho/macho-objfmt.c',
156          'source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c',
157          'source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c',
158          'source/patched-yasm/modules/parsers/gas/gas-parse.c',
159          'source/patched-yasm/modules/parsers/gas/gas-parse-intel.c',
160          'source/patched-yasm/modules/parsers/gas/gas-parser.c',
161          'source/patched-yasm/modules/parsers/nasm/nasm-parse.c',
162          'source/patched-yasm/modules/parsers/nasm/nasm-parser.c',
163          'source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c',
164          'source/patched-yasm/modules/preprocs/nasm/nasm-eval.c',
165          'source/patched-yasm/modules/preprocs/nasm/nasm-pp.c',
166          'source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c',
167          'source/patched-yasm/modules/preprocs/nasm/nasmlib.c',
168          'source/patched-yasm/modules/preprocs/raw/raw-preproc.c',
170          # Sources needed by re2c.
171          'source/patched-yasm/modules/parsers/gas/gas-token.re',
172          'source/patched-yasm/modules/parsers/nasm/nasm-token.re',
174          # Sources needed by genperf. Make sure the generated gperf files
175          # (the ones in shared_generated_dir) are synced with the outputs
176          # for the related generate_*_insn actions in the generate_files
177          # target below.
178          '<(shared_generated_dir)/x86insn_nasm.gperf',
179          '<(shared_generated_dir)/x86insn_gas.gperf',
180          '<(shared_generated_dir)/x86cpu.c',
181          '<(shared_generated_dir)/x86regtmod.c',
182       ],
183       'include_dirs': [
184         '<@(yasm_include_dirs)',
185         '<(shared_generated_dir)',
186         '<(generated_dir)',
187       ],
188       'defines': [ '<@(yasm_defines)' ],
189       'cflags': [ '<@(yasm_cflags)', ],
190       'msvs_disabled_warnings': [ 4267 ],
191       'rules': [
192         {
193           'rule_name': 'generate_gperf',
194           'extension': 'gperf',
195           'inputs': [ '<(PRODUCT_DIR)/'
196                       '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
197           'outputs': [
198             '<(generated_dir)/<(RULE_INPUT_ROOT).c',
199           ],
200           'action': ['<(PRODUCT_DIR)/genperf',
201                      '<(RULE_INPUT_PATH)',
202                      '<(generated_dir)/<(RULE_INPUT_ROOT).c',
203           ],
204           # These files are #included, so do not treat them as sources.
205           'process_outputs_as_sources': 0,
206           'message': 'yasm gperf for <(RULE_INPUT_PATH)',
207         },
208         {
209           'rule_name': 'generate_re2c',
210           'extension': 're',
211           'inputs': [ '<(PRODUCT_DIR)/'
212                       '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)' ],
213           'outputs': [ '<(generated_dir)/<(RULE_INPUT_ROOT).c', ],
214           'action': [
215             '<(PRODUCT_DIR)/re2c',
216             '-b',
217             '-o',
218             '<(generated_dir)/<(RULE_INPUT_ROOT).c',
219             '<(RULE_INPUT_PATH)',
220           ],
221           'process_outputs_as_sources': 1,
222           'message': 'yasm re2c for <(RULE_INPUT_PATH)',
223         },
224       ],
225       'actions': [
226         ###
227         ###  genmacro calls.
228         ###
229         {
230           'action_name': 'generate_nasm_macros',
231           'variables': {
232             'infile': 'source/patched-yasm/modules/parsers/nasm/nasm-std.mac',
233             'varname': 'nasm_standard_mac',
234             'outfile': '<(generated_dir)/nasm-macros.c',
235           },
236           'inputs': [ '<(PRODUCT_DIR)/'
237                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
238                       '<(infile)', ],
239           'outputs': [ '<(outfile)', ],
240           'action': ['<(PRODUCT_DIR)/genmacro',
241                      '<(outfile)', '<(varname)', '<(infile)', ],
242            # Not a direct source because this is #included by
243            #   source/patched-yasm/modules/parsers/nasm/nasm-parser.c
244           'process_outputs_as_sources': 1,
245           'message': 'yasm genmacro for <(infile)',
246         },
247         {
248           'action_name': 'generate_nasm_version',
249           'variables': {
250             'infile': '<(shared_generated_dir)/<(version_file)',
251             'varname': 'nasm_version_mac',
252             'outfile': '<(generated_dir)/nasm-version.c',
253           },
254           'inputs': [ '<(PRODUCT_DIR)/'
255                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
256                       '<(infile)', ],
257           'outputs': [ '<(outfile)', ],
258           'action': ['<(PRODUCT_DIR)/genmacro',
259                      '<(outfile)', '<(varname)', '<(infile)',
260           ],
261            # Not a direct source because this is #included by
262            #   source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c
263           'process_outputs_as_sources': 0,
264           'message': 'yasm genmacro for <(infile)',
265         },
266         {
267           'action_name': 'generate_win64_gas',
268           'variables': {
269             'infile': 'source/patched-yasm/modules/objfmts/coff/win64-gas.mac',
270             'varname': 'win64_gas_stdmac',
271             'outfile': '<(generated_dir)/win64-gas.c',
272           },
273           'inputs': [ '<(PRODUCT_DIR)/'
274                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
275                       '<(infile)', ],
276           'outputs': [ '<(outfile)', ],
277           'action': ['<(PRODUCT_DIR)/genmacro',
278                      '<(outfile)', '<(varname)', '<(infile)',
279           ],
280            # Not a direct source because this is #included by
281            #   source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
282           'process_outputs_as_sources': 0,
283           'message': 'yasm genmacro for <(infile)',
284         },
285         {
286           'action_name': 'generate_win64_nasm',
287           'variables': {
288             'infile': 'source/patched-yasm/modules/objfmts/coff/win64-nasm.mac',
289             'varname': 'win64_nasm_stdmac',
290             'outfile': '<(generated_dir)/win64-nasm.c',
291           },
292           'inputs': [ '<(PRODUCT_DIR)/'
293                       '<(EXECUTABLE_PREFIX)genmacro<(EXECUTABLE_SUFFIX)',
294                       '<(infile)', ],
295           'outputs': [ '<(outfile)', ],
296           'action': ['<(PRODUCT_DIR)/genmacro',
297                      '<(outfile)',
298                      '<(varname)',
299                      '<(infile)',
300           ],
301            # Not a direct source because this is #included by
302            #   source/patched-yasm/modules/objfmts/coff/coff-objfmt.c
303           'process_outputs_as_sources': 0,
304           'message': 'yasm genmacro for <(infile)',
305         },
307         ###
308         ###  genstring call.
309         ###
310         {
311           'action_name': 'generate_license',
312           'variables': {
313             'infile': 'source/patched-yasm/COPYING',
314             'varname': 'license_msg',
315             'outfile': '<(generated_dir)/license.c',
316           },
317           'inputs': [ '<(PRODUCT_DIR)/'
318                       '<(EXECUTABLE_PREFIX)genstring<(EXECUTABLE_SUFFIX)',
319                       '<(infile)', ],
320           'outputs': [ '<(outfile)', ],
321           'action': ['<(PRODUCT_DIR)/genstring',
322                      '<(varname)',
323                      '<(outfile)',
324                      '<(infile)',
325           ],
326           # Not a direct source because this is #included by
327           #   source/patched-yasm/frontends/yasm/yasm.c
328           'process_outputs_as_sources': 0,
329           'message': 'Generating yasm embeddable license',
330         },
332         ###
333         ###  A re2c call that doesn't fit into the rule below.
334         ###
335         {
336           'action_name': 'generate_lc3b_token',
337           'variables': {
338             'infile': 'source/patched-yasm/modules/arch/lc3b/lc3bid.re',
339             # The license file is #included by yasm.c.
340             'outfile': '<(generated_dir)/lc3bid.c',
341           },
342           'inputs': [ '<(PRODUCT_DIR)/'
343                       '<(EXECUTABLE_PREFIX)re2c<(EXECUTABLE_SUFFIX)',
344                       '<(infile)', ],
345           'outputs': [ '<(outfile)', ],
346           'action': [
347             '<(PRODUCT_DIR)/re2c',
348             '-s',
349             '-o', '<(outfile)',
350             '<(infile)'
351           ],
352           'process_outputs_as_sources': 1,
353           'message': 'Generating yasm tokens for lc3b',
354         },
356         ###
357         ###  genmodule call.
358         ###
359         {
360           'action_name': 'generate_module',
361           'variables': {
362             'makefile': 'source/config/<(OS)/Makefile',
363             'module_in': 'source/patched-yasm/libyasm/module.in',
364             'outfile': '<(generated_dir)/module.c',
365           },
366           'inputs': [
367             '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)genmodule<(EXECUTABLE_SUFFIX)',
368             '<(module_in)',
369             '<(makefile)'
370           ],
371           'outputs': [ '<(generated_dir)/module.c' ],
372           'action': [
373             '<(PRODUCT_DIR)/genmodule',
374             '<(module_in)',
375             '<(makefile)',
376             '<(outfile)'
377           ],
378           'process_outputs_as_sources': 1,
379           'message': 'Generating yasm module information',
380         },
381       ],
382     },
383     {
384       'target_name': 'config_sources',
385       'type': 'none',
386       'toolsets': ['host'],
387       'sources': [
388         'source/config/<(OS)/Makefile',
389         'source/config/<(OS)/config.h',
390         'source/config/<(OS)/libyasm-stdint.h',
391       ],
392     },
393     {
394       'target_name': 'generate_files',
395       'type': 'none',
396       'toolsets': ['host'],
397       'dependencies': [
398         'genperf',
399         'genversion',
400       ],
401       'sources': [
402          'source/patched-yasm/modules/arch/x86/x86cpu.gperf',
403          'source/patched-yasm/modules/arch/x86/x86regtmod.gperf',
404       ],
405       'rules': [
406         {
407           'rule_name': 'generate_gperf',
408           'extension': 'gperf',
409           'inputs': [ '<(PRODUCT_DIR)/'
410                       '<(EXECUTABLE_PREFIX)genperf<(EXECUTABLE_SUFFIX)' ],
411           'outputs': [ '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c', ],
412           'action': [
413             '<(PRODUCT_DIR)/genperf',
414             '<(RULE_INPUT_PATH)',
415             '<(shared_generated_dir)/<(RULE_INPUT_ROOT).c',
416           ],
417           'process_outputs_as_sources': 0,
418           'message': 'yasm genperf for <(RULE_INPUT_PATH)',
419         },
420       ],
421       'actions': [
422         {
423           'action_name': 'generate_x86_insn',
424           'variables': {
425             'gen_insn_path':
426                 'source/patched-yasm/modules/arch/x86/gen_x86_insn.py',
427           },
428           'inputs': [ '<(gen_insn_path)', ],
429           'outputs': [
430             '<(shared_generated_dir)/x86insns.c',
431             '<(shared_generated_dir)/x86insn_gas.gperf',
432             '<(shared_generated_dir)/x86insn_nasm.gperf',
433           ],
434           'action': [
435             'python',
436             '<(gen_insn_path)',
437             '<(shared_generated_dir)',
438           ],
439           'message': 'Running <(gen_insn_path)',
440           'process_outputs_as_sources': 0,
441         },
442         {
443           'action_name': 'generate_version',
444           'inputs': [ '<(PRODUCT_DIR)/'
445                       '<(EXECUTABLE_PREFIX)genversion<(EXECUTABLE_SUFFIX)' ],
446           'outputs': [ '<(shared_generated_dir)/<(version_file)', ],
447           'action': [
448             '<(PRODUCT_DIR)/genversion',
449             '<(shared_generated_dir)/<(version_file)'
450           ],
451           'message': 'Generating yasm version file: '
452                      '<(shared_generated_dir)/<(version_file)',
453           'process_outputs_as_sources': 0,
454         },
455       ],
456     },
457     {
458       'target_name': 'genperf_libs',
459       'type': 'static_library',
460       'toolsets': ['host'],
461       'dependencies': [ 'config_sources', ],
462       'sources': [
463          'source/patched-yasm/libyasm/phash.c',
464          'source/patched-yasm/libyasm/xmalloc.c',
465          'source/patched-yasm/libyasm/xstrdup.c',
466       ],
467       'include_dirs': [
468         '<@(yasm_include_dirs)',
469       ],
470       'defines': [ '<@(yasm_defines)' ],
471       'cflags': [
472         '<@(yasm_cflags)',
473       ],
474     },
475     {
476       'target_name': 'genstring',
477       'type': 'executable',
478       'toolsets': ['host'],
479       'dependencies': [ 'config_sources', ],
480       'sources': [
481          'source/patched-yasm/genstring.c',
482       ],
483       'include_dirs': [
484         '<@(yasm_include_dirs)',
485       ],
486       'cflags': [
487         '-std=gnu99',
488       ],
489     },
490     {
491       'target_name': 'genperf',
492       'type': 'executable',
493       'toolsets': ['host'],
494       'dependencies': [
495         'genperf_libs',
496       ],
497       'sources': [
498          'source/patched-yasm/tools/genperf/genperf.c',
499          'source/patched-yasm/tools/genperf/perfect.c',
500       ],
501       'include_dirs': [
502         '<@(yasm_include_dirs)',
503       ],
504       'cflags': [
505         '-std=gnu99',
506       ],
507     },
508     {
509       'target_name': 'genmacro',
510       'type': 'executable',
511       'toolsets': ['host'],
512       'dependencies': [ 'config_sources', ],
513       'sources': [
514         'source/patched-yasm/tools/genmacro/genmacro.c',
515       ],
516       'include_dirs': [
517         '<@(yasm_include_dirs)',
518       ],
519       'cflags': [
520         '-std=gnu99',
521       ],
522     },
523     {
524       'target_name': 'genversion',
525       'type': 'executable',
526       'toolsets': ['host'],
527       'dependencies': [ 'config_sources', ],
528       'sources': [
529          'source/patched-yasm/modules/preprocs/nasm/genversion.c',
530       ],
531       'include_dirs': [
532         '<@(yasm_include_dirs)',
533       ],
534       'cflags': [
535         '-std=gnu99',
536       ],
537     },
538     {
539       'target_name': 're2c',
540       'type': 'executable',
541       'toolsets': ['host'],
542       'dependencies': [ 'config_sources', ],
543       'sources': [
544          'source/patched-yasm/tools/re2c/main.c',
545          'source/patched-yasm/tools/re2c/code.c',
546          'source/patched-yasm/tools/re2c/dfa.c',
547          'source/patched-yasm/tools/re2c/parser.c',
548          'source/patched-yasm/tools/re2c/actions.c',
549          'source/patched-yasm/tools/re2c/scanner.c',
550          'source/patched-yasm/tools/re2c/mbo_getopt.c',
551          'source/patched-yasm/tools/re2c/substr.c',
552          'source/patched-yasm/tools/re2c/translate.c',
553       ],
554       'include_dirs': [
555         '<@(yasm_include_dirs)',
556       ],
557       'cflags': [
558         '-std=gnu99',
559       ],
560       'variables': {
561         'clang_warning_flags': [
562           # re2c is missing CLOSEVOP from one switch.
563           '-Wno-switch',
564           # re2c contains many static functions in headers (because it's
565           # a C library predating C99.)
566           '-Wno-unused-function',
567         ],
568       },
569       'msvs_disabled_warnings': [ 4267 ],
570     },
571     {
572       'target_name': 'genmodule',
573       'type': 'executable',
574       'toolsets': ['host'],
575       'dependencies': [
576         'config_sources',
577       ],
578       'sources': [
579         'source/patched-yasm/libyasm/genmodule.c',
580       ],
581       'include_dirs': [
582         '<@(yasm_include_dirs)',
584       ],
585       'cflags': [
586         '-std=gnu99',
587       ],
588     },
589   ],