Skip to content

Commit 19979e6

Browse files
brentleyjonescopybara-github
authored andcommitted
Update unknown Xcode version error message and provide an environment variable to force re-evaluation
As of c747ae7, you need to run `bazel sync --configure` instead of `bazel shutdown`, to force re-finding of Xcode versions. Certain setups have a hard time running that new command, versus previously only having to cause Bazel to restart. To accommodate that, I’ve also added the `XCODE_VERSION` variable to `environ` (to match a similar use defined here: bazelbuild/apple_support@ddf25c2), which allows those setups to force the re-evaluation by using `--repo_env`. And since the `default` attribute is influenced by `DEVELOPER_DIR`, I've included that in `environ` as well. Closes #19512. PiperOrigin-RevId: 565610471 Change-Id: Ideca7165308ce53fdf1ce22b31eeb7a9e681dedc
1 parent 5009677 commit 19979e6

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/main/java/com/google/devtools/build/lib/rules/apple/XcodeConfig.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ private static Map.Entry<XcodeVersionRuleData, Availability> resolveXcodeFromLoc
388388
} else if (specifiedVersionFromRemote != null) {
389389
ruleContext.ruleWarning(
390390
String.format(
391-
"--xcode_version=%1$s specified, but it is not available locally. Your build"
392-
+ " will fail if any actions require a local Xcode. If you believe you have"
393-
+ " '%1$s' installed, try running \"blaze shutdown\", and then re-run your"
394-
+ " command. localy available versions: [%2$s]. remotely available"
395-
+ " versions: [%3$s]",
391+
"--xcode_version=%1$s specified, but it is not available locally. Your build will"
392+
+ " fail if any actions require a local Xcode. If you believe you have '%1$s'"
393+
+ " installed, try running \"blaze sync --configure\", and then re-run your"
394+
+ " command. localy available versions: [%2$s]. remotely available versions:"
395+
+ " [%3$s]",
396396
versionOverrideFlag,
397397
printableXcodeVersions(localVersions.getAvailableVersions()),
398398
printableXcodeVersions(remoteVersions.getAvailableVersions())));
@@ -403,7 +403,7 @@ private static Map.Entry<XcodeVersionRuleData, Availability> resolveXcodeFromLoc
403403
"--xcode_version=%1$s specified, but '%1$s' is not an available Xcode version."
404404
+ " localy available versions: [%2$s]. remotely available versions:"
405405
+ " [%3$s]. If you believe you have '%1$s' installed, try running \"blaze"
406-
+ " shutdown\", and then re-run your command.",
406+
+ " sync --configure\", and then re-run your command.",
407407
versionOverrideFlag,
408408
printableXcodeVersions(localVersions.getAvailableVersions()),
409409
printableXcodeVersions(remoteVersions.getAvailableVersions())));
@@ -457,10 +457,10 @@ private static Map.Entry<XcodeVersionRuleData, Availability> resolveXcodeFromLoc
457457
checkState(defaultVersion != null);
458458
return Maps.immutableEntry(defaultVersion, Availability.BOTH);
459459
} else { // Use the local default.
460-
ruleContext.ruleWarning(
461-
"You passed --experimental_prefer_mutual_xcode=false, which prevents Bazel from"
462-
+ " selecting an Xcode version that optimizes your performance. Please consider"
463-
+ " using --experimental_prefer_mutual_xcode=true.");
460+
ruleContext.ruleWarning(
461+
"You passed --experimental_prefer_mutual_xcode=false, which prevents Bazel from"
462+
+ " selecting an Xcode version that optimizes your performance. Please consider"
463+
+ " using --experimental_prefer_mutual_xcode=true.");
464464
return Maps.immutableEntry(localVersions.getDefaultVersion(), Availability.LOCAL);
465465
}
466466
}

tools/osx/xcode_configure.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ def _impl(repository_ctx):
295295
repository_ctx.file("BUILD", build_contents)
296296

297297
xcode_autoconf = repository_rule(
298+
environ = [
299+
"DEVELOPER_DIR",
300+
"XCODE_VERSION",
301+
],
298302
implementation = _impl,
299303
configure = True,
300304
attrs = {

0 commit comments

Comments
 (0)