Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: build/toolchain/mac/BUILD.gn

Issue 2219953002: Use new toolchain_args variable in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@toolchain_args
Patch Set: wrap Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/linux/BUILD.gn ('k') | build/toolchain/nacl/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 assert(defined(invoker.toolchain_args),
71 "mac_toolchain() must specify a \"toolchain_os\"") 71 "Toolchains must declare toolchain_args")
72 toolchain_args = {
73 # Populate toolchain args from the invoker.
74 forward_variables_from(invoker.toolchain_args, "*")
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 # On iOS, the final applications are assembled using lipo (to support fat 124 # On iOS, the final applications are assembled using lipo (to support fat
95 # builds). The correct flags are passed to the linker_driver.py script 125 # builds). The correct flags are passed to the linker_driver.py script
96 # directly during the lipo call. 126 # directly during the lipo call.
97 if (invoker.toolchain_os != "ios") { 127 if (toolchain_args.current_os != "ios") {
98 _enable_dsyms = enable_dsyms 128 _enable_dsyms = enable_dsyms
99 _save_unstripped_output = save_unstripped_output 129 _save_unstripped_output = save_unstripped_output
100 } else { 130 } else {
101 _enable_dsyms = false 131 _enable_dsyms = false
102 _save_unstripped_output = false 132 _save_unstripped_output = false
103 } 133 }
104 134
105 # Make these apply to all tools below. 135 # Make these apply to all tools below.
106 lib_switch = "-l" 136 lib_switch = "-l"
107 lib_dir_switch = "-L" 137 lib_dir_switch = "-L"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 _min_deployment_target = mac_deployment_target 407 _min_deployment_target = mac_deployment_target
378 } 408 }
379 command = "rm -f {{output}} && " + 409 command = "rm -f {{output}} && " +
380 "TOOL_VERSION=${tool_versions.compile_xcassets} " + 410 "TOOL_VERSION=${tool_versions.compile_xcassets} " +
381 "python $_tool -p $_sdk_name -t $_min_deployment_target " + 411 "python $_tool -p $_sdk_name -t $_min_deployment_target " +
382 "-o {{output}} {{inputs}}" 412 "-o {{output}} {{inputs}}"
383 413
384 description = "COMPILE_XCASSETS {{output}}" 414 description = "COMPILE_XCASSETS {{output}}"
385 pool = ":bundle_pool($default_toolchain)" 415 pool = ":bundle_pool($default_toolchain)"
386 } 416 }
387
388 toolchain_args() {
389 current_cpu = invoker.toolchain_cpu
390 current_os = invoker.toolchain_os
391
392 # These values need to be passed through unchanged.
393 host_toolchain = host_toolchain
394 target_os = target_os
395 target_cpu = target_cpu
396 is_clang = true
397 }
398 } 417 }
399 } 418 }
400 419
401 mac_toolchain("clang_arm") { 420 mac_toolchain("clang_arm") {
402 toolchain_cpu = "arm" 421 toolchain_args = {
403 toolchain_os = "mac" 422 current_cpu = "arm"
423 current_os = "mac"
424 }
404 } 425 }
405 426
406 mac_toolchain("clang_x64") { 427 mac_toolchain("clang_x64") {
407 toolchain_cpu = "x64" 428 toolchain_args = {
408 toolchain_os = "mac" 429 current_cpu = "x64"
430 current_os = "mac"
431 }
409 } 432 }
410 433
411 if (is_ios) { 434 if (is_ios) {
412 mac_toolchain("ios_clang_arm") { 435 mac_toolchain("ios_clang_arm") {
413 toolchain_cpu = "arm" 436 toolchain_args = {
414 toolchain_os = "ios" 437 current_cpu = "arm"
438 current_os = "ios"
439 }
415 } 440 }
416 441
417 mac_toolchain("ios_clang_arm64") { 442 mac_toolchain("ios_clang_arm64") {
418 toolchain_cpu = "arm64" 443 toolchain_args = {
419 toolchain_os = "ios" 444 current_cpu = "arm64"
445 current_os = "ios"
446 }
420 } 447 }
421 448
422 mac_toolchain("ios_clang_x86") { 449 mac_toolchain("ios_clang_x86") {
423 toolchain_cpu = "x86" 450 toolchain_args = {
424 toolchain_os = "ios" 451 current_cpu = "x86"
452 current_os = "ios"
453 }
425 } 454 }
426 455
427 mac_toolchain("ios_clang_x64") { 456 mac_toolchain("ios_clang_x64") {
428 toolchain_cpu = "x64" 457 toolchain_args = {
429 toolchain_os = "ios" 458 current_cpu = "x64"
459 current_os = "ios"
460 }
430 } 461 }
431 } 462 }
OLDNEW
« no previous file with comments | « build/toolchain/linux/BUILD.gn ('k') | build/toolchain/nacl/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698