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