Skip to content

Commit 008f743

Browse files
brentleyjonescopybara-github
authored andcommitted
Consider DEVELOPER_DIR when building wrapped_clang
Resolves #11716, which partially addresses #8902. With this change, and some careful environment manipulation (probably in a wrapper script) you can ensure that `wrapped_clang` is built with the correct version of Xcode. Closes #11719. PiperOrigin-RevId: 338465098
1 parent 3d6d0c9 commit 008f743

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

tools/cpp/cc_configure.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ cc_autoconf = repository_rule(
166166
"CC_CONFIGURE_DEBUG",
167167
"CC_TOOLCHAIN_NAME",
168168
"CPLUS_INCLUDE_PATH",
169+
"DEVELOPER_DIR",
169170
"GCOV",
170171
"HOMEBREW_RUBY_PATH",
171172
"SYSTEMROOT",

tools/cpp/osx_cc_configure.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ def _get_escaped_xcode_cxx_inc_directories(repository_ctx, cc, xcode_toolchains)
4747
return include_dirs
4848

4949
def compile_cc_file(repository_ctx, src_name, out_name):
50+
env = repository_ctx.os.environ
5051
xcrun_result = repository_ctx.execute([
5152
"env",
5253
"-i",
54+
"DEVELOPER_DIR={}".format(env.get("DEVELOPER_DIR", default = "")),
5355
"xcrun",
5456
"--sdk",
5557
"macosx",

tools/osx/xcode_configure.bzl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ def run_xcode_locator(repository_ctx, xcode_locator_src_label):
115115
to build and run xcode-locator, or None if the run was successful.
116116
"""
117117
xcodeloc_src_path = str(repository_ctx.path(xcode_locator_src_label))
118+
env = repository_ctx.os.environ
118119
xcrun_result = repository_ctx.execute([
119120
"env",
120121
"-i",
122+
"DEVELOPER_DIR={}".format(env.get("DEVELOPER_DIR", default = "")),
121123
"xcrun",
122124
"--sdk",
123125
"macosx",
@@ -181,10 +183,15 @@ def run_xcode_locator(repository_ctx, xcode_locator_src_label):
181183

182184
def _darwin_build_file(repository_ctx):
183185
"""Evaluates local system state to create xcode_config and xcode_version targets."""
184-
xcodebuild_result = repository_ctx.execute(
185-
["env", "-i", "xcrun", "xcodebuild", "-version"],
186-
_EXECUTE_TIMEOUT,
187-
)
186+
env = repository_ctx.os.environ
187+
xcodebuild_result = repository_ctx.execute([
188+
"env",
189+
"-i",
190+
"DEVELOPER_DIR={}".format(env.get("DEVELOPER_DIR", default = "")),
191+
"xcrun",
192+
"xcodebuild",
193+
"-version",
194+
], _EXECUTE_TIMEOUT)
188195

189196
(toolchains, xcodeloc_err) = run_xcode_locator(
190197
repository_ctx,

0 commit comments

Comments
 (0)