Skip to content

Commit 7dbabb4

Browse files
kkresscopybara-github
authored andcommitted
Part 1 of the Implementation for new 'subpackages()` built-in helper function.
Design proposal: https://docs.google.com/document/d/13UOT0GoQofxDW40ILzH2sWpUOmuYy6QZ7CUmhej9vgk/edit# This CL modifies the globber infrastructure to support an additional mode of listing sub-directories. * Add new Globber Operation enum allowing, Globber implementations to discriminate between glob, glob w/directories and the future sub-packages use-case. * Modify UnixGlob to replace Predicate and bools with UnixGlobPathDiscriminator interface for: a) Determining whether to traverse a sub-directory (previously was lambda) b) function for determing what entries to include in the List<Path> produced by UnixGlob.globAsync. These allow relatively simple re-use of the same logic for both subpackages and glob 4) Add a few tests for UnixGlob to ensure both cases continue to work as expected. PiperOrigin-RevId: 421125424
1 parent 9f288e2 commit 7dbabb4

28 files changed

Lines changed: 753 additions & 354 deletions

src/main/java/com/google/devtools/build/lib/includescanning/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ java_library(
3333
"//src/main/java/com/google/devtools/build/lib/exec:module_action_context_registry",
3434
"//src/main/java/com/google/devtools/build/lib/exec:spawn_strategy_resolver",
3535
"//src/main/java/com/google/devtools/build/lib/packages",
36+
"//src/main/java/com/google/devtools/build/lib/packages:globber",
3637
"//src/main/java/com/google/devtools/build/lib/profiler",
3738
"//src/main/java/com/google/devtools/build/lib/rules/cpp",
3839
"//src/main/java/com/google/devtools/build/lib/skyframe:containing_package_lookup_value",

src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.google.devtools.build.lib.concurrent.BlazeInterners;
3939
import com.google.devtools.build.lib.events.Event;
4040
import com.google.devtools.build.lib.includescanning.IncludeParser.Inclusion.Kind;
41+
import com.google.devtools.build.lib.packages.Globber;
4142
import com.google.devtools.build.lib.packages.NoSuchPackageException;
4243
import com.google.devtools.build.lib.profiler.Profiler;
4344
import com.google.devtools.build.lib.profiler.ProfilerTask;
@@ -348,7 +349,7 @@ ImmutableSet<Artifact> getPathLevelHintedInclusions(
348349
containingPackageLookupValue.getContainingPackageName(),
349350
containingPackageLookupValue.getContainingPackageRoot(),
350351
pattern,
351-
/*excludeDirs=*/ true,
352+
Globber.Operation.FILES,
352353
relativePath.relativeTo(packageFragment)));
353354
} catch (InvalidGlobPatternException e) {
354355
env.getListener()

src/main/java/com/google/devtools/build/lib/packages/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,36 @@ java_library(
2424
],
2525
)
2626

27+
java_library(
28+
name = "globber",
29+
srcs = ["Globber.java"],
30+
)
31+
32+
java_library(
33+
name = "globber_utils",
34+
srcs = ["GlobberUtils.java"],
35+
deps = [
36+
":globber",
37+
"//third_party:error_prone_annotations",
38+
],
39+
)
40+
2741
java_library(
2842
name = "packages",
2943
srcs = glob(
3044
["*.java"],
3145
exclude = [
3246
"BuilderFactoryForTesting.java", # see builder_factory_for_testing
47+
"Globber.java",
48+
"GlobberUtils.java",
3349
"ExecGroup.java",
3450
"ConfiguredAttributeMapper.java",
3551
],
3652
),
3753
deps = [
3854
":exec_group",
55+
":globber",
56+
":globber_utils",
3957
"//src/main/java/com/google/devtools/build/docgen/annot",
4058
"//src/main/java/com/google/devtools/build/lib/actions:execution_requirements",
4159
"//src/main/java/com/google/devtools/build/lib/actions:thread_state_receiver",

0 commit comments

Comments
 (0)