| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires | 5 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires |
| 6 # some enhancements since the commands on Mac are slightly different than on | 6 # some enhancements since the commands on Mac are slightly different than on |
| 7 # Linux. | 7 # Linux. |
| 8 | 8 |
| 9 import("../goma.gni") | 9 import("../goma.gni") |
| 10 import("//build/config/mac/mac_sdk.gni") | 10 import("//build/config/mac/mac_sdk.gni") |
| 11 | 11 |
| 12 assert(host_os == "mac") | 12 assert(host_os == "mac") |
| 13 | 13 |
| 14 import("//build/toolchain/clang.gni") | 14 import("//build/toolchain/clang.gni") |
| 15 import("//build/toolchain/goma.gni") | 15 import("//build/toolchain/goma.gni") |
| 16 import("//build/config/sysroot.gni") | 16 import("//build/config/sysroot.gni") |
| 17 | 17 |
| 18 if (use_goma) { | 18 if (use_goma) { |
| 19 goma_prefix = "$goma_dir/gomacc " | 19 goma_prefix = "$goma_dir/gomacc " |
| 20 } else { | 20 } else { |
| 21 goma_prefix = "" | 21 goma_prefix = "" |
| 22 } | 22 } |
| 23 | 23 |
| 24 # This will copy the gyp-mac-tool to the build directory. We pass in the source | |
| 25 # file of the win tool. | |
| 26 gyp_mac_tool_source = | |
| 27 rebase_path("//third_party/gyp/pylib/gyp/mac_tool.py", root_build_dir) | |
| 28 exec_script("setup_toolchain.py", [ gyp_mac_tool_source ]) | |
| 29 | |
| 30 # Shared toolchain definition. Invocations should set toolchain_os to set the | 24 # Shared toolchain definition. Invocations should set toolchain_os to set the |
| 31 # build args in this definition. | 25 # build args in this definition. |
| 32 template("mac_toolchain") { | 26 template("mac_toolchain") { |
| 33 toolchain(target_name) { | 27 toolchain(target_name) { |
| 34 assert(defined(invoker.cc), "mac_toolchain() must specify a \"cc\" value") | 28 assert(defined(invoker.cc), "mac_toolchain() must specify a \"cc\" value") |
| 35 assert(defined(invoker.cxx), "mac_toolchain() must specify a \"cxx\" value") | 29 assert(defined(invoker.cxx), "mac_toolchain() must specify a \"cxx\" value") |
| 30 assert(defined(invoker.ar), "mac_toolchain() must specify an \"ar\" value") |
| 36 assert(defined(invoker.ld), "mac_toolchain() must specify a \"ld\" value") | 31 assert(defined(invoker.ld), "mac_toolchain() must specify a \"ld\" value") |
| 37 assert(defined(invoker.toolchain_cpu), | 32 assert(defined(invoker.toolchain_cpu), |
| 38 "mac_toolchain() must specify a \"toolchain_cpu\"") | 33 "mac_toolchain() must specify a \"toolchain_cpu\"") |
| 39 assert(defined(invoker.toolchain_os), | 34 assert(defined(invoker.toolchain_os), |
| 40 "mac_toolchain() must specify a \"toolchain_os\"") | 35 "mac_toolchain() must specify a \"toolchain_os\"") |
| 41 | 36 |
| 42 # We can't do string interpolation ($ in strings) on things with dots in | 37 # We can't do string interpolation ($ in strings) on things with dots in |
| 43 # them. To allow us to use $cc below, for example, we create copies of | 38 # them. To allow us to use $cc below, for example, we create copies of |
| 44 # these values in our scope. | 39 # these values in our scope. |
| 45 cc = invoker.cc | 40 cc = invoker.cc |
| 46 cxx = invoker.cxx | 41 cxx = invoker.cxx |
| 42 ar = invoker.ar |
| 47 ld = invoker.ld | 43 ld = invoker.ld |
| 48 | 44 |
| 49 # Make these apply to all tools below. | 45 # Make these apply to all tools below. |
| 50 lib_switch = "-l" | 46 lib_switch = "-l" |
| 51 lib_dir_switch = "-L" | 47 lib_dir_switch = "-L" |
| 52 | 48 |
| 53 sysroot_flags = "" | 49 sysroot_flags = "" |
| 54 | 50 |
| 55 if (defined(invoker.sysroot_flags)) { | 51 if (defined(invoker.sysroot_flags)) { |
| 56 sysroot_flags = invoker.sysroot_flags | 52 sysroot_flags = invoker.sysroot_flags |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 depfile = "{{output}}.d" | 102 depfile = "{{output}}.d" |
| 107 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} $sysroot_fl
ags $toolchain_flags {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o
{{output}}" | 103 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} $sysroot_fl
ags $toolchain_flags {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o
{{output}}" |
| 108 depsformat = "gcc" | 104 depsformat = "gcc" |
| 109 description = "OBJCXX {{output}}" | 105 description = "OBJCXX {{output}}" |
| 110 outputs = [ | 106 outputs = [ |
| 111 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", | 107 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", |
| 112 ] | 108 ] |
| 113 } | 109 } |
| 114 | 110 |
| 115 tool("alink") { | 111 tool("alink") { |
| 116 command = "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -stat
ic -o {{output}} {{inputs}}" | 112 rspfile = "{{output}}.rsp" |
| 117 description = "LIBTOOL-STATIC {{output}}" | 113 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" |
| 114 description = "AR {{output}}" |
| 115 rspfile_content = "{{inputs}}" |
| 118 outputs = [ | 116 outputs = [ |
| 119 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", | 117 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 120 ] | 118 ] |
| 121 default_output_extension = ".a" | 119 default_output_extension = ".a" |
| 122 output_prefix = "lib" | 120 output_prefix = "lib" |
| 123 } | 121 } |
| 124 | 122 |
| 125 tool("solink") { | 123 tool("solink") { |
| 126 dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e
g "./libfoo.dylib" | 124 dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e
g "./libfoo.dylib" |
| 127 rspfile = dylib + ".rsp" | 125 rspfile = dylib + ".rsp" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 220 } |
| 223 | 221 |
| 224 # Toolchain used for Mac host targets. | 222 # Toolchain used for Mac host targets. |
| 225 mac_toolchain("clang_x64") { | 223 mac_toolchain("clang_x64") { |
| 226 toolchain_cpu = "x64" | 224 toolchain_cpu = "x64" |
| 227 toolchain_os = "mac" | 225 toolchain_os = "mac" |
| 228 prefix = rebase_path("//buildtools/toolchain/clang+llvm-x86_64-darwin/bin", | 226 prefix = rebase_path("//buildtools/toolchain/clang+llvm-x86_64-darwin/bin", |
| 229 root_build_dir) | 227 root_build_dir) |
| 230 cc = "${goma_prefix}$prefix/clang" | 228 cc = "${goma_prefix}$prefix/clang" |
| 231 cxx = "${goma_prefix}$prefix/clang++" | 229 cxx = "${goma_prefix}$prefix/clang++" |
| 230 ar = "${prefix}/llvm-ar" |
| 232 ld = cxx | 231 ld = cxx |
| 233 strip = "strip" | 232 strip = "strip" |
| 234 is_clang = true | 233 is_clang = true |
| 235 sysroot_flags = "-isysroot $mac_sdk_path -mmacosx-version-min=$mac_sdk_min" | 234 sysroot_flags = "-isysroot $mac_sdk_path -mmacosx-version-min=$mac_sdk_min" |
| 236 } | 235 } |
| 237 | 236 |
| 238 # Toolchain used for Mac host (i386) targets. | 237 # Toolchain used for Mac host (i386) targets. |
| 239 mac_toolchain("clang_x86") { | 238 mac_toolchain("clang_x86") { |
| 240 toolchain_cpu = "i386" | 239 toolchain_cpu = "i386" |
| 241 toolchain_os = "mac" | 240 toolchain_os = "mac" |
| 242 prefix = rebase_path("//buildtools/toolchain/clang+llvm-x86_64-darwin/bin", | 241 prefix = rebase_path("//buildtools/toolchain/clang+llvm-x86_64-darwin/bin", |
| 243 root_build_dir) | 242 root_build_dir) |
| 244 cc = "${goma_prefix}$prefix/clang" | 243 cc = "${goma_prefix}$prefix/clang" |
| 245 cxx = "${goma_prefix}$prefix/clang++" | 244 cxx = "${goma_prefix}$prefix/clang++" |
| 245 ar = "${prefix}/llvm-ar" |
| 246 ld = cxx | 246 ld = cxx |
| 247 strip = "strip" | 247 strip = "strip" |
| 248 is_clang = true | 248 is_clang = true |
| 249 sysroot_flags = "-isysroot $mac_sdk_path -mmacosx-version-min=$mac_sdk_min" | 249 sysroot_flags = "-isysroot $mac_sdk_path -mmacosx-version-min=$mac_sdk_min" |
| 250 } | 250 } |
| OLD | NEW |