use of com.google.devtools.build.lib.skyframe.RepositoryValue in project bazel by bazelbuild.
the class RepositoryLoaderFunction method compute.
@Nullable
@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws SkyFunctionException, InterruptedException {
// This cannot be combined with {@link RepositoryDelegatorFunction}. RDF fetches the
// repository and must not have a Skyframe restart after writing it (otherwise the repository
// would be re-downloaded).
RepositoryName nameFromRule = (RepositoryName) skyKey.argument();
SkyKey repositoryKey = RepositoryDirectoryValue.key(nameFromRule);
RepositoryDirectoryValue repository = (RepositoryDirectoryValue) env.getValue(repositoryKey);
if (repository == null) {
return null;
}
SkyKey workspaceKey = WorkspaceFileValue.key(RootedPath.toRootedPath(repository.getPath(), new PathFragment("WORKSPACE")));
WorkspaceFileValue workspacePackage = (WorkspaceFileValue) env.getValue(workspaceKey);
if (workspacePackage == null) {
return null;
}
RepositoryName workspaceName;
try {
String workspaceNameStr = workspacePackage.getPackage().getWorkspaceName();
workspaceName = workspaceNameStr.isEmpty() ? RepositoryName.create("") : RepositoryName.create("@" + workspaceNameStr);
} catch (LabelSyntaxException e) {
throw new IllegalStateException(e);
}
if (!workspaceName.isDefault() && !workspaceName.strippedName().equals(Label.DEFAULT_REPOSITORY_DIRECTORY) && !nameFromRule.equals(workspaceName)) {
Path workspacePath = repository.getPath().getRelative("WORKSPACE");
env.getListener().handle(Event.warn(Location.fromFile(workspacePath), "Workspace name in " + workspacePath + " (" + workspaceName + ") does not match the " + "name given in the repository's definition (" + nameFromRule + "); this will " + "cause a build error in future versions"));
}
return new RepositoryValue(nameFromRule, repository);
}
Aggregations