Skip to content

Commit

Permalink
Make workspace cycle reporting a little more flexible
Browse files Browse the repository at this point in the history
Fixes bazelbuild#2999.

PiperOrigin-RevId: 157222957
  • Loading branch information
kchodorow authored and laszlocsomor committed May 29, 2017
1 parent 9797560 commit 2c3b896
Showing 1 changed file with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,30 @@ public String apply(SkyKey input) {
// BUILD file.
eventHandler.handle(Event.error(null, cycleMessage.toString()));
return true;
} else if (Iterables.any(cycle, IS_PACKAGE_LOOKUP) && Iterables.any(cycle, IS_WORKSPACE_FILE)
&& (IS_REPOSITORY_DIRECTORY.apply(lastPathElement)
} else if (Iterables.any(cycle, IS_WORKSPACE_FILE)
|| IS_REPOSITORY_DIRECTORY.apply(lastPathElement)
|| IS_PACKAGE_SKY_KEY.apply(lastPathElement)
|| IS_EXTERNAL_PACKAGE.apply(lastPathElement)
|| IS_LOCAL_REPOSITORY_LOOKUP.apply(lastPathElement))) {
|| IS_LOCAL_REPOSITORY_LOOKUP.apply(lastPathElement)) {
// We have a cycle in the workspace file, report as such.
Label fileLabel =
(Label) Iterables.getLast(Iterables.filter(cycle, IS_AST_FILE_LOOKUP)).argument();
String repositoryName = fileLabel.getPackageIdentifier().getRepository().strippedName();
eventHandler.handle(Event.error(null,
"Failed to load Skylark extension '" + fileLabel.toString() + "'.\n"
+ "It usually happens when the repository is not defined prior to being used.\n"
+ "Maybe repository '" + repositoryName
+ "' was defined later in your WORKSPACE file?"));
return true;
if (Iterables.any(cycle, IS_AST_FILE_LOOKUP)) {
Label fileLabel =
(Label) Iterables.getLast(Iterables.filter(cycle, IS_AST_FILE_LOOKUP)).argument();
String repositoryName = fileLabel.getPackageIdentifier().getRepository().strippedName();
eventHandler.handle(Event.error(null,
"Failed to load Skylark extension '" + fileLabel.toString() + "'.\n"
+ "It usually happens when the repository is not defined prior to being used.\n"
+ "Maybe repository '" + repositoryName
+ "' was defined later in your WORKSPACE file?"));
return true;
} else if (Iterables.any(cycle, IS_PACKAGE_LOOKUP)) {
eventHandler.handle(
Event.error(null, "cycle detected loading "
+ String.join(
" ", lastPathElement.functionName().toString().toLowerCase().split("_"))
+ " '" + lastPathElement.argument().toString() + "'"));
return true;
}
}
return false;
}
Expand Down

0 comments on commit 2c3b896

Please sign in to comment.