Skip to content

feat: add rules for recipe bundles #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
)