aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-04-21 14:48:24 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-04-21 14:55:08 +0000
commit790d2f6009d47fe92cf0cd92a1473bbf0141f32e (patch)
tree0b107ee4a3f6e37fa2dbf46be482744e9a5b6230
parentf7633792b14111ff783382e864d28e7657573216 (diff)
Make source manifest caching catch external runfile changes
-- MOS_MIGRATED_REVID=120442698
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java3
-rwxr-xr-xsrc/test/shell/bazel/runfiles_test.sh39
3 files changed, 45 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
index c52eabc5f9..f1c9b4f7f7 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
@@ -94,6 +94,10 @@ public final class Runfiles {
}
};
+ boolean getLegacyExternalRunfiles() {
+ return legacyRepositoryStructure;
+ }
+
/**
* An entry in the runfiles map.
*
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
index 513fdc4e21..0c45b89d25 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
@@ -192,6 +192,7 @@ public final class SourceManifestAction extends AbstractFileWriteAction {
protected String computeKey() {
Fingerprint f = new Fingerprint();
f.addString(GUID);
+ f.addBoolean(runfiles.getLegacyExternalRunfiles());
Map<PathFragment, Artifact> symlinks = runfiles.getSymlinksAsMap();
f.addInt(symlinks.size());
for (Map.Entry<PathFragment, Artifact> symlink : symlinks.entrySet()) {
@@ -219,7 +220,7 @@ public final class SourceManifestAction extends AbstractFileWriteAction {
/**
* Supported manifest writing strategies.
*/
- public static enum ManifestType implements ManifestWriter {
+ public enum ManifestType implements ManifestWriter {
/**
* Writes each line as:
diff --git a/src/test/shell/bazel/runfiles_test.sh b/src/test/shell/bazel/runfiles_test.sh
index 33205b86d2..698f319d59 100755
--- a/src/test/shell/bazel/runfiles_test.sh
+++ b/src/test/shell/bazel/runfiles_test.sh
@@ -53,4 +53,43 @@ EOF
[[ -x bazel-bin/foo/foo.runfiles/$name/foo/foo ]] || fail "No foo executable under $name"
}
+function test_external_runfiles() {
+ cat > WORKSPACE <<EOF
+workspace(name = "foo")
+
+new_local_repository(
+ name = "bar",
+ path = ".",
+ build_file = "BUILD",
+)
+EOF
+
+ cat > BUILD <<EOF
+exports_files(glob(["*"]))
+
+cc_binary(
+ name = "thing",
+ srcs = ["thing.cc"],
+ data = ["@bar//:thing.cc"],
+)
+EOF
+ cat > thing.cc <<EOF
+int main() { return 0; }
+EOF
+ bazel build --legacy_external_runfiles //:thing &> $TEST_log \
+ || fail "Build failed"
+ [[ -d bazel-bin/thing.runfiles/foo/external/bar ]] \
+ || fail "bar not found"
+
+ bazel build --nolegacy_external_runfiles //:thing &> $TEST_log \
+ || fail "Build failed"
+ [[ ! -d bazel-bin/thing.runfiles/foo/external/bar ]] \
+ || fail "Old bar still found"
+
+ bazel build --legacy_external_runfiles //:thing &> $TEST_log \
+ || fail "Build failed"
+ [[ -d bazel-bin/thing.runfiles/foo/external/bar ]] \
+ || fail "bar not recreated"
+}
+
run_suite "runfiles tests"