|
| 1 | +load("@rules_cc//cc:find_cc_toolchain.bzl", "use_cc_toolchain") |
1 | 2 | load("//ecsact/private:ecsact_codegen_plugin.bzl", "EcsactCodegenPluginInfo")
|
2 | 3 |
|
3 | 4 | EcsactBuildRecipeInfo = provider(
|
@@ -101,3 +102,44 @@ ecsact_build_recipe = rule(
|
101 | 102 | ),
|
102 | 103 | },
|
103 | 104 | )
|
| 105 | + |
| 106 | +def _ecsact_build_recipe_bundle(ctx): |
| 107 | + # type: (ctx) -> None |
| 108 | + |
| 109 | + ecsact_toolchain = ctx.toolchains["//ecsact:toolchain_type"].ecsact_info |
| 110 | + bundle_output_file = ctx.actions.declare_file("{}.ecsact-recipe-bundle".format(ctx.attr.name)) |
| 111 | + |
| 112 | + args = ctx.actions.args() |
| 113 | + args.add("recipe-bundle") |
| 114 | + args.add_all(ctx.files.recipes) |
| 115 | + args.add("-o", bundle_output_file) |
| 116 | + |
| 117 | + report_filter = ctx.var.get("ECSACT_CLI_REPORT_FILTER", "errors_and_warnings") |
| 118 | + args.add("--report_filter", report_filter) |
| 119 | + |
| 120 | + print("ARGS: ", args) |
| 121 | + |
| 122 | + executable = ecsact_toolchain.target_tool if ecsact_toolchain.target_tool != None else ecsact_toolchain.target_tool_path |
| 123 | + |
| 124 | + ctx.actions.run( |
| 125 | + mnemonic = "EcsactRecipeBundle", |
| 126 | + progress_message = "Bundling Ecsact Build Recipe %{output}", |
| 127 | + outputs = [bundle_output_file], |
| 128 | + inputs = ctx.files.recipes, |
| 129 | + executable = executable, |
| 130 | + arguments = [args], |
| 131 | + toolchain = Label("//ecsact:toolchain_type"), |
| 132 | + ) |
| 133 | + return DefaultInfo( |
| 134 | + files = depset([bundle_output_file]), |
| 135 | + ) |
| 136 | + |
| 137 | +ecsact_build_recipe_bundle = rule( |
| 138 | + implementation = _ecsact_build_recipe_bundle, |
| 139 | + attrs = { |
| 140 | + "recipes": attr.label_list( |
| 141 | + providers = [EcsactBuildRecipeInfo], |
| 142 | + ), |
| 143 | + }, |
| 144 | + toolchains = ["//ecsact:toolchain_type"] + use_cc_toolchain(), |
| 145 | +) |
0 commit comments