aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/repository
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/repository')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryBuildFileHandler.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java64
4 files changed, 36 insertions, 42 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java
index 258cb960a0..b5f9071456 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java
@@ -21,10 +21,8 @@ import com.google.devtools.build.lib.skyframe.FileValue;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
-import com.google.devtools.build.skyframe.SkyFunctionException;
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
import com.google.devtools.build.skyframe.SkyValue;
-
import java.io.IOException;
/**
@@ -40,7 +38,7 @@ public class LocalRepositoryFunction extends RepositoryFunction {
@Override
public SkyValue fetch(
Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env)
- throws SkyFunctionException {
+ throws InterruptedException, RepositoryFunctionException {
PathFragment pathFragment = RepositoryFunction.getTargetPath(rule, directories.getWorkspace());
try {
outputDirectory.createSymbolicLink(pathFragment);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java
index eb77b57211..db79483635 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java
@@ -27,7 +27,6 @@ import com.google.devtools.build.skyframe.SkyFunction.Environment;
import com.google.devtools.build.skyframe.SkyFunctionException;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
-
import java.io.IOException;
/**
@@ -43,7 +42,7 @@ public class NewLocalRepositoryFunction extends RepositoryFunction {
@Override
public SkyValue fetch(
Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env)
- throws SkyFunctionException {
+ throws SkyFunctionException, InterruptedException {
NewRepositoryBuildFileHandler buildFileHandler =
new NewRepositoryBuildFileHandler(directories.getWorkspace());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryBuildFileHandler.java b/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryBuildFileHandler.java
index 456d80842f..18654e1da1 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryBuildFileHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryBuildFileHandler.java
@@ -32,7 +32,6 @@ import com.google.devtools.build.lib.vfs.RootedPath;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
import com.google.devtools.build.skyframe.SkyKey;
-
import java.io.IOException;
/**
@@ -59,7 +58,7 @@ public class NewRepositoryBuildFileHandler {
* retrieved, written, or symlinked.
*/
public boolean prepareBuildFile(Rule rule, Environment env)
- throws RepositoryFunctionException {
+ throws RepositoryFunctionException, InterruptedException {
AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
boolean hasBuildFile = mapper.isAttributeValueExplicitlySpecified("build_file");
@@ -115,7 +114,7 @@ public class NewRepositoryBuildFileHandler {
}
private FileValue getBuildFileValue(Rule rule, Environment env)
- throws RepositoryFunctionException {
+ throws RepositoryFunctionException, InterruptedException {
AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
String buildFileAttribute = mapper.get("build_file", Type.STRING);
RootedPath rootedBuild;
@@ -200,4 +199,4 @@ public class NewRepositoryBuildFileHandler {
Path buildFilePath = outputDirectory.getRelative("BUILD");
RepositoryFunction.createSymbolicLink(buildFilePath, buildFileValue.realRootedPath().asPath());
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java
index 98e4ad9e71..cb01f3120c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java
@@ -132,21 +132,22 @@ public abstract class RepositoryFunction {
*
* <p>The {@code env} argument can be used to fetch Skyframe dependencies the repository
* implementation needs on the following conditions:
+ *
* <ul>
- * <li>When a Skyframe value is missing, fetching must be restarted, thus, in order to avoid
- * doing duplicate work, it's better to first request the Skyframe dependencies you need and
- * only then start doing anything costly.
- * <li>The output directory must be populated from within this method (and not from within
- * another SkyFunction). This is because if it was populated in another SkyFunction, the
- * repository function would be restarted <b>after</b> that SkyFunction has been run, and
- * it would wipe the output directory clean.
+ * <li>When a Skyframe value is missing, fetching must be restarted, thus, in order to avoid doing
+ * duplicate work, it's better to first request the Skyframe dependencies you need and only
+ * then start doing anything costly.
+ * <li>The output directory must be populated from within this method (and not from within another
+ * SkyFunction). This is because if it was populated in another SkyFunction, the repository
+ * function would be restarted <b>after</b> that SkyFunction has been run, and it would wipe
+ * the output directory clean.
* </ul>
*/
@ThreadSafe
@Nullable
public abstract SkyValue fetch(
Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env)
- throws SkyFunctionException, InterruptedException;
+ throws SkyFunctionException, InterruptedException;
/**
* Whether fetching is done using local operations only.
@@ -164,7 +165,7 @@ public abstract class RepositoryFunction {
* to keep it working somehow)
*/
protected byte[] getRuleSpecificMarkerData(Rule rule, Environment env)
- throws RepositoryFunctionException {
+ throws RepositoryFunctionException, InterruptedException {
return new byte[] {};
}
@@ -265,7 +266,7 @@ public abstract class RepositoryFunction {
*/
@Nullable
public static Rule getRule(String repository, Environment env)
- throws RepositoryFunctionException {
+ throws RepositoryFunctionException, InterruptedException {
SkyKey packageLookupKey = PackageLookupValue.key(Label.EXTERNAL_PACKAGE_IDENTIFIER);
PackageLookupValue packageLookupValue = (PackageLookupValue) env.getValue(packageLookupKey);
@@ -298,9 +299,8 @@ public abstract class RepositoryFunction {
}
@Nullable
- public static Rule getRule(
- String ruleName, @Nullable String ruleClassName, Environment env)
- throws RepositoryFunctionException {
+ public static Rule getRule(String ruleName, @Nullable String ruleClassName, Environment env)
+ throws RepositoryFunctionException, InterruptedException {
try {
return getRule(RepositoryName.create("@" + ruleName), ruleClassName, env);
} catch (LabelSyntaxException e) {
@@ -310,15 +310,15 @@ public abstract class RepositoryFunction {
}
/**
- * Uses a remote repository name to fetch the corresponding Rule describing how to get it.
- * This should be called from {@link SkyFunction#compute} functions, which should return null if
- * this returns null. If {@code ruleClassName} is set, the rule found must have a matching rule
- * class name.
+ * Uses a remote repository name to fetch the corresponding Rule describing how to get it. This
+ * should be called from {@link SkyFunction#compute} functions, which should return null if this
+ * returns null. If {@code ruleClassName} is set, the rule found must have a matching rule class
+ * name.
*/
@Nullable
public static Rule getRule(
RepositoryName repositoryName, @Nullable String ruleClassName, Environment env)
- throws RepositoryFunctionException {
+ throws RepositoryFunctionException, InterruptedException {
Rule rule = getRule(repositoryName.strippedName(), env);
Preconditions.checkState(
rule == null || ruleClassName == null || rule.getRuleClass().equals(ruleClassName),
@@ -327,12 +327,12 @@ public abstract class RepositoryFunction {
}
/**
- * Adds the repository's directory to the graph and, if it's a symlink, resolves it to an
- * actual directory.
+ * Adds the repository's directory to the graph and, if it's a symlink, resolves it to an actual
+ * directory.
*/
@Nullable
- public static FileValue getRepositoryDirectory(Path repositoryDirectory, Environment env)
- throws RepositoryFunctionException {
+ protected static FileValue getRepositoryDirectory(Path repositoryDirectory, Environment env)
+ throws RepositoryFunctionException, InterruptedException {
SkyKey outputDirectoryKey = FileValue.key(RootedPath.toRootedPath(
repositoryDirectory, PathFragment.EMPTY_FRAGMENT));
FileValue value;
@@ -354,21 +354,19 @@ public abstract class RepositoryFunction {
}
/**
- * For files that are under $OUTPUT_BASE/external, add a dependency on the corresponding rule
- * so that if the WORKSPACE file changes, the File/DirectoryStateValue will be re-evaluated.
+ * For files that are under $OUTPUT_BASE/external, add a dependency on the corresponding rule so
+ * that if the WORKSPACE file changes, the File/DirectoryStateValue will be re-evaluated.
*
- * Note that:
- * - We don't add a dependency on the parent directory at the package root boundary, so
- * the only transitive dependencies from files inside the package roots to external files
- * are through symlinks. So the upwards transitive closure of external files is small.
- * - The only way other than external repositories for external source files to get into the
- * skyframe graph in the first place is through symlinks outside the package roots, which we
- * neither want to encourage nor optimize for since it is not common. So the set of external
- * files is small.
+ * <p>Note that: - We don't add a dependency on the parent directory at the package root boundary,
+ * so the only transitive dependencies from files inside the package roots to external files are
+ * through symlinks. So the upwards transitive closure of external files is small. - The only way
+ * other than external repositories for external source files to get into the skyframe graph in
+ * the first place is through symlinks outside the package roots, which we neither want to
+ * encourage nor optimize for since it is not common. So the set of external files is small.
*/
public static void addExternalFilesDependencies(
RootedPath rootedPath, BlazeDirectories directories, Environment env)
- throws IOException {
+ throws IOException, InterruptedException {
Path externalRepoDir = getExternalRepositoryDirectory(directories);
PathFragment repositoryPath = rootedPath.asPath().relativeTo(externalRepoDir);
if (repositoryPath.segmentCount() == 0) {