Skip to content

Commit

Permalink
Exclude //external targets from //...
Browse files Browse the repository at this point in the history
Fixes bazelbuild#3307 and bazelbuild#1606. The problem was that TargetPatternResolver was
trying to figure out if repositories were tagged as "manual," but
repository rules don't have a "tags" field.  Repository rules shouldn't
be included by //... generally. TargetPatternResolver was just ls-ing
// to find all the "packages," so this removes external/ from consideration.

PiperOrigin-RevId: 161134437
  • Loading branch information
kchodorow authored and katre committed Jul 7, 2017
1 parent 7e0f332 commit 79e7c31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.events.Event;
Expand Down Expand Up @@ -197,6 +198,10 @@ private Iterable<SkyKey> getSubdirDeps(
&& PathPackageLocator.DEFAULT_TOP_LEVEL_EXCLUDES.contains(basename)) {
continue;
}
if (basename.equals(Label.EXTERNAL_PACKAGE_NAME.getPathString())) {
// Not a real package.
continue;
}
PathFragment subdirectory = rootRelativePath.getRelative(basename);

// If this subdirectory is one of the excluded paths, don't recurse into it.
Expand Down
13 changes: 13 additions & 0 deletions src/test/shell/bazel/empty_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,17 @@ EOF
expect_log "SCREEEECH"
}

function test_empty_external() {
mkdir foo
cd foo
touch WORKSPACE
# Create a dummy BUILD file, otherwise `bazel build` will complain that there
# were no targets to build.
cat > BUILD <<EOF
exports_files(["BUILD"])
EOF
mkdir external
bazel build ... &> $TEST_log || fail "Failed to build ..."
}

run_suite "empty package tests"

0 comments on commit 79e7c31

Please sign in to comment.