Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 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. | |
| 4 | |
| 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. | |
| 8 # | |
| 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) | |
| 14 # | |
| 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) yasm_config -- General build configuration including setting a | |
| 19 # source_prereqs listing the checked in version of files | |
| 20 # generated by manually running configure. These manually | |
| 21 # generated files are used by all binaries. | |
| 22 # 3) yasm_libs -- Object files with memory management and hashing utilities | |
| 23 # shared between yasm and the genperf subprogram. | |
| 24 # 4) genmacro, genmodule, etc. -- One executable target for each subprogram. | |
| 25 # 5) generate_license, generate_module, etc. -- Actions that invoke programs | |
| 26 # built in #4 to generate .c files. | |
| 27 # 6) compile_gperf, compile_re2c, etc. -- Actions that invoke programs that | |
| 28 # turn intermediate files into .c files. | |
| 29 | |
| 30 if (default_toolchain == host_toolchain) { | |
| 31 | |
| 32 # Various files referenced by multiple targets. | |
| 33 yasm_gen_include_dir = "$target_gen_dir/include" | |
| 34 config_makefile = "source/config/$os/Makefile" | |
| 35 version_file = "version.mac" | |
| 36 | |
| 37 import("//build/gn_helper_scripts.gni") | |
| 38 | |
| 39 config("yasm_config") { | |
| 40 include_dirs = [ | |
| 41 "source/config/$os", | |
| 42 "source/patched-yasm", | |
| 43 ] | |
| 44 source_prereqs = [ | |
| 45 config_makefile, | |
| 46 "source/config/$os/config.h", | |
| 47 "source/config/$os/libyasm-stdint.h", | |
| 48 ] | |
| 49 defines = [ "HAVE_CONFIG_H" ] | |
| 50 cflags = [ "-std=gnu99" ] | |
| 51 } | |
| 52 | |
| 53 executable("genmacro") { | |
| 54 sources = [ "source/patched-yasm/tools/genmacro/genmacro.c" ] | |
| 55 configs -= [ "//build/config/compiler:chromium_code" ] | |
|
brettw
2014/05/05 16:46:50
Can you add back "no_chromium_code". Same in other
awong
2014/05/05 19:28:34
Done.
| |
| 56 configs += [ ":yasm_config" ] | |
| 57 } | |
| 58 | |
| 59 executable("genmodule") { | |
| 60 sources = [ "source/patched-yasm/libyasm/genmodule.c" ] | |
| 61 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 62 configs += [ ":yasm_config" ] | |
| 63 } | |
| 64 | |
| 65 executable("genperf") { | |
| 66 sources = [ | |
| 67 "source/patched-yasm/tools/genperf/genperf.c", | |
| 68 "source/patched-yasm/tools/genperf/perfect.c", | |
| 69 ] | |
| 70 | |
| 71 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 72 configs += [ ":yasm_config" ] | |
| 73 | |
| 74 deps = [ ":yasm_libs" ] | |
| 75 } | |
| 76 | |
| 77 # Used by both yasm and genperf binaries. | |
| 78 source_set("yasm_libs") { | |
| 79 sources = [ | |
| 80 "source/patched-yasm/libyasm/phash.c", | |
| 81 "source/patched-yasm/libyasm/xmalloc.c", | |
| 82 "source/patched-yasm/libyasm/xstrdup.c", | |
| 83 ] | |
| 84 | |
| 85 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 86 configs += [ ":yasm_config" ] | |
| 87 } | |
| 88 | |
| 89 executable("genstring") { | |
| 90 sources = [ "source/patched-yasm/genstring.c", ] | |
| 91 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 92 configs += [ ":yasm_config" ] | |
| 93 } | |
| 94 | |
| 95 executable("genversion") { | |
| 96 sources = [ "source/patched-yasm/modules/preprocs/nasm/genversion.c" ] | |
| 97 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 98 configs += [ ":yasm_config" ] | |
| 99 } | |
| 100 | |
| 101 executable("re2c") { | |
| 102 sources = [ | |
| 103 "source/patched-yasm/tools/re2c/main.c", | |
| 104 "source/patched-yasm/tools/re2c/code.c", | |
| 105 "source/patched-yasm/tools/re2c/dfa.c", | |
| 106 "source/patched-yasm/tools/re2c/parser.c", | |
| 107 "source/patched-yasm/tools/re2c/actions.c", | |
| 108 "source/patched-yasm/tools/re2c/scanner.c", | |
| 109 "source/patched-yasm/tools/re2c/mbo_getopt.c", | |
| 110 "source/patched-yasm/tools/re2c/substr.c", | |
| 111 "source/patched-yasm/tools/re2c/translate.c", | |
| 112 ] | |
| 113 | |
| 114 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 115 configs += [ ":yasm_config" ] | |
| 116 | |
| 117 # re2c is missing CLOSEVOP from one switch. | |
| 118 cflags = [ "-Wno-switch" ] | |
| 119 } | |
| 120 | |
| 121 executable("yasm") { | |
| 122 sources = [ | |
| 123 "source/patched-yasm/frontends/yasm/yasm-options.c", | |
| 124 "source/patched-yasm/frontends/yasm/yasm.c", | |
| 125 "source/patched-yasm/libyasm/assocdat.c", | |
| 126 "source/patched-yasm/libyasm/bc-align.c", | |
| 127 "source/patched-yasm/libyasm/bc-data.c", | |
| 128 "source/patched-yasm/libyasm/bc-incbin.c", | |
| 129 "source/patched-yasm/libyasm/bc-org.c", | |
| 130 "source/patched-yasm/libyasm/bc-reserve.c", | |
| 131 "source/patched-yasm/libyasm/bitvect.c", | |
| 132 "source/patched-yasm/libyasm/bytecode.c", | |
| 133 "source/patched-yasm/libyasm/errwarn.c", | |
| 134 "source/patched-yasm/libyasm/expr.c", | |
| 135 "source/patched-yasm/libyasm/file.c", | |
| 136 "source/patched-yasm/libyasm/floatnum.c", | |
| 137 "source/patched-yasm/libyasm/hamt.c", | |
| 138 "source/patched-yasm/libyasm/insn.c", | |
| 139 "source/patched-yasm/libyasm/intnum.c", | |
| 140 "source/patched-yasm/libyasm/inttree.c", | |
| 141 "source/patched-yasm/libyasm/linemap.c", | |
| 142 "source/patched-yasm/libyasm/md5.c", | |
| 143 "source/patched-yasm/libyasm/mergesort.c", | |
| 144 "source/patched-yasm/libyasm/section.c", | |
| 145 "source/patched-yasm/libyasm/strcasecmp.c", | |
| 146 "source/patched-yasm/libyasm/strsep.c", | |
| 147 "source/patched-yasm/libyasm/symrec.c", | |
| 148 "source/patched-yasm/libyasm/valparam.c", | |
| 149 "source/patched-yasm/libyasm/value.c", | |
| 150 "source/patched-yasm/modules/arch/lc3b/lc3barch.c", | |
| 151 "source/patched-yasm/modules/arch/lc3b/lc3bbc.c", | |
| 152 "source/patched-yasm/modules/arch/x86/x86arch.c", | |
| 153 "source/patched-yasm/modules/arch/x86/x86bc.c", | |
| 154 "source/patched-yasm/modules/arch/x86/x86expr.c", | |
| 155 "source/patched-yasm/modules/arch/x86/x86id.c", | |
| 156 "source/patched-yasm/modules/dbgfmts/codeview/cv-dbgfmt.c", | |
| 157 "source/patched-yasm/modules/dbgfmts/codeview/cv-symline.c", | |
| 158 "source/patched-yasm/modules/dbgfmts/codeview/cv-type.c", | |
| 159 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-aranges.c", | |
| 160 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c", | |
| 161 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-info.c", | |
| 162 "source/patched-yasm/modules/dbgfmts/dwarf2/dwarf2-line.c", | |
| 163 "source/patched-yasm/modules/dbgfmts/null/null-dbgfmt.c", | |
| 164 "source/patched-yasm/modules/dbgfmts/stabs/stabs-dbgfmt.c", | |
| 165 "source/patched-yasm/modules/listfmts/nasm/nasm-listfmt.c", | |
| 166 "source/patched-yasm/modules/objfmts/bin/bin-objfmt.c", | |
| 167 "source/patched-yasm/modules/objfmts/coff/coff-objfmt.c", | |
| 168 "source/patched-yasm/modules/objfmts/coff/win64-except.c", | |
| 169 "source/patched-yasm/modules/objfmts/dbg/dbg-objfmt.c", | |
| 170 "source/patched-yasm/modules/objfmts/elf/elf-objfmt.c", | |
| 171 "source/patched-yasm/modules/objfmts/elf/elf-x86-amd64.c", | |
| 172 "source/patched-yasm/modules/objfmts/elf/elf-x86-x86.c", | |
| 173 "source/patched-yasm/modules/objfmts/elf/elf.c", | |
| 174 "source/patched-yasm/modules/objfmts/macho/macho-objfmt.c", | |
| 175 "source/patched-yasm/modules/objfmts/rdf/rdf-objfmt.c", | |
| 176 "source/patched-yasm/modules/objfmts/xdf/xdf-objfmt.c", | |
| 177 "source/patched-yasm/modules/parsers/gas/gas-parse.c", | |
| 178 "source/patched-yasm/modules/parsers/gas/gas-parse-intel.c", | |
| 179 "source/patched-yasm/modules/parsers/gas/gas-parser.c", | |
| 180 "source/patched-yasm/modules/parsers/nasm/nasm-parse.c", | |
| 181 "source/patched-yasm/modules/parsers/nasm/nasm-parser.c", | |
| 182 "source/patched-yasm/modules/preprocs/cpp/cpp-preproc.c", | |
| 183 "source/patched-yasm/modules/preprocs/nasm/nasm-eval.c", | |
| 184 "source/patched-yasm/modules/preprocs/nasm/nasm-pp.c", | |
| 185 "source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c", | |
| 186 "source/patched-yasm/modules/preprocs/nasm/nasmlib.c", | |
| 187 "source/patched-yasm/modules/preprocs/raw/raw-preproc.c", | |
| 188 | |
| 189 # Files generated by compile_gperf | |
| 190 "$target_gen_dir/x86cpu.c", | |
| 191 "$target_gen_dir/x86regtmod.c", | |
| 192 | |
| 193 # Files generated by compile_re2c | |
| 194 "$target_gen_dir/gas-token.c", | |
| 195 "$target_gen_dir/nasm-token.c", | |
| 196 | |
| 197 # File generated by compile_re2c_lc3b | |
| 198 "$target_gen_dir/lc3bid.c", | |
| 199 | |
| 200 # File generated by generate_module | |
| 201 "$target_gen_dir/module.c" | |
| 202 ] | |
| 203 | |
| 204 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 205 configs += [ ":yasm_config" ] | |
| 206 | |
| 207 # Yasm generates a bunch of .c files which its source file #include. | |
| 208 # Add the |target_gen_dir| into the include path so it can find them. | |
| 209 # Ideally, these generated .c files would be placed into a separate | |
| 210 # directory, but the gen_x86_insn.py script does not make this easy. | |
| 211 include_dirs = [ yasm_gen_include_dir ] | |
| 212 | |
| 213 cflags = [ "-ansi", "-pedantic" ] | |
| 214 if (is_clang) { | |
| 215 cflags += [ "-Wno-incompatible-pointer-types" ] | |
| 216 } | |
| 217 | |
| 218 # TODO(ajwong): This should take most of the generated output as | |
| 219 # source_prereqs. | |
| 220 deps = [ | |
| 221 ":compile_gperf", | |
| 222 ":compile_gperf_for_include", | |
| 223 ":compile_nasm_macros", | |
| 224 ":compile_nasm_version", | |
| 225 ":compile_win64_gas", | |
| 226 ":compile_win64_nasm", | |
| 227 ":compile_re2c", | |
| 228 ":generate_license", | |
| 229 ":generate_module", | |
| 230 ":generate_version", | |
| 231 ":yasm_libs", | |
| 232 ] | |
| 233 } | |
| 234 | |
| 235 run_executable_foreach("compile_gperf") { | |
| 236 sources = [ | |
| 237 "source/patched-yasm/modules/arch/x86/x86cpu.gperf", | |
| 238 "source/patched-yasm/modules/arch/x86/x86regtmod.gperf", | |
| 239 ] | |
| 240 | |
| 241 outputs = [ "$target_gen_dir/{{source_name_part}}.c" ] | |
| 242 binary_name = "genperf" | |
| 243 args = [ | |
| 244 "{{source}}", | |
| 245 rebase_path(target_gen_dir, ".") + "/{{source_name_part}}.c", | |
| 246 ] | |
| 247 deps = [ | |
| 248 ":genperf", | |
| 249 ":generate_x86_insn" | |
| 250 ] | |
| 251 } | |
| 252 | |
| 253 # This differs from |compile_gperf| in where it places it output files. | |
| 254 run_executable_foreach("compile_gperf_for_include") { | |
| 255 sources = [ | |
| 256 # Make sure the generated gperf files in $target_gen_dir are synced with | |
| 257 # the outputs for the related generate_*_insn actions in the | |
| 258 # generate_files target below. | |
| 259 # | |
| 260 # The output for these two are #included by | |
| 261 # source/patched-yasm/modules/arch/x86/x86id.c | |
| 262 "$yasm_gen_include_dir/x86insn_gas.gperf", | |
| 263 "$yasm_gen_include_dir/x86insn_nasm.gperf", | |
| 264 ] | |
| 265 | |
| 266 outputs = [ "$yasm_gen_include_dir/{{source_name_part}}.c" ] | |
| 267 binary_name = "genperf" | |
| 268 args = [ | |
| 269 "{{source}}", | |
| 270 rebase_path(yasm_gen_include_dir, ".") + "/{{source_name_part}}.c", | |
| 271 ] | |
| 272 deps = [ | |
| 273 ":genperf", | |
| 274 ":generate_x86_insn" | |
| 275 ] | |
| 276 } | |
| 277 | |
| 278 template("compile_macro") { | |
| 279 run_executable(target_name) { | |
| 280 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
| 281 sources = invoker.sources | |
| 282 outputs = invoker.outputs | |
| 283 binary_name = "genmacro" | |
| 284 args = [ | |
| 285 rebase_path(outputs[0], root_build_dir), | |
| 286 invoker.macro_varname, | |
| 287 rebase_path(sources[0], root_build_dir), | |
| 288 ] | |
| 289 deps = [ ":genmacro" ] | |
| 290 if (defined(invoker.deps)) { | |
| 291 deps += invoker.deps | |
| 292 } | |
| 293 } | |
| 294 } | |
| 295 | |
| 296 compile_macro("compile_nasm_macros") { | |
| 297 # Output #included by | |
| 298 # source/patched-yasm/modules/preprocs/nasm/nasm-parser.c | |
| 299 sources = [ "source/patched-yasm/modules/parsers/nasm/nasm-std.mac" ] | |
| 300 outputs = [ "$yasm_gen_include_dir/nasm-macros.c" ] | |
| 301 macro_varname = "nasm_standard_mac" | |
| 302 } | |
| 303 | |
| 304 compile_macro("compile_nasm_version") { | |
| 305 # Output #included by | |
| 306 # source/patched-yasm/modules/preprocs/nasm/nasm-preproc.c | |
| 307 sources = [ "$target_gen_dir/$version_file" ] | |
| 308 outputs = [ "$yasm_gen_include_dir/nasm-version.c" ] | |
| 309 macro_varname = "nasm_version_mac" | |
| 310 deps = [ ":generate_version" ] | |
| 311 } | |
| 312 | |
| 313 compile_macro("compile_win64_gas") { | |
| 314 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
| 315 sources = [ "source/patched-yasm/modules/objfmts/coff/win64-gas.mac" ] | |
| 316 outputs = [ "$yasm_gen_include_dir/win64-gas.c" ] | |
| 317 macro_varname = "win64_gas_stdmac" | |
| 318 } | |
| 319 | |
| 320 compile_macro("compile_win64_nasm") { | |
| 321 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
| 322 sources = [ "source/patched-yasm/modules/objfmts/coff/win64-nasm.mac" ] | |
| 323 outputs = [ "$yasm_gen_include_dir/win64-nasm.c" ] | |
| 324 macro_varname = "win64_nasm_stdmac" | |
| 325 } | |
| 326 | |
| 327 run_executable_foreach("compile_re2c") { | |
| 328 sources = [ | |
| 329 "source/patched-yasm/modules/parsers/gas/gas-token.re", | |
| 330 "source/patched-yasm/modules/parsers/nasm/nasm-token.re", | |
| 331 ] | |
| 332 outputs = [ "$target_gen_dir/{{source_name_part}}.c" ] | |
| 333 binary_name = "re2c" | |
| 334 args = [ | |
| 335 "-b", | |
| 336 "-o", | |
| 337 rebase_path(target_gen_dir, ".") + "/{{source_name_part}}.c", | |
| 338 "{{source}}", | |
| 339 ] | |
| 340 deps = [ ":re2c" ] | |
| 341 } | |
| 342 | |
| 343 # This call doesn't fit into the re2c template above. | |
| 344 run_executable("compile_re2c_lc3b") { | |
| 345 sources = [ "source/patched-yasm/modules/arch/lc3b/lc3bid.re" ] | |
| 346 outputs = [ "$target_gen_dir/lc3bid.c" ] | |
| 347 binary_name = "re2c" | |
| 348 args = [ | |
| 349 "-s", | |
| 350 "-o", | |
| 351 rebase_path(outputs[0], root_build_dir), | |
| 352 rebase_path(sources[0], root_build_dir), | |
| 353 ] | |
| 354 deps = [ ":re2c" ] | |
| 355 } | |
| 356 | |
| 357 run_executable("generate_license") { | |
| 358 # Output #included by source/patched-yasm/frontends/yasm/yasm.c. | |
| 359 sources = [ "source/patched-yasm/COPYING" ] | |
| 360 outputs = [ "$yasm_gen_include_dir/license.c" ] | |
| 361 binary_name = "genstring" | |
| 362 args = [ | |
| 363 "license_msg", | |
| 364 rebase_path(outputs[0], root_build_dir), | |
| 365 rebase_path(sources[0], root_build_dir), | |
| 366 ] | |
| 367 | |
| 368 deps = [ ":genstring" ] | |
| 369 } | |
| 370 | |
| 371 run_executable("generate_module") { | |
| 372 sources = [ "source/patched-yasm/libyasm/module.in" ] | |
| 373 outputs = [ "$target_gen_dir/module.c" ] | |
| 374 binary_name = "genmodule" | |
| 375 args = [ | |
| 376 rebase_path(sources[0], root_build_dir), | |
| 377 rebase_path(config_makefile, root_build_dir), | |
| 378 rebase_path(outputs[0], root_build_dir), | |
| 379 ] | |
| 380 deps = [ ":genmodule" ] | |
| 381 } | |
| 382 | |
| 383 run_executable("generate_version") { | |
| 384 outputs = [ "$target_gen_dir/$version_file" ] | |
| 385 binary_name = "genversion" | |
| 386 args = [ | |
| 387 rebase_path(outputs[0], | |
| 388 root_build_dir) | |
| 389 ] | |
| 390 deps = [ ":genversion" ] | |
| 391 } | |
| 392 | |
| 393 action("generate_x86_insn") { | |
| 394 script = "source/patched-yasm/modules/arch/x86/gen_x86_insn.py" | |
| 395 # Output eventually #included by source/patched-yasm/frontends/yasm/x86id.c | |
| 396 outputs = [ | |
| 397 "$yasm_gen_include_dir/x86insns.c", | |
| 398 "$yasm_gen_include_dir/x86insn_gas.gperf", | |
| 399 "$yasm_gen_include_dir/x86insn_nasm.gperf", | |
| 400 ] | |
| 401 args = [ rebase_path(yasm_gen_include_dir, root_build_dir) ] | |
| 402 } | |
| 403 | |
| 404 } | |
| OLD | NEW |