Skip to content

Commit dd68309

Browse files
authored
feat: support new ecsact si modules (#140)
1 parent 1e0317f commit dd68309

File tree

9 files changed

+78
-10
lines changed

9 files changed

+78
-10
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.4.1
1+
7.5.0

MODULE.bazel

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ bazel_dep(name = "nlohmann_json", version = "3.11.3")
99
bazel_dep(name = "platforms", version = "0.0.10")
1010
bazel_dep(name = "rules_pkg", version = "0.10.1")
1111
bazel_dep(name = "bazel_skylib", version = "1.6.1")
12-
bazel_dep(name = "ecsact_runtime", version = "0.7.1", max_compatibility_level = 8)
13-
bazel_dep(name = "ecsact_interpret", version = "0.6.6")
14-
bazel_dep(name = "ecsact_codegen", version = "0.4.3")
12+
bazel_dep(name = "ecsact_runtime", version = "0.8.2")
13+
single_version_override(
14+
module_name = "ecsact_runtime",
15+
version = "0.8.2",
16+
)
17+
18+
bazel_dep(name = "ecsact_interpret", version = "0.6.7")
19+
bazel_dep(name = "ecsact_codegen", version = "0.4.4")
1520
bazel_dep(name = "boost.dll", version = "1.83.0.bzl.2")
1621
bazel_dep(name = "magic_enum", version = "0.9.3")
1722
bazel_dep(name = "curl", version = "8.7.1.bcr.1")

ecsact/cli/commands/build/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ cc_library(
1010
copts = copts,
1111
deps = [
1212
"//ecsact/cli:report",
13-
"//ecsact/cli/commands/codegen:codegen_util",
1413
"//ecsact/cli/commands/build:get_modules",
14+
"//ecsact/cli/commands/codegen:codegen_util",
1515
"@yaml-cpp",
1616
],
1717
)
@@ -75,5 +75,6 @@ cc_library(
7575
"@ecsact_runtime//:dynamic",
7676
"@ecsact_runtime//:meta",
7777
"@ecsact_runtime//:serialize",
78+
"@ecsact_runtime//:si_wasm",
7879
],
7980
)

ecsact/cli/commands/build/get_modules.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "ecsact/runtime/dynamic.h"
66
#include "ecsact/runtime/meta.h"
77
#include "ecsact/runtime/serialize.h"
8+
#include "ecsact/si/wasm.h"
89

910
auto ecsact::cli::detail::get_ecsact_modules( //
1011
std::vector<std::string> methods
@@ -24,6 +25,7 @@ auto ecsact::cli::detail::get_ecsact_modules( //
2425
FOR_EACH_ECSACT_DYNAMIC_API_FN(CHECK_MODULE, "dynamic");
2526
FOR_EACH_ECSACT_META_API_FN(CHECK_MODULE, "meta");
2627
FOR_EACH_ECSACT_SERIALIZE_API_FN(CHECK_MODULE, "serialize");
28+
FOR_EACH_ECSACT_SI_WASM_API_FN(CHECK_MODULE, "si_wasm");
2729

2830
result.unknown_module_methods.emplace_back(method);
2931
}

ecsact/cli/commands/build/recipe/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ cc_library(
9595
"@ecsact_runtime//:ecsact/runtime/serialize.h",
9696
"@ecsact_runtime//:ecsact/runtime/serialize.hh",
9797
"@ecsact_runtime//:ecsact/runtime/static.h",
98+
"@ecsact_runtime//:ecsact/si/wasm.h",
99+
"@ecsact_runtime//:ecsact/si/wasm.hh",
98100
],
99101
}),
100102
)

ecsact/cli/commands/build/recipe/cook.cc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,24 @@ static auto write_file(fs::path path, std::span<std::byte> data) -> void {
120120
file.write(reinterpret_cast<const char*>(data.data()), data.size());
121121
}
122122

123+
static auto find_wasmer_dir() -> std::optional<fs::path> {
124+
auto wasmer_dir_env = std::getenv("WASMER_DIR");
125+
if(wasmer_dir_env) {
126+
if(fs::exists(wasmer_dir_env)) {
127+
return wasmer_dir_env;
128+
} else {
129+
report_warning(
130+
"WASMER_DIR is set, but could not be found: {}",
131+
wasmer_dir_env
132+
);
133+
}
134+
} else {
135+
report_warning("WASMER_DIR environment variable is unset");
136+
}
137+
138+
return std::nullopt;
139+
}
140+
123141
static auto handle_source( //
124142
fs::path base_directory,
125143
ecsact::build_recipe::source_fetch src,
@@ -722,6 +740,18 @@ auto cl_compile(compile_options options) -> int {
722740
return params_file_path;
723741
};
724742

743+
const bool wants_wasmer = std::ranges::find(options.system_libs, "wasmer"s) !=
744+
options.system_libs.end();
745+
const auto wasmer_dir = wants_wasmer ? find_wasmer_dir() : std::nullopt;
746+
747+
if(wants_wasmer && !wasmer_dir) {
748+
report_error(
749+
"Recipe wants 'wasmer' system lib, but wasmer directory could not be "
750+
"found"
751+
);
752+
return 1;
753+
}
754+
725755
cl_args.push_back("/nologo");
726756
cl_args.push_back("/D_WIN32_WINNT=0x0A00");
727757
cl_args.push_back("/diagnostics:column");
@@ -768,6 +798,10 @@ auto cl_compile(compile_options options) -> int {
768798
cl_args.push_back(std::format("/I{}", inc_dir.string()));
769799
}
770800

801+
if(wants_wasmer && wasmer_dir) {
802+
cl_args.push_back(std::format("/I{}", (*wasmer_dir / "include").string()));
803+
}
804+
771805
if(options.tracy_dir) {
772806
cl_args.push_back(std::format("/I{}", options.tracy_dir->string()));
773807
}
@@ -868,6 +902,10 @@ auto cl_compile(compile_options options) -> int {
868902
cl_args.push_back("@" + obj_params_file.string());
869903
cl_args.push_back("@" + main_params_file.string());
870904

905+
if(wants_wasmer && wasmer_dir) {
906+
cl_args.push_back((*wasmer_dir / "lib" / "wasmer.lib").string());
907+
}
908+
871909
if(options.tracy_dir) {
872910
auto tracy_lib =
873911
fs::path{options.output_path.parent_path() / "profiler.lib"};
@@ -881,6 +919,19 @@ auto cl_compile(compile_options options) -> int {
881919
cl_args.push_back("/DLL");
882920

883921
for(auto sys_lib : options.system_libs) {
922+
if(sys_lib == "wasmer" && wasmer_dir) {
923+
// Wasmer has some special treatment
924+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "ws2_32"));
925+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "Advapi32"));
926+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "Userenv"));
927+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "Bcrypt"));
928+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "ntdll"));
929+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "Shell32"));
930+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "Ole32"));
931+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "OleAut32"));
932+
cl_args.push_back(std::format("/DEFAULTLIB:{}", "RuntimeObject"));
933+
continue;
934+
}
884935
cl_args.push_back(std::format("/DEFAULTLIB:{}", sys_lib));
885936
}
886937

ecsact/cli/commands/build/recipe/cook_runfiles.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ auto ecsact::cli::cook::load_runfiles(
4646
"ecsact_runtime/ecsact/runtime/serialize.h",
4747
"ecsact_runtime/ecsact/runtime/serialize.hh",
4848
"ecsact_runtime/ecsact/runtime/static.h",
49+
"ecsact_runtime/ecsact/si/wasm.h",
50+
"ecsact_runtime/ecsact/si/wasm.hh",
4951
};
5052

5153
for(auto hdr : ecsact_runtime_headers_from_runfiles) {

test/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.5.0

test/MODULE.bazel

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
bazel_dep(name = "rules_cc", version = "0.0.9")
2-
bazel_dep(name = "rules_ecsact", version = "0.5.0")
3-
bazel_dep(name = "ecsact_codegen", version = "0.4.1")
1+
bazel_dep(name = "rules_cc", version = "0.0.17")
2+
bazel_dep(name = "rules_ecsact", version = "0.5.10")
3+
bazel_dep(name = "ecsact_codegen", version = "0.4.4")
44
bazel_dep(name = "boost.dll", version = "1.83.0.bzl.2")
55
bazel_dep(name = "boost.process", version = "1.83.0.bzl.2")
66
bazel_dep(name = "boost.regex", version = "1.83.0.bcr.1")
7-
bazel_dep(name = "ecsact_runtime", version = "0.7.0")
7+
bazel_dep(name = "ecsact_runtime", version = "0.8.2")
8+
single_version_override(
9+
module_name = "ecsact_runtime",
10+
version = "0.8.2",
11+
)
12+
813
bazel_dep(name = "docopt.cpp", version = "0.6.2")
914

1015
bazel_dep(name = "toolchains_llvm", version = "1.0.0", dev_dependency = True)
1116
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
1217

1318
bazel_dep(name = "googletest", version = "1.14.0")
1419
bazel_dep(name = "ecsact_cli")
15-
1620
local_path_override(
1721
module_name = "ecsact_cli",
1822
path = "..",

0 commit comments

Comments
 (0)