Skip to content

Commit

Permalink
Report meaningful message when both --enable_workspace and --enable_b…
Browse files Browse the repository at this point in the history
…zlmod are false, part 2

Similar to 3f9fb7f; sometimes RepositoryMappingFunction gets invoked before WorkspaceNameFunction (for example, when platform mapping flags are in place).

Partially fixes kythe/kythe#6135.

PiperOrigin-RevId: 670848064
Change-Id: Ia99a80795297f43eea12e0c80241e2c2a430ac8f
  • Loading branch information
Wyverald authored and copybara-github committed Sep 4, 2024
1 parent d925dee commit 04a1674
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public SkyValue compute(SkyKey skyKey, Environment env)
boolean enableBzlmod = starlarkSemantics.getBool(BuildLanguageOptions.ENABLE_BZLMOD);
boolean enableWorkspace = starlarkSemantics.getBool(BuildLanguageOptions.ENABLE_WORKSPACE);

if (!enableBzlmod && !enableWorkspace) {
throw new RepositoryMappingFunctionException(
"Both --enable_bzlmod and --enable_workspace are disabled, but one of them must be"
+ " enabled to fetch external dependencies.");
}

if (enableBzlmod) {
if (StarlarkBuiltinsValue.isBuiltinsRepo(repositoryName)) {
// If tools repo is not set, repo mapping for @_builtins should be always fallback.
Expand Down Expand Up @@ -214,7 +220,7 @@ private RepositoryMappingValue computeFromWorkspace(
throws RepositoryMappingFunctionException {
Package externalPackage = externalPackageValue.getPackage();
if (externalPackage.containsErrors()) {
throw new RepositoryMappingFunctionException();
throw new RepositoryMappingFunctionException("error evaluating WORKSPACE");
}
RepositoryMapping workspaceMapping =
RepositoryMapping.createAllowingFallback(
Expand All @@ -239,9 +245,9 @@ private static Optional<ModuleExtensionId> maybeGetModuleExtensionForRepo(
}

private static class RepositoryMappingFunctionException extends SkyFunctionException {
RepositoryMappingFunctionException() {
RepositoryMappingFunctionException(String message) {
super(
new BuildFileContainsErrorsException(LabelConstants.EXTERNAL_PACKAGE_IDENTIFIER),
new BuildFileContainsErrorsException(LabelConstants.EXTERNAL_PACKAGE_IDENTIFIER, message),
Transience.PERSISTENT);
}
}
Expand Down

0 comments on commit 04a1674

Please sign in to comment.