| 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 | 10 |
| 11 # Should only be running on Mac. | 11 assert(host_os == "mac") |
| 12 assert(is_mac || is_ios) | |
| 13 | 12 |
| 14 import("//build/toolchain/clang.gni") | 13 import("//build/toolchain/clang.gni") |
| 15 import("//build/toolchain/goma.gni") | 14 import("//build/toolchain/goma.gni") |
| 16 | 15 |
| 17 if (use_goma) { | 16 if (use_goma) { |
| 18 goma_prefix = "$goma_dir/gomacc " | 17 goma_prefix = "$goma_dir/gomacc " |
| 19 } else { | 18 } else { |
| 20 goma_prefix = "" | 19 goma_prefix = "" |
| 21 } | 20 } |
| 22 | 21 |
| 23 if (is_clang) { | |
| 24 cc = rebase_path("//third_party/llvm-build/Release+Asserts/bin/clang", | |
| 25 root_build_dir) | |
| 26 cxx = rebase_path("//third_party/llvm-build/Release+Asserts/bin/clang++", | |
| 27 root_build_dir) | |
| 28 } else { | |
| 29 cc = "gcc" | |
| 30 cxx = "g++" | |
| 31 } | |
| 32 cc = goma_prefix + cc | |
| 33 cxx = goma_prefix + cxx | |
| 34 ld = cxx | |
| 35 | |
| 36 # This will copy the gyp-mac-tool to the build directory. We pass in the source | 22 # This will copy the gyp-mac-tool to the build directory. We pass in the source |
| 37 # file of the win tool. | 23 # file of the win tool. |
| 38 gyp_mac_tool_source = | 24 gyp_mac_tool_source = |
| 39 rebase_path("//tools/gyp/pylib/gyp/mac_tool.py", root_build_dir) | 25 rebase_path("//tools/gyp/pylib/gyp/mac_tool.py", root_build_dir) |
| 40 exec_script("setup_toolchain.py", [ gyp_mac_tool_source ]) | 26 exec_script("setup_toolchain.py", [ gyp_mac_tool_source ]) |
| 41 | 27 |
| 42 # Shared toolchain definition. Invocations should set toolchain_os to set the | 28 # Shared toolchain definition. Invocations should set toolchain_os to set the |
| 43 # build args in this definition. | 29 # build args in this definition. |
| 44 template("mac_clang_toolchain") { | 30 template("mac_toolchain") { |
| 45 toolchain(target_name) { | 31 toolchain(target_name) { |
| 46 assert(defined(invoker.cc), | 32 assert(defined(invoker.cc), "mac_toolchain() must specify a \"cc\" value") |
| 47 "mac_clang_toolchain() must specify a \"cc\" value") | 33 assert(defined(invoker.cxx), "mac_toolchain() must specify a \"cxx\" value") |
| 48 assert(defined(invoker.cxx), | 34 assert(defined(invoker.ld), "mac_toolchain() must specify a \"ld\" value") |
| 49 "mac_clang_toolchain() must specify a \"cxx\" value") | 35 assert(defined(invoker.toolchain_cpu), |
| 50 assert(defined(invoker.ld), | 36 "mac_toolchain() must specify a \"toolchain_cpu\"") |
| 51 "mac_clang_toolchain() must specify a \"ld\" value") | |
| 52 assert(defined(invoker.toolchain_os), | 37 assert(defined(invoker.toolchain_os), |
| 53 "mac_clang_toolchain() must specify a \"toolchain_os\"") | 38 "mac_toolchain() must specify a \"toolchain_os\"") |
| 54 | 39 |
| 55 # We can't do string interpolation ($ in strings) on things with dots in | 40 # We can't do string interpolation ($ in strings) on things with dots in |
| 56 # them. To allow us to use $cc below, for example, we create copies of | 41 # them. To allow us to use $cc below, for example, we create copies of |
| 57 # these values in our scope. | 42 # these values in our scope. |
| 58 cc = invoker.cc | 43 cc = invoker.cc |
| 59 cxx = invoker.cxx | 44 cxx = invoker.cxx |
| 60 ld = invoker.ld | 45 ld = invoker.ld |
| 61 | 46 |
| 62 # Make these apply to all tools below. | 47 # Make these apply to all tools below. |
| 63 lib_switch = "-l" | 48 lib_switch = "-l" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 command = "touch {{output}}" | 172 command = "touch {{output}}" |
| 188 description = "STAMP {{output}}" | 173 description = "STAMP {{output}}" |
| 189 } | 174 } |
| 190 | 175 |
| 191 tool("copy") { | 176 tool("copy") { |
| 192 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} &
& cp -af {{source}} {{output}})" | 177 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} &
& cp -af {{source}} {{output}})" |
| 193 description = "COPY {{source}} {{output}}" | 178 description = "COPY {{source}} {{output}}" |
| 194 } | 179 } |
| 195 | 180 |
| 196 toolchain_args() { | 181 toolchain_args() { |
| 182 current_cpu = invoker.toolchain_cpu |
| 197 current_os = invoker.toolchain_os | 183 current_os = invoker.toolchain_os |
| 184 |
| 185 # These values need to be passed through unchanged. |
| 186 target_os = target_os |
| 187 target_cpu = target_cpu |
| 188 |
| 189 if (defined(invoker.is_clang)) { |
| 190 is_clang = invoker.is_clang |
| 191 } |
| 198 } | 192 } |
| 199 } | 193 } |
| 200 } | 194 } |
| 201 | 195 |
| 202 # Toolchain representing the target build (either mac or iOS). | 196 mac_toolchain("clang_arm") { |
| 203 mac_clang_toolchain("clang") { | 197 toolchain_cpu = "arm" |
| 204 toolchain_os = current_os | 198 toolchain_os = "mac" |
| 199 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| 200 root_build_dir) |
| 201 cc = "${goma_prefix}$prefix/clang" |
| 202 cxx = "${goma_prefix}$prefix/clang++" |
| 203 ld = cxx |
| 204 is_clang = true |
| 205 } | 205 } |
| 206 | 206 |
| 207 # This toolchain provides a way for iOS target compiles to reference targets | 207 mac_toolchain("arm") { |
| 208 # compiled for the host system. It just overrides the OS back to "mac". | 208 toolchain_cpu = "arm" |
| 209 mac_clang_toolchain("host_clang") { | |
| 210 toolchain_os = "mac" | 209 toolchain_os = "mac" |
| 210 cc = "${goma_prefix}/gcc" |
| 211 cxx = "${goma_prefix}/g++" |
| 212 ld = cxx |
| 213 is_clang = false |
| 211 } | 214 } |
| 215 |
| 216 mac_toolchain("clang_x64") { |
| 217 toolchain_cpu = "x64" |
| 218 toolchain_os = "mac" |
| 219 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| 220 root_build_dir) |
| 221 cc = "${goma_prefix}$prefix/clang" |
| 222 cxx = "${goma_prefix}$prefix/clang++" |
| 223 ld = cxx |
| 224 is_clang = true |
| 225 } |
| 226 |
| 227 mac_toolchain("x64") { |
| 228 toolchain_cpu = "x64" |
| 229 toolchain_os = "mac" |
| 230 cc = "${goma_prefix}/gcc" |
| 231 cxx = "${goma_prefix}/g++" |
| 232 ld = cxx |
| 233 is_clang = false |
| 234 } |
| OLD | NEW |