Index: build/toolchain/mac/BUILD.gn |
diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn |
index 0c00e995fffe139ac39badd12790acbad3a78a7a..2bb96c75cbeb333f20ab89a7243874fedc99099c 100644 |
--- a/build/toolchain/mac/BUILD.gn |
+++ b/build/toolchain/mac/BUILD.gn |
@@ -62,6 +62,12 @@ tool_versions = |
# build args in this definition. |
template("mac_toolchain") { |
toolchain(target_name) { |
+ if (use_system_xcode) { |
+ env_wrapper = "" |
+ } else { |
+ env_wrapper = "export DEVELOPER_DIR=$hermetic_xcode_path; " |
+ } |
+ |
# When invoking this toolchain not as the default one, these args will be |
# passed to the build. They are ignored when this is the default toolchain. |
assert(defined(invoker.toolchain_args), |
@@ -212,7 +218,7 @@ template("mac_toolchain") { |
tool("alink") { |
script = |
rebase_path("//build/toolchain/mac/filter_libtool.py", root_build_dir) |
- command = "rm -f {{output}} && TOOL_VERSION=${tool_versions.filter_libtool} python $script libtool -static {{arflags}} -o {{output}} {{inputs}}" |
+ command = "$env_wrapper rm -f {{output}} && TOOL_VERSION=${tool_versions.filter_libtool} python $script libtool -static {{arflags}} -o {{output}} {{inputs}}" |
description = "LIBTOOL-STATIC {{output}}" |
outputs = [ |
"{{output_dir}}/{{target_output_name}}{{output_extension}}", |
@@ -250,7 +256,7 @@ template("mac_toolchain") { |
replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then mv \"$temporary_tocname\" \"$tocname\"" |
extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm -gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" |
- command = "if $does_reexport_command ; then $link_command && $extract_toc_command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporary_tocname\" && $replace_command ; fi; fi" |
+ command = "$env_wrapper if $does_reexport_command ; then $link_command && $extract_toc_command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporary_tocname\" && $replace_command ; fi; fi" |
rspfile_content = "{{inputs_newline}}" |
@@ -291,7 +297,7 @@ template("mac_toolchain") { |
rspfile = sofile + ".rsp" |
pool = "//build/toolchain:link_pool($default_toolchain)" |
- link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl,-filelist,\"$rspfile\"" |
+ link_command = "$env_wrapper $linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl,-filelist,\"$rspfile\"" |
if (is_component_build) { |
link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{output_extension}}" |
} |
@@ -334,7 +340,7 @@ template("mac_toolchain") { |
# do for command-line arguments. Thus any source names with spaces, or |
# label names with spaces (which GN bases the output paths on) will be |
# corrupted by this process. Don't use spaces for source files or labels. |
- command = "$linker_driver $ld $dsym_switch {{ldflags}} -o \"$outfile\" -Wl,-filelist,\"$rspfile\" {{solibs}} {{libs}}" |
+ command = "$env_wrapper $linker_driver $ld $dsym_switch {{ldflags}} -o \"$outfile\" -Wl,-filelist,\"$rspfile\" {{solibs}} {{libs}}" |
description = "LINK $outfile" |
rspfile_content = "{{inputs_newline}}" |
outputs = [ |
@@ -400,7 +406,7 @@ template("mac_toolchain") { |
_sdk_name = mac_sdk_name |
_min_deployment_target = mac_deployment_target |
} |
- command = "rm -f {{output}} && " + |
+ command = "$env_wrapper rm -f {{output}} && " + |
"TOOL_VERSION=${tool_versions.compile_xcassets} " + |
"python $_tool -p $_sdk_name -t $_min_deployment_target " + |
"-T {{bundle_product_type}} -o {{output}} {{inputs}}" |