我试图使用Bazel进行以下设置。通过调用“ bazel build”,Python脚本应该生成未知数量的带有随机名称的* .cc文件,然后将这些文件编译到单个静态库(.a文件)中,所有这些都在一个Bazel调用中完成。我尝试了以下操作:一个生成的文件具有固定名称,该文件在genrule()和cc_library规则的srcs中引用。问题是我需要将所有生成的文件构建为库,而不仅仅是具有固定名称的文件。任何想法如何做到这一点?我的BUILD文件:
py_binary(
name = "sample_script",
srcs = ["sample_script.py"],
)
genrule(
name = "sample_genrule",
tools = [":sample_script"],
cmd = "$(location :sample_script)",
outs = ["cpp_output_fixed.cc"], #or shall also the files with random names be defined here?
)
cc_library(
name = "autolib",
srcs = ["cpp_output_fixed.cc"],
#srcs = glob([ #here should all generated .cc files be named
# "./*.cc",
# "./**/*.cc",
# ])+["cpp_output_fixed.cc"],
)
Run Code Online (Sandbox Code Playgroud)
Python文件sample_script.py:
#!/usr/bin/env python
import hashlib
import time
time_stamp = time.time()
time_1 = str(time_stamp)
time_2 = str(time_stamp + …
Run Code Online (Sandbox Code Playgroud)