Skip to content

Commit

Permalink
Be explicit about alowing empty globs (third part)
Browse files Browse the repository at this point in the history
There are several globs that are empty and this prevents building
with the incompatible flag #8195.
This commit just makes it explicit that empty is allowed.
  • Loading branch information
limdor committed Sep 28, 2022
1 parent 0b3c55d commit 4e4231b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void testFatApk_androidPlatformsFlag() throws Exception {
" proguard_specs = [],",
" deps = ['lib', 'native-lib'],",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res/**']))");
" resource_files = glob(['res/**'], allow_empty = True))");
useConfiguration(
"--android_platforms=//java/android/platforms:x86,//java/android/platforms:armeabi-v7a",
"--dynamic_mode=off");
Expand Down Expand Up @@ -1077,7 +1077,7 @@ public void testIncrementalDexingUsesDexArchives_binaryDependingOnAliasTarget()
"android_library(",
" name = 'dep',",
" srcs = ['dep.java'],",
" resource_files = glob(['res/**']),",
" resource_files = glob(['res/**'], allow_empty = True),",
" manifest = 'AndroidManifest.xml',",
")",
"alias(",
Expand Down Expand Up @@ -1632,7 +1632,7 @@ public void testProGuardExecutableMatchesConfiguration() throws Exception {
"java/com/google/devtools/build/jkrunchy/BUILD",
"package(default_visibility=['//visibility:public'])",
"java_binary(name = 'jkrunchy',",
" srcs = glob(['*.java']),",
" srcs = glob(['*.java'], allow_empty = True),",
" main_class = 'com.google.devtools.build.jkrunchy.JKrunchyMain')");

useConfiguration("--proguard_top=//java/com/google/devtools/build/jkrunchy:jkrunchy");
Expand Down Expand Up @@ -1903,7 +1903,7 @@ public void omitResourcesInfoProviderFromAndroidBinary_enabled() throws Exceptio
"android_binary(",
" name = 'myapp',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res/**/*']),",
" resource_files = glob(['res/**/*'], allow_empty = True),",
")");

assertThat(binary.get(AndroidResourcesInfo.PROVIDER)).isNull();
Expand All @@ -1919,7 +1919,7 @@ public void omitResourcesInfoProviderFromAndroidBinary_disabled() throws Excepti
"android_binary(",
" name = 'myapp',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res/**/*']),",
" resource_files = glob(['res/**/*'], allow_empty = True),",
")");

assertThat(binary.get(AndroidResourcesInfo.PROVIDER)).isNotNull();
Expand Down Expand Up @@ -1979,7 +1979,7 @@ public void testFilterResourcesPseudolocalesPropagated() throws Exception {
dir,
"bin",
"android_binary(name = 'bin',",
" resource_files = glob(['res/**']),",
" resource_files = glob(['res/**'], allow_empty = True),",
" resource_configuration_filters = ['en', 'en-rXA', 'ar-rXB'],",
" manifest = 'AndroidManifest.xml')");

Expand Down Expand Up @@ -2045,18 +2045,18 @@ public void testInheritedRNotInRuntimeJars() throws Exception {
dir + "BUILD",
"android_library(name = 'sublib',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res3/**']),",
" resource_files = glob(['res3/**'], allow_empty = True),",
" srcs =['sublib.java'],",
" )",
"android_library(name = 'lib',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res2/**']),",
" resource_files = glob(['res2/**'], allow_empty = True),",
" deps = [':sublib'],",
" srcs =['lib.java'],",
" )",
"android_binary(name = 'bin',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res/**']),",
" resource_files = glob(['res/**'], allow_empty = True),",
" deps = [':lib'],",
" srcs =['bin.java'],",
" )");
Expand Down Expand Up @@ -2160,15 +2160,15 @@ public void testUseRClassGeneratorMultipleDeps() throws Exception {
"java/r/android/BUILD",
"android_library(name = 'lib1',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res1/**']),",
" resource_files = glob(['res1/**'], allow_empty = True),",
" )",
"android_library(name = 'lib2',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res2/**']),",
" resource_files = glob(['res2/**'], allow_empty = True),",
" )",
"android_binary(name = 'r',",
" manifest = 'AndroidManifest.xml',",
" resource_files = glob(['res/**']),",
" resource_files = glob(['res/**'], allow_empty = True),",
" deps = [':lib1', ':lib2'],",
" )");
ConfiguredTargetAndData binary = getConfiguredTargetAndData("//java/r/android:r");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void javaHomeGenerated() throws Exception {
")",
"java_runtime(",
" name = 'jvm', ",
" srcs = glob(['generated_java_home/**']), ",
" srcs = glob(['generated_java_home/**'], allow_empty = True), ",
" java = 'generated_java_home/bin/java', ",
" java_home = 'generated_java_home',",
")");
Expand Down
5 changes: 4 additions & 1 deletion tools/build_defs/pkg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ py_library(

filegroup(
name = "archive_testdata",
srcs = glob(["testdata/**"]),
srcs = glob(
["testdata/**"],
allow_empty = True,
),
)

py_test(
Expand Down

0 comments on commit 4e4231b

Please sign in to comment.