blob: 082b3f13821c5835981ba81ee70354de7e3de741 [file] [log] [blame]
This defines a macro to cut down on boiler plate for generating sksl test resources.
load("//bazel:macros.bzl", "py_binary")
def compile_sksl(name, lang, inputs, settings = "settings"):
"""Creates a rule to compile the given sksl inputs
This macro creates a py_binary rule to invoke the // script and a
helper genrule which creates the list of all file names that should be processed by that
python script.
The generated py_binary rule is called compute_${name} and can be run via `bazel run`.
name: A string used to uniquely identify the generated compile and list rule.
lang: A string passed into the script.
inputs: A filegroup label containing all the input files to be processed.
settings: A string passed into the script.
name = "compile_" + name,
main = "",
srcs = [""],
args = [
# comments are the variable names in
"--" + lang, # lang
"--" + settings, # settings
"resources", # input_root_dir
"tests", # output_root_dir
"bazel-bin/tools/skslc/%s.txt" % name, # input_file
data = [
":%s.txt" % name,
tags = ["no-remote"],
name = "enumerate_%s_list" % name, # This name does not really matter.
srcs = [inputs],
outs = [name + ".txt"],
# Put a space seperated list of file names into the one output
# This is done because the list could be quite long and overflow
# the command line length
cmd = "echo $(SRCS) > $@",