Skip to content

Commit 4904acb

Browse files
authored
fix empty glob() error (#98)
tl;dr : the issue description and repro: https://github.com/gdevillele/debug_bazel I am trying to build native C libs for Android using Bazel and `rules_android_ndk`, and am getting the following error: ``` glob pattern 'lib64/**/*' didn't match anything, but allow_empty is set to False ``` This is due to a breaking change introduced in Bazel 8.0. (bazelbuild/bazel#8195) Note: I am still a beginner with Bazel, so let me know if this is not the correct way of fixing this. Thank you 🙂
1 parent 66e0427 commit 4904acb

1 file changed

Lines changed: 29 additions & 21 deletions

File tree

BUILD.ndk_clang.tpl

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,23 @@ cc_toolchain_suite(
3838
name = "toolchain_config_%s" % target_system_name,
3939
api_level = {api_level},
4040
clang_resource_directory = "{clang_resource_directory}",
41+
executable_extension = "{executable_extension}",
4142
target_system_name = target_system_name,
4243
toolchain_identifier = "toolchain_identifier_%s" % target_system_name,
43-
executable_extension = "{executable_extension}",
4444
) for target_system_name in TARGET_SYSTEM_NAMES]
4545

4646
filegroup(
4747
name = "all_binaries",
48-
srcs = glob([
49-
"bin/*",
50-
"lib64/**/*",
51-
"lib/**/*",
52-
]),
48+
srcs = glob(
49+
[
50+
"bin/*",
51+
"lib64/**/*",
52+
"lib/**/*",
53+
],
54+
# Need to allow_empty here because previous NDK versions had
55+
# "lib" & "lib64" directories but recent ones only have "lib".
56+
allow_empty = True,
57+
),
5358
)
5459

5560
filegroup(
@@ -69,7 +74,6 @@ filegroup(
6974
output_licenses = ["unencumbered"],
7075
)
7176

72-
7377
[filegroup(
7478
name = "compiler_files_%s" % target_system_name,
7579
srcs = [
@@ -78,24 +82,25 @@ filegroup(
7882
":as_files",
7983
":objcopy_files",
8084
"//{sysroot_directory}:sysroot_includes",
81-
] + glob([
82-
"prebuilt_include/**",
83-
"include/**",
84-
"lib/gcc/%s/**" % target_system_name,
85-
"lib64/**/*",
86-
"lib/**/*",
87-
], allow_empty = True),
85+
] + glob(
86+
[
87+
"prebuilt_include/**",
88+
"include/**",
89+
"lib/gcc/%s/**" % target_system_name,
90+
"lib64/**/*",
91+
"lib/**/*",
92+
],
93+
allow_empty = True,
94+
),
8895
output_licenses = ["unencumbered"],
8996
) for target_system_name in TARGET_SYSTEM_NAMES]
9097

91-
9298
filegroup(
9399
name = "coverage_files",
94100
srcs = [":all_binaries"],
95101
output_licenses = ["unencumbered"],
96102
)
97103

98-
99104
filegroup(
100105
name = "dwp_files",
101106
srcs = [":all_binaries"],
@@ -117,11 +122,14 @@ filegroup(
117122
srcs = [
118123
":all_binaries",
119124
":static_runtime_lib_%s" % target_system_name,
120-
] + glob([
121-
"lib/gcc/%s/**" % target_system_name,
122-
"lib64/**",
123-
"lib/**",
124-
], allow_empty = True),
125+
] + glob(
126+
[
127+
"lib/gcc/%s/**" % target_system_name,
128+
"lib64/**",
129+
"lib/**",
130+
],
131+
allow_empty = True,
132+
),
125133
) for target_system_name in TARGET_SYSTEM_NAMES]
126134

127135
filegroup(

0 commit comments

Comments
 (0)