Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 # TODO(ajwong): This should be is_posix... | |
|
brettw
2014/05/05 19:34:26
Myabe just remove this comment and it this block i
awong
2014/05/05 19:47:08
Done.
| |
| 30 if (is_posix && !is_mac && !is_ios) { | |
| 31 if (cpu_arch == "x86") { | |
| 32 yasm_flags = [ | |
| 33 "-felf32", | |
| 34 "-m", "x86", | |
| 35 ] | |
| 36 } else if (cpu_arch == "x64") { | |
| 37 yasm_flags = [ | |
| 38 "-DPIC", | |
| 39 "-felf64", | |
| 40 "-m", "amd64", | |
| 41 ] | |
| 42 } | |
| 43 } else if (is_mac || is_ios) { | |
| 44 if (cpu_arch == "x86") { | |
| 45 yasm_flags = [ | |
| 46 "-fmacho32", | |
| 47 "-m", "x86", | |
| 48 ] | |
| 49 } else if (cpu_arch == "x64") { | |
| 50 yasm_flags = [ | |
| 51 "-fmacho64", | |
| 52 "-m", "amd64", | |
| 53 ] | |
| 54 } | |
| 55 } else if (is_win) { | |
| 56 if (cpu_arch == "x86") { | |
| 57 yasm_flags = [ | |
| 58 "-DPREFIX", | |
| 59 "-fwin32", | |
| 60 "-m", "x86", | |
| 61 ] | |
| 62 } else if (cpu_arch == "x64") { | |
| 63 yasm_flags = [ | |
| 64 "-fwin64", | |
| 65 "-m", "amd64", | |
| 66 ] | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 if (is_win) { | |
| 71 asm_obj_extension = "obj" | |
| 72 } else { | |
| 73 asm_obj_extension = "o" | |
| 74 } | |
| 75 | |
| 76 assert(defined(invoker.yasm_output_path)) | |
| 77 yasm_output_path = invoker.yasm_output_path | |
| 78 | |
| 79 source_set(target_name) { | |
| 80 sources = process_file_template( | |
| 81 invoker.sources, | |
| 82 "$yasm_output_path/{{source_name_part}}.o") | |
| 83 deps = [ ":${target_name}_yasm" ] | |
| 84 } | |
| 85 | |
| 86 run_executable_foreach("${target_name}_yasm") { | |
| 87 sources = invoker.sources | |
| 88 binary_name = "yasm" | |
| 89 outputs = [ "$yasm_output_path/{{source_name_part}}.$asm_obj_extension" ] | |
| 90 args = yasm_flags | |
| 91 if (defined(invoker.yasm_flags)) { | |
| 92 args += invoker.yasm_flags | |
| 93 } | |
| 94 args += [ | |
| 95 "-o", rebase_path(outputs[0], root_build_dir), | |
| 96 "{{source}}" | |
| 97 ] | |
| 98 | |
| 99 if (defined(invoker.yasm_includes)) { | |
| 100 source_prereqs = rebase_path(invoker.yasm_includes, root_build_dir) | |
| 101 } | |
| 102 | |
| 103 # Only depend on YASM on x86 systems. Force compilation of .asm files for | |
| 104 # ARM to fail. | |
| 105 assert(cpu_arch == "x86" || cpu_arch == "x64") | |
| 106 deps = [ "//third_party/yasm($host_toolchain)" ] | |
| 107 } | |
| 108 } | |
| OLD | NEW |