| 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 24 matching lines...) Expand all Loading... |
| 35 # Example | 35 # Example |
| 36 # | 36 # |
| 37 # yasm_assemble("my_yasm_target") { | 37 # yasm_assemble("my_yasm_target") { |
| 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 (current_cpu == "x86") { |
| 46 _yasm_flags = [ | 46 _yasm_flags = [ |
| 47 "-fmacho32", | 47 "-fmacho32", |
| 48 "-m", | 48 "-m", |
| 49 "x86", | 49 "x86", |
| 50 ] | 50 ] |
| 51 } else if (cpu_arch == "x64") { | 51 } else if (current_cpu == "x64") { |
| 52 _yasm_flags = [ | 52 _yasm_flags = [ |
| 53 "-fmacho64", | 53 "-fmacho64", |
| 54 "-m", | 54 "-m", |
| 55 "amd64", | 55 "amd64", |
| 56 ] | 56 ] |
| 57 } | 57 } |
| 58 } else if (is_posix) { | 58 } else if (is_posix) { |
| 59 if (cpu_arch == "x86") { | 59 if (current_cpu == "x86") { |
| 60 _yasm_flags = [ | 60 _yasm_flags = [ |
| 61 "-felf32", | 61 "-felf32", |
| 62 "-m", | 62 "-m", |
| 63 "x86", | 63 "x86", |
| 64 ] | 64 ] |
| 65 } else if (cpu_arch == "x64") { | 65 } else if (current_cpu == "x64") { |
| 66 _yasm_flags = [ | 66 _yasm_flags = [ |
| 67 "-DPIC", | 67 "-DPIC", |
| 68 "-felf64", | 68 "-felf64", |
| 69 "-m", | 69 "-m", |
| 70 "amd64", | 70 "amd64", |
| 71 ] | 71 ] |
| 72 } | 72 } |
| 73 } else if (is_win) { | 73 } else if (is_win) { |
| 74 if (cpu_arch == "x86") { | 74 if (current_cpu == "x86") { |
| 75 _yasm_flags = [ | 75 _yasm_flags = [ |
| 76 "-DPREFIX", | 76 "-DPREFIX", |
| 77 "-fwin32", | 77 "-fwin32", |
| 78 "-m", | 78 "-m", |
| 79 "x86", | 79 "x86", |
| 80 ] | 80 ] |
| 81 } else if (cpu_arch == "x64") { | 81 } else if (current_cpu == "x64") { |
| 82 _yasm_flags = [ | 82 _yasm_flags = [ |
| 83 "-fwin64", | 83 "-fwin64", |
| 84 "-m", | 84 "-m", |
| 85 "amd64", | 85 "amd64", |
| 86 ] | 86 ] |
| 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. | 97 # TODO(ajwong): Support use_system_yasm. |
| 98 assert(defined(invoker.sources), "Need sources defined for $target_name") | 98 assert(defined(invoker.sources), "Need sources defined for $target_name") |
| 99 | 99 |
| 100 # Only depend on YASM on x86 systems. Force compilation of .asm files for | 100 # Only depend on YASM on x86 systems. Force compilation of .asm files for |
| 101 # ARM to fail. | 101 # ARM to fail. |
| 102 assert(cpu_arch == "x86" || cpu_arch == "x64") | 102 assert(current_cpu == "x86" || current_cpu == "x64") |
| 103 | 103 |
| 104 action_name = "${target_name}_action" | 104 action_name = "${target_name}_action" |
| 105 source_set_name = target_name | 105 source_set_name = target_name |
| 106 | 106 |
| 107 action_foreach(action_name) { | 107 action_foreach(action_name) { |
| 108 # Only the source set can depend on this. | 108 # Only the source set can depend on this. |
| 109 visibility = [ ":$source_set_name" ] | 109 visibility = [ ":$source_set_name" ] |
| 110 | 110 |
| 111 script = "//third_party/yasm/run_yasm.py" | 111 script = "//third_party/yasm/run_yasm.py" |
| 112 sources = invoker.sources | 112 sources = invoker.sources |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 visibility = invoker.visibility | 194 visibility = invoker.visibility |
| 195 } | 195 } |
| 196 | 196 |
| 197 sources = get_target_outputs(":$action_name") | 197 sources = get_target_outputs(":$action_name") |
| 198 | 198 |
| 199 deps = [ | 199 deps = [ |
| 200 ":$action_name", | 200 ":$action_name", |
| 201 ] | 201 ] |
| 202 } | 202 } |
| 203 } | 203 } |
| OLD | NEW |