|
9 | 9 | #include <curl/curl.h>
|
10 | 10 | #undef fopen
|
11 | 11 | #include <boost/url.hpp>
|
| 12 | +#include <boost/algorithm/string/case_conv.hpp> |
12 | 13 | #include "magic_enum.hpp"
|
13 | 14 | #include "ecsact/cli/detail/proc_exec.hh"
|
14 | 15 | #include "ecsact/cli/commands/build/cc_compiler_config.hh"
|
@@ -241,17 +242,41 @@ static auto handle_source( //
|
241 | 242 | return 0;
|
242 | 243 | }
|
243 | 244 |
|
| 245 | +constexpr auto GENERATED_DYLIB_DISCLAIMER = R"( |
| 246 | +//////////////////////////////////////////////////////////////////////////////// |
| 247 | +// THIS FILE IS GENERATED - DO NOT EDIT // |
| 248 | +//////////////////////////////////////////////////////////////////////////////// |
| 249 | +)"; |
| 250 | + |
| 251 | +constexpr auto LOAD_AT_RUNTIME_GUARD = R"( |
| 252 | +#ifndef ECSACT_{0}_API_LOAD_AT_RUNTIME |
| 253 | +# error "Expected ECSACT_{0}_API_LOAD_AT_RUNTIME to be set" |
| 254 | +#endif // ECSACT_{0}_API_LOAD_AT_RUNTIME |
| 255 | +
|
| 256 | +#ifdef ECSACT_{0}_API |
| 257 | +# error "ECSACT_{0}_API may not be set while using generated dylib source" |
| 258 | +#endif // ECSACT_{0}_API |
| 259 | +)"; |
| 260 | + |
244 | 261 | static auto generate_dylib_imports( //
|
245 | 262 | auto&& imports,
|
246 | 263 | std::ostream& output
|
247 | 264 | ) -> void {
|
248 | 265 | auto mods = ecsact::cli::detail::get_ecsact_modules(as_vec(imports));
|
| 266 | + output << GENERATED_DYLIB_DISCLAIMER; |
249 | 267 | output << "#include <string>\n";
|
250 | 268 | output << "#include \"ecsact/runtime/common.h\"\n";
|
251 | 269 | for(auto&& [module_name, _] : mods.module_methods) {
|
252 | 270 | output << std::format("#include \"ecsact/runtime/{}.h\"\n", module_name);
|
253 | 271 | }
|
254 | 272 |
|
| 273 | + for(auto&& [module_name, _] : mods.module_methods) { |
| 274 | + output << std::format( // |
| 275 | + LOAD_AT_RUNTIME_GUARD, |
| 276 | + boost::to_upper_copy(module_name) |
| 277 | + ); |
| 278 | + } |
| 279 | + |
255 | 280 | output << "\n";
|
256 | 281 |
|
257 | 282 | for(std::string_view imp : imports) {
|
@@ -470,6 +495,8 @@ auto cl_compile(compile_options options) -> int {
|
470 | 495 | // compile_proc_args.push_back("/bigobj");
|
471 | 496 | // }
|
472 | 497 |
|
| 498 | + // cl_args.push_back("/we4530"); // treat exceptions as errors |
| 499 | + cl_args.push_back("/wd4530"); // ignore use of exceptions warning |
473 | 500 | cl_args.push_back("/MD");
|
474 | 501 | cl_args.push_back("/DNDEBUG");
|
475 | 502 | cl_args.push_back("/O2");
|
@@ -620,6 +647,14 @@ auto ecsact::cli::cook_recipe( //
|
620 | 647 |
|
621 | 648 | auto source_files = std::vector<fs::path>{};
|
622 | 649 |
|
| 650 | + { |
| 651 | + // No need to add to source_files since it will be grabbed in the directory |
| 652 | + // iterator |
| 653 | + auto dylib_src = src_dir / "ecsact-generated-dylib.cc"; |
| 654 | + auto dylib_src_stream = std::ofstream{dylib_src}; |
| 655 | + generate_dylib_imports(recipe.imports(), dylib_src_stream); |
| 656 | + } |
| 657 | + |
623 | 658 | for(auto entry : fs::recursive_directory_iterator(src_dir)) {
|
624 | 659 | if(!entry.is_regular_file()) {
|
625 | 660 | continue;
|
@@ -698,15 +733,6 @@ auto ecsact::cli::cook_recipe( //
|
698 | 733 | inc_dirs.push_back(install_prefix / "include");
|
699 | 734 | #endif
|
700 | 735 |
|
701 |
| - auto dylib_src = src_dir / "ecsact-generated-dylib.cc"; |
702 |
| - |
703 |
| - { |
704 |
| - auto dylib_src_stream = std::ofstream{dylib_src}; |
705 |
| - generate_dylib_imports(recipe.imports(), dylib_src_stream); |
706 |
| - } |
707 |
| - |
708 |
| - source_files.push_back(dylib_src); |
709 |
| - |
710 | 736 | if(is_cl_like(compiler.compiler_type)) {
|
711 | 737 | exit_code = cl_compile({
|
712 | 738 | .work_dir = recipe_options.work_dir,
|
|
0 commit comments