File: BUILD.gn

package info (click to toggle)
qtwebengine-opensource-src 5.7.1%2Bdfsg-6.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,028,096 kB
  • ctags: 1,436,736
  • sloc: cpp: 5,960,176; ansic: 3,477,727; asm: 395,492; python: 320,633; sh: 96,504; perl: 69,449; xml: 42,977; makefile: 28,408; objc: 9,962; yacc: 9,847; tcl: 5,430; lex: 2,259; ruby: 1,053; lisp: 522; awk: 497; pascal: 310; cs: 249; sed: 53
file content (513 lines) | stat: -rw-r--r-- 16,107 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# The yasm build process creates a slew of small C subprograms that
# dynamically generate files at various point in the build process.  This makes
# the build integration moderately complex.
#
# There are three classes of dynamically generated files:
#   1) C source files that should be included in the build (eg., lc3bid.c)
#   2) C source files that are #included by static C sources (eg., license.c)
#   3) Intermediate files that are used as input by other subprograms to
#      further generate files in category #1 or #2.  (eg., version.mac)
#
# This structure is represented with the following targets:
#   1) yasm -- Sources, flags for the main yasm executable. Also has most of
#              of the actions and rules that invoke the subprograms.
#   2) yasm_config -- General build configuration including setting a
#              inputs listing the checked in version of files
#              generated by manually running configure. These manually
#              generated files are used by all binaries.
#   3) yasm_utils -- Object files with memory management and hashing utilities
#              shared between yasm and the genperf subprogram.
#   4) genmacro, genmodule, etc. -- One executable target for each subprogram.
#   5) generate_license, generate_module, etc. -- Actions that invoke programs
#              built in #4 to generate .c files.
#   6) compile_gperf, compile_re2c, etc. -- Actions that invoke programs that
#              turn intermediate files into .c files.

if (current_toolchain == host_toolchain) {
  # Various files referenced by multiple targets.
  yasm_gen_include_dir = "$target_gen_dir/include"
  config_makefile = "source/config/$host_os/Makefile"
  version_file = "version.mac"

  import("//build/compiled_action.gni")

  config("yasm_config") {
    include_dirs = [
      "source/config/$host_os",
      "source/patched-yasm",
    ]
    defines = [ "HAVE_CONFIG_H" ]
    if (is_posix) {
      cflags = [ "-std=gnu99" ]
    }
  }

  executable("genmacro") {
    sources = [
      "source/patched-yasm/tools/genmacro/genmacro.c",
    ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",
    ]
    deps = [
      "//build/config/sanitizers:deps",
    ]
  }

  executable("genmodule") {
    sources = [
      "source/patched-yasm/libyasm/genmodule.c",
    ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",
    ]
    deps = [
      "//build/config/sanitizers:deps",
    ]
  }

  executable("genperf") {
    sources = [
      "source/patched-yasm/tools/genperf/genperf.c",
      "source/patched-yasm/tools/genperf/perfect.c",
    ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",
    ]

    deps = [
      ":yasm_utils",
      "//build/config/sanitizers:deps",
    ]
  }

  # Used by both yasm and genperf binaries.
  source_set("yasm_utils") {
    sources = [
      "source/patched-yasm/libyasm/phash.c",
      "source/patched-yasm/libyasm/xmalloc.c",
      "source/patched-yasm/libyasm/xstrdup.c",
    ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",
    ]
  }

  executable("genstring") {
    sources = [
      "source/patched-yasm/genstring.c",
    ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",
    ]
    deps = [
      "//build/config/sanitizers:deps",
    ]
  }

  executable("genversion") {
    sources = [
      "source/patched-yasm/modules/preprocs/nasm/genversion.c",
    ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",
    ]
    deps = [
      "//build/config/sanitizers:deps",
    ]
  }

  config("re2c_warnings") {
    # re2c is missing CLOSEVOP from one switch.
    if (is_clang) {
      cflags = [
        # re2c is missing CLOSEVOP from one switch.
        "-Wno-switch",

        # re2c contains many static functions in headers (because it's
        # a C library predating C99.)
        "-Wno-unused-function",
      ]
    }
  }

  executable("re2c") {
    sources = [
      "source/patched-yasm/tools/re2c/actions.c",
      "source/patched-yasm/tools/re2c/code.c",
      "source/patched-yasm/tools/re2c/dfa.c",
      "source/patched-yasm/tools/re2c/main.c",
      "source/patched-yasm/tools/re2c/mbo_getopt.c",
      "source/patched-yasm/tools/re2c/parser.c",
      "source/patched-yasm/tools/re2c/scanner.c",
      "source/patched-yasm/tools/re2c/substr.c",
      "source/patched-yasm/tools/re2c/translate.c",
    ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",

      # Must be after no_chromium_code for warning flags to be ordered
      # correctly.
      ":re2c_warnings",
    ]
    deps = [
      "//build/config/sanitizers:deps",
    ]
  }

  config("yasm_warnings") {
    if (is_clang) {
      cflags = [
        # reg3264type in x86expr.c is unused.
        "-Wno-unused-local-typedef",
      ]
    }
  }

  executable("yasm") {
    sources = [
      "source/patched-yasm/frontends/yasm/yasm-options.c",
      "source/patched-yasm/frontends/yasm/yasm.c",
      "source/patched-yasm/libyasm/assocdat.c",
      "source/patched-yasm/libyasm/bc-align.c",
      "source/patched-yasm/libyasm/bc-data.c",
      "source/patched-yasm/libyasm/bc-incbin.c",
      "source/patched-yasm/libyasm/bc-org.c",
      "source/patched-yasm/libyasm/bc-reserve.c",
      "source/patched-yasm/libyasm/bitvect.c",
      "source/patched-yasm/libyasm/bytecode.c",
      "source/patched-yasm/libyasm/errwarn.c",
      "source/patched-yasm/libyasm/expr.c",
      "source/patched-yasm/libyasm/file.c",
      "source/patched-yasm/libyasm/floatnum.c",
      "source/patched-yasm/libyasm/hamt.c",
      "source/patched-yasm/libyasm/insn.c",
      "source/patched-yasm/libyasm/intnum.c",
      "source/patched-yasm/libyasm/inttree.c",
      "source/patched-yasm/libyasm/linemap.c",
      "source/patched-yasm/libyasm/md5.c",
      "source/patched-yasm/libyasm/mergesort.c",
      "source/patched-yasm/libyasm/section.c",
      "source/patched-yasm/libyasm/strcasecmp.c",
      "source/patched-yasm/libyasm/strsep.c",
      "source/patched-yasm/libyasm/symrec.c",
      "source/patched-yasm/libyasm/valparam.c",
      "source/patched-yasm/libyasm/value.c",
      "source/patched-yasm/modules/arch/lc3b/lc3barch.c",
      "source/patched-yasm/modules/arch/lc3b/lc3bbc.c",
      "source/patched-yasm/modules/arch/x86/x86arch.c",
      "source/patched-yasm/modules/arch/x86/x86bc.c",
      "source/patched-yasm/modules/arch/x86/x86expr.c",
      "source/patched-yasm/modules/arch/x86/x86id.c",
      "source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c",
      "source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c",
      "source/patched-yasm/modules/dbgfmts/codeview/cv-type.c",
      "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c",
      "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c",
      "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c",
      "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c",
      "source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c",
      "source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c",
      "source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c",
      "source/patched-yasm/modules/objfmts/bin/bin-objfmt.c",
      "source/patched-yasm/modules/objfmts/coff/coff-objfmt.c",
      "source/patched-yasm/modules/objfmts/coff/win64-except.c",
      "source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c",
      "source/patched-yasm/modules/objfmts/elf/elf-objfmt.c",
      "source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c",
      "source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c",
      "source/patched-yasm/modules/objfmts/elf/elf.c",
      "source/patched-yasm/modules/objfmts/macho/macho-objfmt.c",
      "source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c",
      "source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c",
      "source/patched-yasm/modules/parsers/gas/gas-parse-intel.c",
      "source/patched-yasm/modules/parsers/gas/gas-parse.c",
      "source/patched-yasm/modules/parsers/gas/gas-parser.c",
      "source/patched-yasm/modules/parsers/nasm/nasm-parse.c",
      "source/patched-yasm/modules/parsers/nasm/nasm-parser.c",
      "source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c",
      "source/patched-yasm/modules/preprocs/nasm/nasm-eval.c",
      "source/patched-yasm/modules/preprocs/nasm/nasm-pp.c",
      "source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c",
      "source/patched-yasm/modules/preprocs/nasm/nasmlib.c",
      "source/patched-yasm/modules/preprocs/raw/raw-preproc.c",

      # Files generated by compile_gperf
      "$target_gen_dir/x86cpu.c",
      "$target_gen_dir/x86regtmod.c",

      # Files generated by compile_re2c
      "$target_gen_dir/gas-token.c",
      "$target_gen_dir/nasm-token.c",

      # File generated by compile_re2c_lc3b
      "$target_gen_dir/lc3bid.c",

      # File generated by generate_module
      "$target_gen_dir/module.c",
    ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [
      ":yasm_config",
      "//build/config/compiler:no_chromium_code",
      "//build/config/compiler:no_incompatible_pointer_warnings",

      # Must be after no_chromium_code for warning flags to be ordered
      # correctly.
      ":yasm_warnings",
    ]

    # Yasm generates a bunch of .c files which its source file #include.
    # Add the |target_gen_dir| into the include path so it can find them.
    # Ideally, these generated .c files would be placed into a separate
    # directory, but the gen_x86_insn.py script does not make this easy.
    include_dirs = [ yasm_gen_include_dir ]

    if (!is_win) {
      cflags = [
        "-ansi",
        "-pedantic",
      ]
    }

    # TODO(ajwong): This should take most of the generated output as
    # inputs.
    deps = [
      ":compile_gperf",
      ":compile_gperf_for_include",
      ":compile_nasm_macros",
      ":compile_nasm_version",
      ":compile_re2c",
      ":compile_re2c_lc3b",
      ":compile_win64_gas",
      ":compile_win64_nasm",
      ":generate_license",
      ":generate_module",
      ":generate_version",
      ":yasm_utils",
      "//build/config/sanitizers:deps",
    ]
  }

  compiled_action_foreach("compile_gperf") {
    tool = ":genperf"
    sources = [
      "source/patched-yasm/modules/arch/x86/x86cpu.gperf",
      "source/patched-yasm/modules/arch/x86/x86regtmod.gperf",
    ]

    outputs = [
      "$target_gen_dir/{{source_name_part}}.c",
    ]
    args = [
      "{{source}}",
      rebase_path(target_gen_dir, root_build_dir) + "/{{source_name_part}}.c",
    ]
    deps = [
      ":generate_x86_insn",
    ]
  }

  # This differs from |compile_gperf| in where it places it output files.
  compiled_action_foreach("compile_gperf_for_include") {
    tool = ":genperf"
    sources = [
      # Make sure the generated gperf files in $target_gen_dir are synced with
      # the outputs for the related generate_*_insn actions in the
      # generate_files target below.
      #
      # The output for these two are #included by
      #   source/patched-yasm/modules/arch/x86/x86id.c
      "$yasm_gen_include_dir/x86insn_gas.gperf",
      "$yasm_gen_include_dir/x86insn_nasm.gperf",
    ]

    outputs = [
      "$yasm_gen_include_dir/{{source_name_part}}.c",
    ]
    args = [
      "{{source}}",
      rebase_path(yasm_gen_include_dir, root_build_dir) +
          "/{{source_name_part}}.c",
    ]
    deps = [
      ":generate_x86_insn",
    ]
  }

  template("compile_macro") {
    compiled_action(target_name) {
      tool = ":genmacro"

      # Output #included by source/patched-yasm/frontends/yasm/yasm.c.
      inputs = invoker.sources
      outputs = invoker.outputs
      args = [
        rebase_path(outputs[0], root_build_dir),
        invoker.macro_varname,
        rebase_path(inputs[0], root_build_dir),
      ]
      if (defined(invoker.deps)) {
        deps = invoker.deps
      }
    }
  }

  compile_macro("compile_nasm_macros") {
    # Output #included by
    #   source/patched-yasm/modules/preprocs/nasm/nasm-parser.c
    sources = [
      "source/patched-yasm/modules/parsers/nasm/nasm-std.mac",
    ]
    outputs = [
      "$yasm_gen_include_dir/nasm-macros.c",
    ]
    macro_varname = "nasm_standard_mac"
  }

  compile_macro("compile_nasm_version") {
    # Output #included by
    #   source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c
    sources = [
      "$target_gen_dir/$version_file",
    ]
    outputs = [
      "$yasm_gen_include_dir/nasm-version.c",
    ]
    macro_varname = "nasm_version_mac"
    deps = [
      ":generate_version",
    ]
  }

  compile_macro("compile_win64_gas") {
    # Output #included by source/patched-yasm/frontends/yasm/yasm.c.
    sources = [
      "source/patched-yasm/modules/objfmts/coff/win64-gas.mac",
    ]
    outputs = [
      "$yasm_gen_include_dir/win64-gas.c",
    ]
    macro_varname = "win64_gas_stdmac"
  }

  compile_macro("compile_win64_nasm") {
    # Output #included by source/patched-yasm/frontends/yasm/yasm.c.
    sources = [
      "source/patched-yasm/modules/objfmts/coff/win64-nasm.mac",
    ]
    outputs = [
      "$yasm_gen_include_dir/win64-nasm.c",
    ]
    macro_varname = "win64_nasm_stdmac"
  }

  compiled_action_foreach("compile_re2c") {
    tool = ":re2c"
    sources = [
      "source/patched-yasm/modules/parsers/gas/gas-token.re",
      "source/patched-yasm/modules/parsers/nasm/nasm-token.re",
    ]
    outputs = [
      "$target_gen_dir/{{source_name_part}}.c",
    ]
    args = [
      "-b",
      "-o",
      rebase_path(target_gen_dir, root_build_dir) + "/{{source_name_part}}.c",
      "{{source}}",
    ]
  }

  # This call doesn't fit into the re2c template above.
  compiled_action("compile_re2c_lc3b") {
    tool = ":re2c"
    inputs = [
      "source/patched-yasm/modules/arch/lc3b/lc3bid.re",
    ]
    outputs = [
      "$target_gen_dir/lc3bid.c",
    ]
    args = [
      "-s",
      "-o",
      rebase_path(outputs[0], root_build_dir),
      rebase_path(inputs[0], root_build_dir),
    ]
  }

  compiled_action("generate_license") {
    tool = ":genstring"

    # Output #included by source/patched-yasm/frontends/yasm/yasm.c.
    inputs = [
      "source/patched-yasm/COPYING",
    ]
    outputs = [
      "$yasm_gen_include_dir/license.c",
    ]
    args = [
      "license_msg",
      rebase_path(outputs[0], root_build_dir),
      rebase_path(inputs[0], root_build_dir),
    ]
  }

  compiled_action("generate_module") {
    tool = ":genmodule"
    inputs = [
      "source/patched-yasm/libyasm/module.in",
      config_makefile,
    ]
    outputs = [
      "$target_gen_dir/module.c",
    ]
    args = [
      rebase_path(inputs[0], root_build_dir),
      rebase_path(config_makefile, root_build_dir),
      rebase_path(outputs[0], root_build_dir),
    ]
  }

  compiled_action("generate_version") {
    tool = ":genversion"
    outputs = [
      "$target_gen_dir/$version_file",
    ]
    args = [ rebase_path(outputs[0], root_build_dir) ]
  }

  action("generate_x86_insn") {
    script = "source/patched-yasm/modules/arch/x86/gen_x86_insn.py"

    # Output eventually #included by source/patched-yasm/frontends/yasm/x86id.c
    outputs = [
      "$yasm_gen_include_dir/x86insns.c",
      "$yasm_gen_include_dir/x86insn_gas.gperf",
      "$yasm_gen_include_dir/x86insn_nasm.gperf",
    ]
    args = [ rebase_path(yasm_gen_include_dir, root_build_dir) ]
  }
}