|
21 | 21 |
|
22 | 22 | #include "ecsact/cli/report.hh" |
23 | 23 | #include "ecsact/cli/detail/download.hh" |
| 24 | +#include "ecsact/cli/commands/codegen/codegen_util.hh" |
24 | 25 |
|
25 | 26 | using namespace std::string_literals; |
26 | 27 | using namespace std::string_view_literals; |
@@ -191,6 +192,48 @@ auto ecsact::build_recipe_bundle::create( // |
191 | 192 | }; |
192 | 193 | }, |
193 | 194 | [&](build_recipe::source_codegen src) -> source_visitor_result_t { |
| 195 | + auto new_archive_rel_plugin_paths = std::vector<std::string>{}; |
| 196 | + new_archive_rel_plugin_paths.reserve(src.plugins.size()); |
| 197 | + for(auto plugin : src.plugins) { |
| 198 | + if(cli::is_default_plugin(plugin)) { |
| 199 | + new_archive_rel_plugin_paths.emplace_back(plugin); |
| 200 | + continue; |
| 201 | + } |
| 202 | + |
| 203 | + auto plugin_file_path = |
| 204 | + cli::resolve_plugin_path(cli::resolve_plugin_path_options{ |
| 205 | + .plugin_arg = plugin, |
| 206 | + .default_plugins_dir = recipe.base_directory(), |
| 207 | + .additional_plugin_dirs = {recipe.base_directory()}, |
| 208 | + }); |
| 209 | + |
| 210 | + if(!plugin_file_path) { |
| 211 | + return std::logic_error{ |
| 212 | + std::format("Unable to resolve codegen plugin: {}", plugin) |
| 213 | + }; |
| 214 | + } |
| 215 | + |
| 216 | + if(plugin_file_path->extension() != ".wasm") { |
| 217 | + ecsact::cli::report_warning( |
| 218 | + "Bundled codegen plugin {} is platform specific. Bundle will only " |
| 219 | + "work on current platform.", |
| 220 | + plugin_file_path->filename().string() |
| 221 | + ); |
| 222 | + } |
| 223 | + |
| 224 | + auto plugin_file_data = read_file(*plugin_file_path); |
| 225 | + auto archive_rel_path = |
| 226 | + (fs::path{"codegen"} / plugin_file_path->filename()) |
| 227 | + .lexically_normal(); |
| 228 | + |
| 229 | + auto& p = new_archive_rel_plugin_paths.emplace_back( |
| 230 | + archive_rel_path.generic_string() |
| 231 | + ); |
| 232 | + add_simple_buffer(p, plugin_file_data); |
| 233 | + } |
| 234 | + |
| 235 | + src.plugins = new_archive_rel_plugin_paths; |
| 236 | + |
194 | 237 | return src; |
195 | 238 | }, |
196 | 239 | [&](build_recipe::source_path src) -> source_visitor_result_t { |
|
0 commit comments