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

Side by Side Diff: third_party/yasm/yasm_assemble.gni

Issue 266613002: Add BUILD.gn for third_party/yasm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yasm yasm yasm 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
« third_party/yasm/BUILD.gn ('K') | « third_party/yasm/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # This provides the yasm_assemble() template which uses YASM to assemble
6 # assembly files.
7 #
8 # Files to be assembled with YASM should have an extension of .asm.
9 #
10 # There are three variables with this template:
11 # yasm_flags : Pass additional flags into YASM.
12 # yasm_output_path : Output directory for the compiled object files.
13 # yasm_includes : Includes used by .asm code. Changes to which should force
14 # recompilation.
15 #
16 # Sample usage:
17 # yasm_assemble("my_yasm_target") {
18 # sources = [ "ultra_optimized_awesome.asm" ]
19 # yasm_flags = [ "-I", "assembly_include", ],
20 # yasm_output_path = "$target_gen_dir/project"
21 # yasm_includes = [ "ultra_optimized_awesome.inc" ]
22 # }
23
24 import("//build/gn_helper_scripts.gni")
25
26 template("yasm_assemble") {
27 # TODO(ajwong): Support use_system_yasm.
28
29 if (is_mac || is_ios) {
brettw 2014/05/09 20:17:54 Do you think this file will be used a lot? If so,
brettw 2014/05/09 20:56:56 Oh: prefix the names with _ if you do this so they
awong 2014/05/10 08:55:34 Should GN generate a warning or error on a shadow
awong 2014/05/10 08:55:34 It's not super common, but moved it out anyways.
30 if (cpu_arch == "x86") {
31 yasm_flags = [
32 "-fmacho32",
33 "-m", "x86",
34 ]
35 } else if (cpu_arch == "x64") {
36 yasm_flags = [
37 "-fmacho64",
38 "-m", "amd64",
39 ]
40 }
41 } else if (is_posix) {
42 if (cpu_arch == "x86") {
43 yasm_flags = [
44 "-felf32",
45 "-m", "x86",
46 ]
47 } else if (cpu_arch == "x64") {
48 yasm_flags = [
49 "-DPIC",
50 "-felf64",
51 "-m", "amd64",
52 ]
53 }
54 } else if (is_win) {
55 if (cpu_arch == "x86") {
56 yasm_flags = [
57 "-DPREFIX",
58 "-fwin32",
59 "-m", "x86",
60 ]
61 } else if (cpu_arch == "x64") {
62 yasm_flags = [
63 "-fwin64",
64 "-m", "amd64",
65 ]
66 }
67 }
68
69 if (is_win) {
70 asm_obj_extension = "obj"
71 } else {
72 asm_obj_extension = "o"
73 }
74
75 assert(defined(invoker.yasm_output_path))
76 yasm_output_path = invoker.yasm_output_path
77
78 source_set(target_name) {
79 sources = process_file_template(
80 invoker.sources,
81 "$yasm_output_path/{{source_name_part}}.o")
82 deps = [ ":${target_name}_yasm" ]
83 }
84
85 run_executable_foreach("${target_name}_yasm") {
86 sources = invoker.sources
87 binary_name = "yasm"
brettw 2014/05/09 20:17:54 While this works for the main toolchain, it won't
awong 2014/05/10 08:55:34 I think I finally understand enough to make this w
88 outputs = [ "$yasm_output_path/{{source_name_part}}.$asm_obj_extension" ]
89 args = yasm_flags
90 if (defined(invoker.yasm_flags)) {
91 args += invoker.yasm_flags
92 }
93 args += [
94 "-o", rebase_path(outputs[0], root_build_dir),
95 "{{source}}"
96 ]
97
98 if (defined(invoker.yasm_includes)) {
99 source_prereqs = rebase_path(invoker.yasm_includes, root_build_dir)
100 }
101
102 # Only depend on YASM on x86 systems. Force compilation of .asm files for
103 # ARM to fail.
104 assert(cpu_arch == "x86" || cpu_arch == "x64")
105 deps = [ "//third_party/yasm($host_toolchain)" ]
106 }
107 }
OLDNEW
« third_party/yasm/BUILD.gn ('K') | « third_party/yasm/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698