Skip to content

Commit

Permalink
Do not consider //external: a repository-local reference.
Browse files Browse the repository at this point in the history
Fixes #360.

--
MOS_MIGRATED_REVID=101360551
  • Loading branch information
lberki authored and laszlocsomor committed Aug 25, 2015
1 parent 81fb6e7 commit 29c4387
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public abstract class AbstractAttributeMapper implements AttributeMap {

private static final PathFragment VISIBILITY = new PathFragment("visibility");
private static final PathFragment EXTERNAL = new PathFragment("external");

private final Package pkg;
private final RuleClass ruleClass;
Expand Down Expand Up @@ -164,8 +165,9 @@ protected void visitLabels(Attribute attribute, AcceptsLabelAttribute observer)
// generally tools, which go to the main repository.
absoluteLabel = label;
} else if (label.getPackageIdentifier().getRepository().isDefault()
&& VISIBILITY.equals(label.getPackageIdentifier().getPackageFragment())) {
// //visibility: labels must also be special-cased :(
&& (VISIBILITY.equals(label.getPackageIdentifier().getPackageFragment())
|| EXTERNAL.equals(label.getPackageIdentifier().getPackageFragment()))) {
// //visibility: and //external: labels must also be special-cased :(
absoluteLabel = label;
} else {
absoluteLabel = ruleLabel.resolveRepositoryRelative(label);
Expand Down
38 changes: 37 additions & 1 deletion src/test/shell/bazel/local_repository_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ EOF
assert_contains "Michaelangelo" bazel-genfiles/external/mutant/tmnt
}

function test_local_deps() {
function test_external_deps_in_remote_repo() {
local r=$TEST_TMPDIR/r
rm -fr $r
mkdir -p $r
Expand All @@ -491,6 +491,42 @@ local_repository(
path = "$r",
)
bind(
name = "e",
actual = "@r//:g",
)
EOF

cat > $r/BUILD <<EOF
genrule(
name = "r",
srcs = ["//external:e"],
outs = ["r.out"],
cmd = "cp \$< \$@",
)
genrule(
name = "g",
srcs = [],
outs = ["g.out"],
cmd = "echo GOLF > \$@",
visibility = ["//visibility:public"],
)
EOF

bazel build @r//:r || fail "build failed"
assert_contains "GOLF" bazel-genfiles/external/r/r.out
}

function test_local_deps() {
local r=$TEST_TMPDIR/r
rm -fr $r
mkdir -p $r
cat > WORKSPACE <<EOF
local_repository(
name = "r",
path = "$r",
)
EOF

mkdir -p $r/a
Expand Down

0 comments on commit 29c4387

Please sign in to comment.