Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/yasm/BUILD.gn

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

Powered by Google App Engine
This is Rietveld 408576698