rules.bzl 1005 B

1234567891011121314151617181920212223242526272829303132333435
  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. tags = ["manual"],
  12. args = args,
  13. **kwargs
  14. )
  15. def glob_sh_run(file_exts, args, data, run_ext = "run", **kwargs):
  16. """Produces a per-file sh_run."""
  17. files = native.glob(
  18. ["**"],
  19. exclude_directories = 1,
  20. )
  21. for f in files:
  22. if f.split(".")[-1] not in file_exts:
  23. continue
  24. sh_run(
  25. name = "%s.%s" % (f, run_ext),
  26. args = args + ["$(location %s)" % f],
  27. data = data + [f],
  28. env = cc_env(),
  29. **kwargs
  30. )