Skip to content

Commit

Permalink
Update unknown Xcode version error message and provide an environment…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
brentleyjones authored and copybara-github committed Sep 15, 2023
1 parent 5009677 commit 19979e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ private static Map.Entry<XcodeVersionRuleData, Availability> resolveXcodeFromLoc
} else if (specifiedVersionFromRemote != null) {
ruleContext.ruleWarning(
String.format(
"--xcode_version=%1$s specified, but it is not available locally. Your build"
+ " will fail if any actions require a local Xcode. If you believe you have"
+ " '%1$s' installed, try running \"blaze shutdown\", and then re-run your"
+ " command. localy available versions: [%2$s]. remotely available"
+ " versions: [%3$s]",
"--xcode_version=%1$s specified, but it is not available locally. Your build will"
+ " fail if any actions require a local Xcode. If you believe you have '%1$s'"
+ " installed, try running \"blaze sync --configure\", and then re-run your"
+ " command. localy available versions: [%2$s]. remotely available versions:"
+ " [%3$s]",
versionOverrideFlag,
printableXcodeVersions(localVersions.getAvailableVersions()),
printableXcodeVersions(remoteVersions.getAvailableVersions())));
Expand All @@ -403,7 +403,7 @@ private static Map.Entry<XcodeVersionRuleData, Availability> resolveXcodeFromLoc
"--xcode_version=%1$s specified, but '%1$s' is not an available Xcode version."
+ " localy available versions: [%2$s]. remotely available versions:"
+ " [%3$s]. If you believe you have '%1$s' installed, try running \"blaze"
+ " shutdown\", and then re-run your command.",
+ " sync --configure\", and then re-run your command.",
versionOverrideFlag,
printableXcodeVersions(localVersions.getAvailableVersions()),
printableXcodeVersions(remoteVersions.getAvailableVersions())));
Expand Down Expand Up @@ -457,10 +457,10 @@ private static Map.Entry<XcodeVersionRuleData, Availability> resolveXcodeFromLoc
checkState(defaultVersion != null);
return Maps.immutableEntry(defaultVersion, Availability.BOTH);
} else { // Use the local default.
ruleContext.ruleWarning(
"You passed --experimental_prefer_mutual_xcode=false, which prevents Bazel from"
+ " selecting an Xcode version that optimizes your performance. Please consider"
+ " using --experimental_prefer_mutual_xcode=true.");
ruleContext.ruleWarning(
"You passed --experimental_prefer_mutual_xcode=false, which prevents Bazel from"
+ " selecting an Xcode version that optimizes your performance. Please consider"
+ " using --experimental_prefer_mutual_xcode=true.");
return Maps.immutableEntry(localVersions.getDefaultVersion(), Availability.LOCAL);
}
}
Expand Down
4 changes: 4 additions & 0 deletions tools/osx/xcode_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ def _impl(repository_ctx):
repository_ctx.file("BUILD", build_contents)

xcode_autoconf = repository_rule(
environ = [
"DEVELOPER_DIR",
"XCODE_VERSION",
],
implementation = _impl,
configure = True,
attrs = {
Expand Down

0 comments on commit 19979e6

Please sign in to comment.