Skip to content

Commit

Permalink
maprule: add implementation and tests
Browse files Browse the repository at this point in the history
maprule() is an improved version of
native.genrule(), with the following advantages:

- Maprule can process source files in parallel,
  creating separate actions for each of them.

- Maprule does not require declaring all output
  files. Instead you declare templates for the
  output files produces for each source. Therefore
  N source files and M templates produce N*M
  outputs.

- Maprule supports both Bash or cmd.exe syntax for
  its commands via the specialized rules
  bash_maprule and cmd_maprule.

- Maprule's cmd attribute does deliberately not
  support $(location) expression nor Make
  Variables, in order to avoid issues and
  challenges with quoting. (Particluarly in case
  of cmd.exe passing empty arguments is
  impossible). These paths can be passed as
  envvars instead.

- Maprule's add_env attribute does support
  $(location) expressions (and some extra
  placeholders) and is the idiomatic way to pass
  execpaths of labels in "tools" or "srcs" (the
  shared sources available for all actions) to the
  command.

See bazelbuild/bazel#4319
  • Loading branch information
laszlocsomor committed Dec 5, 2018
1 parent daf5137 commit 979a9f6
Show file tree
Hide file tree
Showing 4 changed files with 929 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rules/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
licenses(["notice"])

exports_files(["maprule.bzl"])
Loading

0 comments on commit 979a9f6

Please sign in to comment.