| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 if (is_win) { | 90 if (is_win) { |
| 91 asm_obj_extension = "obj" | 91 asm_obj_extension = "obj" |
| 92 } else { | 92 } else { |
| 93 asm_obj_extension = "o" | 93 asm_obj_extension = "o" |
| 94 } | 94 } |
| 95 | 95 |
| 96 template("yasm_assemble") { | 96 template("yasm_assemble") { |
| 97 # TODO(ajwong): Support use_system_yasm. | |
| 98 assert(defined(invoker.sources), "Need sources defined for $target_name") | 97 assert(defined(invoker.sources), "Need sources defined for $target_name") |
| 99 | 98 |
| 100 # Only depend on YASM on x86 systems. Force compilation of .asm files for | 99 # Only depend on YASM on x86 systems. Force compilation of .asm files for |
| 101 # ARM to fail. | 100 # ARM to fail. |
| 102 assert(current_cpu == "x86" || current_cpu == "x64") | 101 assert(current_cpu == "x86" || current_cpu == "x64") |
| 103 | 102 |
| 104 action_name = "${target_name}_action" | 103 action_name = "${target_name}_action" |
| 105 source_set_name = target_name | 104 source_set_name = target_name |
| 106 | 105 |
| 107 action_foreach(action_name) { | 106 action_foreach(action_name) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 ] | 158 ] |
| 160 | 159 |
| 161 # Extra defines. | 160 # Extra defines. |
| 162 if (defined(invoker.defines)) { | 161 if (defined(invoker.defines)) { |
| 163 foreach(def, invoker.defines) { | 162 foreach(def, invoker.defines) { |
| 164 args += [ "-D$def" ] | 163 args += [ "-D$def" ] |
| 165 } | 164 } |
| 166 } | 165 } |
| 167 | 166 |
| 168 # Output file. | 167 # Output file. |
| 169 # | |
| 170 # TODO(brettw) it might be nice if there was a source expansion for the | |
| 171 # path of the source file relative to the source root. Then we could | |
| 172 # exactly duplicate the naming and location of object files from the | |
| 173 # native build, which would be: | |
| 174 # "$root_out_dir/${target_name}.{{source_dir_part}}.$asm_obj_extension" | |
| 175 outputs = [ | 168 outputs = [ |
| 176 "$target_out_dir/{{source_name_part}}.o", | 169 "$target_out_dir/$source_set_name/{{source_name_part}}.o", |
| 177 ] | 170 ] |
| 178 args += [ | 171 args += [ |
| 179 "-o", | 172 "-o", |
| 180 rebase_path(outputs[0], root_build_dir), | 173 rebase_path(outputs[0], root_build_dir), |
| 181 "{{source}}", | 174 "{{source}}", |
| 182 ] | 175 ] |
| 183 | 176 |
| 184 # The wrapper script run_yasm will write the depfile to the same name as | 177 # The wrapper script run_yasm will write the depfile to the same name as |
| 185 # the output but with .d appended (like gcc will). | 178 # the output but with .d appended (like gcc will). |
| 186 depfile = outputs[0] + ".d" | 179 depfile = outputs[0] + ".d" |
| 187 } | 180 } |
| 188 | 181 |
| 189 # Gather the .o files into a linkable thing. This doesn't actually link | 182 # Gather the .o files into a linkable thing. This doesn't actually link |
| 190 # anything (a source set just compiles files to link later), but will pass | 183 # anything (a source set just compiles files to link later), but will pass |
| 191 # the object files generated by the action up the dependency chain. | 184 # the object files generated by the action up the dependency chain. |
| 192 source_set(source_set_name) { | 185 source_set(source_set_name) { |
| 193 if (defined(invoker.visibility)) { | 186 if (defined(invoker.visibility)) { |
| 194 visibility = invoker.visibility | 187 visibility = invoker.visibility |
| 195 } | 188 } |
| 196 | 189 |
| 197 sources = get_target_outputs(":$action_name") | 190 sources = get_target_outputs(":$action_name") |
| 198 | 191 |
| 199 deps = [ | 192 deps = [ |
| 200 ":$action_name", | 193 ":$action_name", |
| 201 ] | 194 ] |
| 202 } | 195 } |
| 203 } | 196 } |
| OLD | NEW |