OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # This provides the yasm_assemble() template which uses YASM to assemble | 5 # This provides the yasm_assemble() template which uses YASM to assemble |
6 # assembly files. | 6 # assembly files. |
7 # | 7 # |
8 # Files to be assembled with YASM should have an extension of .asm. | 8 # Files to be assembled with YASM should have an extension of .asm. |
9 # | 9 # |
10 # Parameters | 10 # Parameters |
(...skipping 27 matching lines...) Expand all Loading... |
38 # sources = [ | 38 # sources = [ |
39 # "ultra_optimized_awesome.asm", | 39 # "ultra_optimized_awesome.asm", |
40 # ] | 40 # ] |
41 # include_dirs = [ "assembly_include" ] | 41 # include_dirs = [ "assembly_include" ] |
42 # } | 42 # } |
43 | 43 |
44 if (is_mac || is_ios) { | 44 if (is_mac || is_ios) { |
45 if (cpu_arch == "x86") { | 45 if (cpu_arch == "x86") { |
46 _yasm_flags = [ | 46 _yasm_flags = [ |
47 "-fmacho32", | 47 "-fmacho32", |
48 "-m", "x86", | 48 "-m", |
| 49 "x86", |
49 ] | 50 ] |
50 } else if (cpu_arch == "x64") { | 51 } else if (cpu_arch == "x64") { |
51 _yasm_flags = [ | 52 _yasm_flags = [ |
52 "-fmacho64", | 53 "-fmacho64", |
53 "-m", "amd64", | 54 "-m", |
| 55 "amd64", |
54 ] | 56 ] |
55 } | 57 } |
56 } else if (is_posix) { | 58 } else if (is_posix) { |
57 if (cpu_arch == "x86") { | 59 if (cpu_arch == "x86") { |
58 _yasm_flags = [ | 60 _yasm_flags = [ |
59 "-felf32", | 61 "-felf32", |
60 "-m", "x86", | 62 "-m", |
| 63 "x86", |
61 ] | 64 ] |
62 } else if (cpu_arch == "x64") { | 65 } else if (cpu_arch == "x64") { |
63 _yasm_flags = [ | 66 _yasm_flags = [ |
64 "-DPIC", | 67 "-DPIC", |
65 "-felf64", | 68 "-felf64", |
66 "-m", "amd64", | 69 "-m", |
| 70 "amd64", |
67 ] | 71 ] |
68 } | 72 } |
69 } else if (is_win) { | 73 } else if (is_win) { |
70 if (cpu_arch == "x86") { | 74 if (cpu_arch == "x86") { |
71 _yasm_flags = [ | 75 _yasm_flags = [ |
72 "-DPREFIX", | 76 "-DPREFIX", |
73 "-fwin32", | 77 "-fwin32", |
74 "-m", "x86", | 78 "-m", |
| 79 "x86", |
75 ] | 80 ] |
76 } else if (cpu_arch == "x64") { | 81 } else if (cpu_arch == "x64") { |
77 _yasm_flags = [ | 82 _yasm_flags = [ |
78 "-fwin64", | 83 "-fwin64", |
79 "-m", "amd64", | 84 "-m", |
| 85 "amd64", |
80 ] | 86 ] |
81 } | 87 } |
82 } | 88 } |
83 | 89 |
84 if (is_win) { | 90 if (is_win) { |
85 asm_obj_extension = "obj" | 91 asm_obj_extension = "obj" |
86 } else { | 92 } else { |
87 asm_obj_extension = "o" | 93 asm_obj_extension = "o" |
88 } | 94 } |
89 | 95 |
(...skipping 17 matching lines...) Expand all Loading... |
107 | 113 |
108 if (defined(invoker.inputs)) { | 114 if (defined(invoker.inputs)) { |
109 inputs = invoker.inputs | 115 inputs = invoker.inputs |
110 } | 116 } |
111 | 117 |
112 # Executable (first in the args). The binary might be in the root build dir | 118 # Executable (first in the args). The binary might be in the root build dir |
113 # (no cross-compiling) or in a toolchain-specific subdirectory of that | 119 # (no cross-compiling) or in a toolchain-specific subdirectory of that |
114 # (when cross-compiling). | 120 # (when cross-compiling). |
115 yasm_label = "//third_party/yasm($host_toolchain)" | 121 yasm_label = "//third_party/yasm($host_toolchain)" |
116 args = [ "./" + # Force current dir. | 122 args = [ "./" + # Force current dir. |
117 rebase_path(get_label_info(yasm_label, "root_out_dir") + "/yasm", | 123 rebase_path(get_label_info(yasm_label, "root_out_dir") + "/yasm", |
118 root_build_dir) | 124 root_build_dir) ] |
119 ] | |
120 | 125 |
121 # Deps. | 126 # Deps. |
122 deps = [ yasm_label ] | 127 deps = [ |
| 128 yasm_label, |
| 129 ] |
123 if (defined(invoker.deps)) { | 130 if (defined(invoker.deps)) { |
124 deps += invoker.deps | 131 deps += invoker.deps |
125 } | 132 } |
126 | 133 |
127 # Flags. | 134 # Flags. |
128 args += _yasm_flags | 135 args += _yasm_flags |
129 if (defined(invoker.yasm_flags)) { | 136 if (defined(invoker.yasm_flags)) { |
130 args += invoker.yasm_flags | 137 args += invoker.yasm_flags |
131 } | 138 } |
132 | 139 |
133 # User defined include dirs go first. | 140 # User defined include dirs go first. |
134 if (defined(invoker.include_dirs)) { | 141 if (defined(invoker.include_dirs)) { |
135 foreach(include, invoker.include_dirs) { | 142 foreach(include, invoker.include_dirs) { |
136 args += [ "-I" + rebase_path(include, root_build_dir) ] | 143 args += [ "-I" + rebase_path(include, root_build_dir) ] |
137 } | 144 } |
138 } | 145 } |
139 | 146 |
140 # Default yasm include dirs. Make it match the native build (source root and | 147 # Default yasm include dirs. Make it match the native build (source root and |
141 # root generated code directory). | 148 # root generated code directory). |
142 # This goes to the end of include list. | 149 # This goes to the end of include list. |
143 args += [ | 150 args += [ |
144 "-I.", | 151 "-I.", |
| 152 |
145 # Using "//." will produce a relative path "../.." which looks better than | 153 # Using "//." will produce a relative path "../.." which looks better than |
146 # "../../" which will result from using "//" as the base (although both | 154 # "../../" which will result from using "//" as the base (although both |
147 # work). This is because rebase_path will terminate the result in a | 155 # work). This is because rebase_path will terminate the result in a |
148 # slash if the input ends in a slash. | 156 # slash if the input ends in a slash. |
149 "-I" + rebase_path("//.", root_build_dir), | 157 "-I" + rebase_path("//.", root_build_dir), |
150 "-I" + rebase_path(root_gen_dir, root_build_dir), | 158 "-I" + rebase_path(root_gen_dir, root_build_dir), |
151 ] | 159 ] |
152 | 160 |
153 | |
154 # Extra defines. | 161 # Extra defines. |
155 if (defined(invoker.defines)) { | 162 if (defined(invoker.defines)) { |
156 foreach(def, invoker.defines) { | 163 foreach(def, invoker.defines) { |
157 args += [ "-D$def" ] | 164 args += [ "-D$def" ] |
158 } | 165 } |
159 } | 166 } |
160 | 167 |
161 # Output file. | 168 # Output file. |
162 # | 169 # |
163 # TODO(brettw) it might be nice if there was a source expansion for the | 170 # TODO(brettw) it might be nice if there was a source expansion for the |
164 # path of the source file relative to the source root. Then we could | 171 # path of the source file relative to the source root. Then we could |
165 # exactly duplicate the naming and location of object files from the | 172 # exactly duplicate the naming and location of object files from the |
166 # native build, which would be: | 173 # native build, which would be: |
167 # "$root_out_dir/${target_name}.{{source_dir_part}}.$asm_obj_extension" | 174 # "$root_out_dir/${target_name}.{{source_dir_part}}.$asm_obj_extension" |
168 outputs = [ "$target_out_dir/{{source_name_part}}.o" ] | 175 outputs = [ "$target_out_dir/{{source_name_part}}.o" ] |
169 args += [ | 176 args += [ |
170 "-o", rebase_path(outputs[0], root_build_dir), | 177 "-o", |
171 "{{source}}" | 178 rebase_path(outputs[0], root_build_dir), |
| 179 "{{source}}", |
172 ] | 180 ] |
173 | 181 |
174 # The wrapper script run_yasm will write the depfile to the same name as | 182 # The wrapper script run_yasm will write the depfile to the same name as |
175 # the output but with .d appended (like gcc will). | 183 # the output but with .d appended (like gcc will). |
176 depfile = outputs[0] + ".d" | 184 depfile = outputs[0] + ".d" |
177 } | 185 } |
178 | 186 |
179 # Gather the .o files into a linkable thing. This doesn't actually link | 187 # Gather the .o files into a linkable thing. This doesn't actually link |
180 # anything (a source set just compiles files to link later), but will pass | 188 # anything (a source set just compiles files to link later), but will pass |
181 # the object files generated by the action up the dependency chain. | 189 # the object files generated by the action up the dependency chain. |
182 source_set(source_set_name) { | 190 source_set(source_set_name) { |
183 if (defined(invoker.visibility)) { | 191 if (defined(invoker.visibility)) { |
184 visibility = invoker.visibility | 192 visibility = invoker.visibility |
185 } | 193 } |
186 | 194 |
187 sources = get_target_outputs(":$action_name") | 195 sources = get_target_outputs(":$action_name") |
188 | 196 |
189 deps = [ ":$action_name" ] | 197 deps = [ |
| 198 ":$action_name", |
| 199 ] |
190 } | 200 } |
191 } | 201 } |
OLD | NEW |