aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-01-29 15:04:31 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-01-29 15:36:36 +0000
commit734e7f7b63c9c00a6aaa60769481a11bc4f76346 (patch)
treed51ce64080b580a98540ef7fd16b5ec5369d9e22 /src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java
parentf9f2e10dcbbf0efade6a9c9cf21dd3dde8e55f6b (diff)
Parse the workspace name when a repository is loaded
Moved RepositoryValue to RepositoryDirectoryValue so that it could be cached (and not re-downloaded) even if the WorkspaceAST caused a Skyframe restart (as mentioned in https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java#L130-L133). -- MOS_MIGRATED_REVID=113358489
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java65
1 files changed, 20 insertions, 45 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java
index e647b817b2..2f8da11aa2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RepositoryValue.java
@@ -1,4 +1,4 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
+// Copyright 2016 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,49 +16,31 @@ package com.google.devtools.build.lib.skyframe;
import com.google.common.base.Objects;
import com.google.devtools.build.lib.cmdline.RepositoryName;
+import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryValue;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
/**
- * A local view of an external repository.
+ * A repository's name and directory.
*/
public class RepositoryValue implements SkyValue {
- private final Path path;
- private final boolean fetchingDelayed;
-
- private RepositoryValue(Path path, boolean fetchingDelayed) {
- this.path = path;
- this.fetchingDelayed = fetchingDelayed;
- }
-
- /**
- * Creates an immutable external repository.
- */
- public static RepositoryValue create(Path repositoryDirectory) {
- return new RepositoryValue(repositoryDirectory, false);
- }
+ private final RepositoryName repositoryName;
+ private final RepositoryDirectoryValue repositoryDirectory;
/**
- * Creates a value that represents a repository whose fetching has been delayed by a
- * {@code --nofetch} command line option.
+ * Creates a repository with a given name in a certain directory.
*/
- public static RepositoryValue fetchingDelayed(Path repositoryDirectory) {
- return new RepositoryValue(repositoryDirectory, true);
+ public RepositoryValue(RepositoryName repositoryName, RepositoryDirectoryValue repository) {
+ this.repositoryName = repositoryName;
+ this.repositoryDirectory = repository;
}
/**
- * Returns the path to the directory containing the repository's contents. This directory is
- * guaranteed to exist. It may contain a full Bazel repository (with a WORKSPACE file,
- * directories, and BUILD files) or simply contain a file (or set of files) for, say, a jar from
- * Maven.
+ * Returns the path to the repository.
*/
public Path getPath() {
- return path;
- }
-
- public boolean isFetchingDelayed() {
- return fetchingDelayed;
+ return repositoryDirectory.getPath();
}
@Override
@@ -66,28 +48,21 @@ public class RepositoryValue implements SkyValue {
if (this == other) {
return true;
}
-
- if (other instanceof RepositoryValue) {
- RepositoryValue otherValue = (RepositoryValue) other;
- return path.equals(otherValue.path);
+ if (other == null || getClass() != other.getClass()) {
+ return false;
}
- return false;
- }
- @Override
- public int hashCode() {
- return Objects.hashCode(path);
+ RepositoryValue that = (RepositoryValue) other;
+ return Objects.equal(repositoryName, that.repositoryName)
+ && Objects.equal(repositoryDirectory, that.repositoryDirectory);
}
@Override
- public String toString() {
- return path.getPathString();
+ public int hashCode() {
+ return Objects.hashCode(repositoryName, repositoryDirectory);
}
- /**
- * Creates a key from the given repository name.
- */
- public static SkyKey key(RepositoryName repository) {
- return new SkyKey(SkyFunctions.REPOSITORY, repository);
+ static SkyKey key(RepositoryName repositoryName) {
+ return new SkyKey(SkyFunctions.REPOSITORY, repositoryName);
}
}