From 4e4231b44b1567a059095b0674eedd6e3b104017 Mon Sep 17 00:00:00 2001 From: Xavier Bonaventura Date: Wed, 28 Sep 2022 15:40:42 +0200 Subject: [PATCH] Be explicit about alowing empty globs (third part) 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. --- .../lib/rules/android/AndroidBinaryTest.java | 24 +++++++++---------- .../build/lib/rules/java/JavaRuntimeTest.java | 2 +- tools/build_defs/pkg/BUILD | 5 +++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java index c7490df814d78b..48e4268c659ce7 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java @@ -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"); @@ -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(", @@ -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"); @@ -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(); @@ -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(); @@ -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')"); @@ -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'],", " )"); @@ -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"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaRuntimeTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaRuntimeTest.java index d1ea4c366a1aed..b81579e617dc77 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaRuntimeTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaRuntimeTest.java @@ -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',", ")"); diff --git a/tools/build_defs/pkg/BUILD b/tools/build_defs/pkg/BUILD index e34cf65452160b..e0da8b8d0289da 100644 --- a/tools/build_defs/pkg/BUILD +++ b/tools/build_defs/pkg/BUILD @@ -30,7 +30,10 @@ py_library( filegroup( name = "archive_testdata", - srcs = glob(["testdata/**"]), + srcs = glob( + ["testdata/**"], + allow_empty = True, + ), ) py_test(