@@ -120,6 +120,24 @@ static auto write_file(fs::path path, std::span<std::byte> data) -> void {
120
120
file.write (reinterpret_cast <const char *>(data.data ()), data.size ());
121
121
}
122
122
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
+
123
141
static auto handle_source ( //
124
142
fs::path base_directory,
125
143
ecsact::build_recipe::source_fetch src,
@@ -722,6 +740,18 @@ auto cl_compile(compile_options options) -> int {
722
740
return params_file_path;
723
741
};
724
742
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
+
725
755
cl_args.push_back (" /nologo" );
726
756
cl_args.push_back (" /D_WIN32_WINNT=0x0A00" );
727
757
cl_args.push_back (" /diagnostics:column" );
@@ -768,6 +798,10 @@ auto cl_compile(compile_options options) -> int {
768
798
cl_args.push_back (std::format (" /I{}" , inc_dir.string ()));
769
799
}
770
800
801
+ if (wants_wasmer && wasmer_dir) {
802
+ cl_args.push_back (std::format (" /I{}" , (*wasmer_dir / " include" ).string ()));
803
+ }
804
+
771
805
if (options.tracy_dir ) {
772
806
cl_args.push_back (std::format (" /I{}" , options.tracy_dir ->string ()));
773
807
}
@@ -868,6 +902,10 @@ auto cl_compile(compile_options options) -> int {
868
902
cl_args.push_back (" @" + obj_params_file.string ());
869
903
cl_args.push_back (" @" + main_params_file.string ());
870
904
905
+ if (wants_wasmer && wasmer_dir) {
906
+ cl_args.push_back ((*wasmer_dir / " lib" / " wasmer.lib" ).string ());
907
+ }
908
+
871
909
if (options.tracy_dir ) {
872
910
auto tracy_lib =
873
911
fs::path{options.output_path .parent_path () / " profiler.lib" };
@@ -881,6 +919,19 @@ auto cl_compile(compile_options options) -> int {
881
919
cl_args.push_back (" /DLL" );
882
920
883
921
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
+ }
884
935
cl_args.push_back (std::format (" /DEFAULTLIB:{}" , sys_lib));
885
936
}
886
937
0 commit comments