Skip to content

Commit

Permalink
feat: add rules for recipe bundles (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelwan authored Jul 2, 2024
1 parent 0663960 commit 6afde02
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module(
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "ecsact_cli", version = "0.3.4")
bazel_dep(name = "ecsact_cli", version = "0.3.12")

bazel_dep(name = "aspect_bazel_lib", version = "1.32.1", dev_dependency = True)
5 changes: 3 additions & 2 deletions ecsact/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""
"""

load("//ecsact/private:ecsact_binary.bzl", _ecsact_binary = "ecsact_binary")
load("//ecsact/private:ecsact_build_recipe.bzl", _ecsact_build_recipe = "ecsact_build_recipe", _ecsact_build_recipe_bundle = "ecsact_build_recipe_bundle")
load("//ecsact/private:ecsact_codegen.bzl", _ecsact_codegen = "ecsact_codegen")
load("//ecsact/private:ecsact_codegen_plugin.bzl", _ecsact_codegen_plugin = "ecsact_codegen_plugin")
load("//ecsact/private:ecsact_binary.bzl", _ecsact_binary = "ecsact_binary")
load("//ecsact/private:ecsact_build_recipe.bzl", _ecsact_build_recipe = "ecsact_build_recipe")
load("//ecsact/private:ecsact_library.bzl", _ecsact_library = "ecsact_library")

ecsact_codegen = _ecsact_codegen
ecsact_codegen_plugin = _ecsact_codegen_plugin
ecsact_binary = _ecsact_binary
ecsact_build_recipe = _ecsact_build_recipe
ecsact_build_recipe_bundle = _ecsact_build_recipe_bundle
ecsact_library = _ecsact_library
42 changes: 42 additions & 0 deletions ecsact/private/ecsact_build_recipe.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_cc//cc:find_cc_toolchain.bzl", "use_cc_toolchain")
load("//ecsact/private:ecsact_codegen_plugin.bzl", "EcsactCodegenPluginInfo")

EcsactBuildRecipeInfo = provider(
Expand Down Expand Up @@ -101,3 +102,44 @@ ecsact_build_recipe = rule(
),
},
)

def _ecsact_build_recipe_bundle(ctx):
# type: (ctx) -> None

ecsact_toolchain = ctx.toolchains["//ecsact:toolchain_type"].ecsact_info
bundle_output_file = ctx.actions.declare_file("{}.ecsact-recipe-bundle".format(ctx.attr.name))

args = ctx.actions.args()
args.add("recipe-bundle")
args.add_all(ctx.files.recipes)
args.add("-o", bundle_output_file)

report_filter = ctx.var.get("ECSACT_CLI_REPORT_FILTER", "errors_and_warnings")
args.add("--report_filter", report_filter)

print("ARGS: ", args)

executable = ecsact_toolchain.target_tool if ecsact_toolchain.target_tool != None else ecsact_toolchain.target_tool_path

ctx.actions.run(
mnemonic = "EcsactRecipeBundle",
progress_message = "Bundling Ecsact Build Recipe %{output}",
outputs = [bundle_output_file],
inputs = ctx.files.recipes,
executable = executable,
arguments = [args],
toolchain = Label("//ecsact:toolchain_type"),
)
return DefaultInfo(
files = depset([bundle_output_file]),
)

ecsact_build_recipe_bundle = rule(
implementation = _ecsact_build_recipe_bundle,
attrs = {
"recipes": attr.label_list(
providers = [EcsactBuildRecipeInfo],
),
},
toolchains = ["//ecsact:toolchain_type"] + use_cc_toolchain(),
)

0 comments on commit 6afde02

Please # to comment.