Search code examples
bazel

What bazel build command can be used for genrule with loop?


What build command I can use for below genrule?

This genrule might be evaluated multiply and each genrule have a unique name so that I'm wondering what I configured target name for bazel build.

I hope the genrule is built multiply by a single build command.

[genrule(
  name = "gen_txt_" + fin,
  srcs = [":sources"],
  outs = [fin + ".cp"],
  cmd = """
  cp $@ [email protected]
  """,
) for fin in glob(["*.in"])]

Solution

  • I found the answer from the Bazel User's guide.