Skip to content

Commit

Permalink
Make source manifest caching catch external runfile changes
Browse files Browse the repository at this point in the history
--
MOS_MIGRATED_REVID=120442698
  • Loading branch information
kchodorow committed Apr 21, 2016
1 parent f763379 commit 790d2f6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public String apply(PathFragment input) {
}
};

boolean getLegacyExternalRunfiles() {
return legacyRepositoryStructure;
}

/**
* An entry in the runfiles map.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ protected String getRawProgressMessage() {
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()) {
Expand Down Expand Up @@ -219,7 +220,7 @@ protected String computeKey() {
/**
* Supported manifest writing strategies.
*/
public static enum ManifestType implements ManifestWriter {
public enum ManifestType implements ManifestWriter {

/**
* Writes each line as:
Expand Down
39 changes: 39 additions & 0 deletions src/test/shell/bazel/runfiles_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 790d2f6

Please sign in to comment.