Skip to content

Commit be9d32a

Browse files
committed
Bazel/CMake: make include not use cmake include
...but rather just pass along targets. This is required to fix CMake generation in the internal repository.
1 parent 400176f commit be9d32a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

misc/bazel/cmake/cmake.bzl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def _map_cmake_info(info, is_windows):
212212

213213
GeneratedCmakeFiles = provider(
214214
fields = {
215-
"files": "",
215+
"targets": "",
216216
},
217217
)
218218

@@ -221,7 +221,11 @@ def _generate_cmake_impl(ctx):
221221
inputs = []
222222

223223
infos = {}
224-
for dep in ctx.attr.targets:
224+
targets = list(ctx.attr.targets)
225+
for include in ctx.attr.includes:
226+
targets += include[GeneratedCmakeFiles].targets.to_list()
227+
228+
for dep in targets:
225229
for info in [dep[CmakeInfo]] + dep[CmakeInfo].transitive_deps.to_list():
226230
if info.name != None:
227231
inputs += info.inputs
@@ -233,11 +237,6 @@ def _generate_cmake_impl(ctx):
233237
commands += _map_cmake_info(info, is_windows)
234238
commands.append("")
235239

236-
for include in ctx.attr.includes:
237-
for file in include[GeneratedCmakeFiles].files.to_list():
238-
inputs.append(file)
239-
commands.append("include(${BAZEL_EXEC_ROOT}/%s)" % file.path)
240-
241240
# we want to use a run or run_shell action to register a bunch of files like inputs, but we cannot write all
242241
# in a shell command as we would hit the command size limit. So we first write the file and then copy it with
243242
# the dummy inputs
@@ -248,7 +247,7 @@ def _generate_cmake_impl(ctx):
248247

249248
return [
250249
DefaultInfo(files = depset([output])),
251-
GeneratedCmakeFiles(files = depset([output])),
250+
GeneratedCmakeFiles(targets = depset(ctx.attr.targets)),
252251
]
253252

254253
generate_cmake = rule(

0 commit comments

Comments
 (0)