rules.bzl 978 B

12345678910111213141516171819202122232425262728293031323334
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. """Rules for building fuzz tests."""
  5. load("//bazel/cc_toolchains:defs.bzl", "cc_env")
  6. def sh_run(name, args, **kwargs):
  7. """Produces a target which can run with the given args."""
  8. native.sh_binary(
  9. name = name,
  10. srcs = ["//bazel/sh_run:exec.sh"],
  11. args = args,
  12. **kwargs
  13. )
  14. def glob_sh_run(file_exts, args, data, run_ext = "run", **kwargs):
  15. """Produces a per-file sh_run."""
  16. files = native.glob(
  17. ["**"],
  18. exclude_directories = 1,
  19. )
  20. for f in files:
  21. if f.split(".")[-1] not in file_exts:
  22. continue
  23. sh_run(
  24. name = "%s.%s" % (f, run_ext),
  25. args = args + ["$(location %s)" % f],
  26. data = data + [f],
  27. env = cc_env(),
  28. **kwargs
  29. )