diff --git a/MODULE.bazel b/MODULE.bazel index 427b68e..1d0055a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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) diff --git a/ecsact/defs.bzl b/ecsact/defs.bzl index 4f5b859..88143e5 100644 --- a/ecsact/defs.bzl +++ b/ecsact/defs.bzl @@ -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 diff --git a/ecsact/private/ecsact_build_recipe.bzl b/ecsact/private/ecsact_build_recipe.bzl index bbf54b9..2386277 100644 --- a/ecsact/private/ecsact_build_recipe.bzl +++ b/ecsact/private/ecsact_build_recipe.bzl @@ -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( @@ -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(), +)