diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java | 64 |
1 files changed, 31 insertions, 33 deletions
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) { |