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/clang/clang.gni") | 10 import("//build/config/clang/clang.gni") |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 "//build/toolchain/mac/compile_xcassets.py", | 54 "//build/toolchain/mac/compile_xcassets.py", |
55 "//build/toolchain/mac/filter_libtool.py", | 55 "//build/toolchain/mac/filter_libtool.py", |
56 "//build/toolchain/mac/linker_driver.py", | 56 "//build/toolchain/mac/linker_driver.py", |
57 ], | 57 ], |
58 root_build_dir), | 58 root_build_dir), |
59 "trim scope") | 59 "trim scope") |
60 | 60 |
61 # Work around for unused variable warning in template https://crbug.com/395883. | 61 # Work around for unused variable warning in template https://crbug.com/395883. |
62 assert(tool_versions != "") | 62 assert(tool_versions != "") |
63 | 63 |
64 # Shared toolchain definition. Invocations should set toolchain_os to set the | 64 # Shared toolchain definition. Invocations should set current_os to set the |
65 # build args in this definition. | 65 # build args in this definition. |
66 template("mac_toolchain") { | 66 template("mac_toolchain") { |
67 toolchain(target_name) { | 67 toolchain(target_name) { |
68 assert(defined(invoker.toolchain_cpu), | 68 # When invoking this toolchain not as the default one, these args will be |
69 "mac_toolchain() must specify a \"toolchain_cpu\"") | 69 # passed to the build. They are ignored when this is the default toolchain. |
70 assert(defined(invoker.toolchain_os), | 70 toolchain_args = { |
71 "mac_toolchain() must specify a \"toolchain_os\"") | 71 # Populate toolchain args from the invoker. |
| 72 if (defined(invoker.toolchain_args)) { |
| 73 forward_variables_from(invoker.toolchain_args, "*") |
| 74 } |
72 | 75 |
73 if (use_goma) { | 76 # These values need to be passed through unchanged to all secondary |
74 assert(cc_wrapper == "", "Goma and cc_wrapper can't be used together.") | 77 # toolchains. BUILDCONFIG.gn sets some defaults based on the values of |
75 _compiler_prefix = "$goma_dir/gomacc " | 78 # the operating system and compiler, and we want to force the values to |
76 } else if (cc_wrapper != "") { | 79 # be consistent if re-running the computation in another context leads |
77 _compiler_prefix = cc_wrapper + " " | 80 # to different defaults. |
78 } else { | 81 host_toolchain = host_toolchain |
79 _compiler_prefix = "" | 82 target_os = target_os |
| 83 target_cpu = target_cpu |
80 } | 84 } |
81 | 85 |
82 if (invoker.toolchain_os != "ios" || !use_xcode_clang) { | 86 # When the invoker has explicitly overridden use_goma or cc_wrapper in the |
83 _compiler_prefix += rebase_path("$clang_base_path/bin/", root_build_dir) | 87 # toolchain args, use those values, otherwise default to the global one. |
| 88 # This works because the only reasonable override that toolchains might |
| 89 # supply for these values are to force-disable them. |
| 90 if (defined(toolchain_args.use_goma)) { |
| 91 toolchain_uses_goma = toolchain_args.use_goma |
| 92 } else { |
| 93 toolchain_uses_goma = use_goma |
| 94 } |
| 95 if (defined(toolchain_args.cc_wrapper)) { |
| 96 toolchain_cc_wrapper = toolchain_args.cc_wrapper |
| 97 } else { |
| 98 toolchain_cc_wrapper = cc_wrapper |
84 } | 99 } |
85 | 100 |
86 cc = "${_compiler_prefix}clang" | 101 # Compute the compiler prefix. |
87 cxx = "${_compiler_prefix}clang++" | 102 if (toolchain_uses_goma) { |
| 103 assert(toolchain_cc_wrapper == "", |
| 104 "Goma and cc_wrapper can't be used together.") |
| 105 compiler_prefix = "$goma_dir/gomacc " |
| 106 } else if (toolchain_cc_wrapper != "") { |
| 107 compiler_prefix = toolchain_cc_wrapper + " " |
| 108 } else { |
| 109 compiler_prefix = "" |
| 110 } |
| 111 |
| 112 if (toolchain_args.current_os != "ios" || !use_xcode_clang) { |
| 113 compiler_prefix += rebase_path("$clang_base_path/bin/", root_build_dir) |
| 114 } |
| 115 |
| 116 cc = "${compiler_prefix}clang" |
| 117 cxx = "${compiler_prefix}clang++" |
88 ld = cxx | 118 ld = cxx |
89 | 119 |
90 linker_driver = | 120 linker_driver = |
91 "TOOL_VERSION=${tool_versions.linker_driver} " + | 121 "TOOL_VERSION=${tool_versions.linker_driver} " + |
92 rebase_path("//build/toolchain/mac/linker_driver.py", root_build_dir) | 122 rebase_path("//build/toolchain/mac/linker_driver.py", root_build_dir) |
93 | 123 |
94 if (invoker.toolchain_os == "ios" && additional_toolchains != []) { | 124 if (toolchain_args.current_os == "ios" && additional_toolchains != []) { |
95 # For a fat build, the generation of dSYM needs to be performed after the | 125 # For a fat build, the generation of dSYM needs to be performed after the |
96 # generation of the fat binaries using "lipo". So disable the generation | 126 # generation of the fat binaries using "lipo". So disable the generation |
97 # of the dSYM for intermediate architecture specific binaries. | 127 # of the dSYM for intermediate architecture specific binaries. |
98 _enable_dsyms = false | 128 _enable_dsyms = false |
99 _save_unstripped_output = false | 129 _save_unstripped_output = false |
100 } else { | 130 } else { |
101 _enable_dsyms = enable_dsyms | 131 _enable_dsyms = enable_dsyms |
102 _save_unstripped_output = save_unstripped_output | 132 _save_unstripped_output = save_unstripped_output |
103 } | 133 } |
104 | 134 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 _min_deployment_target = mac_deployment_target | 401 _min_deployment_target = mac_deployment_target |
372 } | 402 } |
373 command = "rm -f {{output}} && " + | 403 command = "rm -f {{output}} && " + |
374 "TOOL_VERSION=${tool_versions.compile_xcassets} " + | 404 "TOOL_VERSION=${tool_versions.compile_xcassets} " + |
375 "python $_tool -p $_sdk_name -t $_min_deployment_target " + | 405 "python $_tool -p $_sdk_name -t $_min_deployment_target " + |
376 "-o {{output}} {{inputs}}" | 406 "-o {{output}} {{inputs}}" |
377 | 407 |
378 description = "COMPILE_XCASSETS {{output}}" | 408 description = "COMPILE_XCASSETS {{output}}" |
379 pool = ":bundle_pool($default_toolchain)" | 409 pool = ":bundle_pool($default_toolchain)" |
380 } | 410 } |
381 | |
382 toolchain_args() { | |
383 current_cpu = invoker.toolchain_cpu | |
384 current_os = invoker.toolchain_os | |
385 | |
386 # These values need to be passed through unchanged. | |
387 host_toolchain = host_toolchain | |
388 target_os = target_os | |
389 target_cpu = target_cpu | |
390 is_clang = true | |
391 } | |
392 } | 411 } |
393 } | 412 } |
394 | 413 |
395 mac_toolchain("clang_arm") { | 414 mac_toolchain("clang_arm") { |
396 toolchain_cpu = "arm" | 415 toolchain_args = { |
397 toolchain_os = "mac" | 416 current_cpu = "arm" |
| 417 current_os = "mac" |
| 418 } |
398 } | 419 } |
399 | 420 |
400 mac_toolchain("clang_x64") { | 421 mac_toolchain("clang_x64") { |
401 toolchain_cpu = "x64" | 422 toolchain_args = { |
402 toolchain_os = "mac" | 423 current_cpu = "x64" |
| 424 current_os = "mac" |
| 425 } |
403 } | 426 } |
404 | 427 |
405 if (is_ios) { | 428 if (is_ios) { |
406 mac_toolchain("ios_clang_arm") { | 429 mac_toolchain("ios_clang_arm") { |
407 toolchain_cpu = "arm" | 430 toolchain_args = { |
408 toolchain_os = "ios" | 431 current_cpu = "arm" |
| 432 current_os = "ios" |
| 433 } |
409 } | 434 } |
410 | 435 |
411 mac_toolchain("ios_clang_arm64") { | 436 mac_toolchain("ios_clang_arm64") { |
412 toolchain_cpu = "arm64" | 437 toolchain_args = { |
413 toolchain_os = "ios" | 438 current_cpu = "arm64" |
| 439 current_os = "ios" |
| 440 } |
414 } | 441 } |
415 | 442 |
416 mac_toolchain("ios_clang_x86") { | 443 mac_toolchain("ios_clang_x86") { |
417 toolchain_cpu = "x86" | 444 toolchain_args = { |
418 toolchain_os = "ios" | 445 current_cpu = "x86" |
| 446 current_os = "ios" |
| 447 } |
419 } | 448 } |
420 | 449 |
421 mac_toolchain("ios_clang_x64") { | 450 mac_toolchain("ios_clang_x64") { |
422 toolchain_cpu = "x64" | 451 toolchain_args = { |
423 toolchain_os = "ios" | 452 current_cpu = "x64" |
| 453 current_os = "ios" |
| 454 } |
424 } | 455 } |
425 } | 456 } |
OLD | NEW |