@Override public SkyValue compute(SkyKey skyKey, Environment env) throws WorkspaceFileFunctionException, InterruptedException { RootedPath workspaceRoot = (RootedPath) skyKey.argument(); FileValue workspaceFileValue = (FileValue) env.getValue(FileValue.key(workspaceRoot)); if (workspaceFileValue == null) { return null; } Path repoWorkspace = workspaceRoot.getRoot().getRelative(workspaceRoot.getRelativePath()); Builder builder = com.google.devtools.build.lib.packages.Package.newExternalPackageBuilder( repoWorkspace, packageFactory.getRuleClassProvider().getRunfilesPrefix()); try (Mutability mutability = Mutability.create("workspace %s", repoWorkspace)) { WorkspaceFactory parser = new WorkspaceFactory( builder, packageFactory.getRuleClassProvider(), mutability, installDir.getPathString()); parser.parse( ParserInputSource.create( ruleClassProvider.getDefaultWorkspaceFile(), new PathFragment("DEFAULT.WORKSPACE"))); if (!workspaceFileValue.exists()) { return new PackageValue(builder.build()); } try { parser.parse(ParserInputSource.create(repoWorkspace, workspaceFileValue.getSize())); } catch (IOException e) { throw new WorkspaceFileFunctionException(e, Transience.TRANSIENT); } } return new PackageValue(builder.build()); }
public Package getPackage() { return builder.build(); }