aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages/Package.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages/Package.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/Package.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java
index 4ec65dd3b0..ec5806869a 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Package.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java
@@ -39,6 +39,7 @@ import com.google.devtools.build.lib.util.SpellChecker;
import com.google.devtools.build.lib.vfs.Canonicalizer;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -751,6 +752,8 @@ public class Package {
private List<String> features = new ArrayList<>();
private List<Event> events = Lists.newArrayList();
private List<Postable> posts = Lists.newArrayList();
+ @Nullable String ioExceptionMessage = null;
+ @Nullable private IOException ioException = null;
private boolean containsErrors = false;
private License defaultLicense = License.NO_LICENSE;
@@ -928,6 +931,12 @@ public class Package {
return this;
}
+ Builder setIOExceptionAndMessage(IOException e, String message) {
+ this.ioException = e;
+ this.ioExceptionMessage = message;
+ return setContainsErrors();
+ }
+
/**
* Declares that errors were encountering while loading this package.
*/
@@ -1284,11 +1293,15 @@ public class Package {
this.registeredToolchainLabels.addAll(toolchains);
}
- private Builder beforeBuild(boolean discoverAssumedInputFiles) throws InterruptedException {
+ private Builder beforeBuild(boolean discoverAssumedInputFiles)
+ throws InterruptedException, NoSuchPackageException {
Preconditions.checkNotNull(pkg);
Preconditions.checkNotNull(filename);
Preconditions.checkNotNull(buildFileLabel);
Preconditions.checkNotNull(makeEnv);
+ if (ioException != null) {
+ throw new NoSuchPackageException(getPackageIdentifier(), ioExceptionMessage, ioException);
+ }
// Freeze subincludes.
subincludes = (subincludes == null)
? Collections.<Label, Path>emptyMap()
@@ -1337,7 +1350,7 @@ public class Package {
}
/** Intended for use by {@link com.google.devtools.build.lib.skyframe.PackageFunction} only. */
- public Builder buildPartial() throws InterruptedException {
+ public Builder buildPartial() throws InterruptedException, NoSuchPackageException {
if (alreadyBuilt) {
return this;
}
@@ -1385,15 +1398,16 @@ public class Package {
return externalPackageData;
}
- public Package build() throws InterruptedException {
+ public Package build() throws InterruptedException, NoSuchPackageException {
return build(/*discoverAssumedInputFiles=*/ true);
}
/**
- * Build the package, optionally adding any labels in the package not already associated with
- * a target as an input file.
+ * Build the package, optionally adding any labels in the package not already associated with a
+ * target as an input file.
*/
- public Package build(boolean discoverAssumedInputFiles) throws InterruptedException {
+ public Package build(boolean discoverAssumedInputFiles)
+ throws InterruptedException, NoSuchPackageException {
if (alreadyBuilt) {
return pkg;
}