This repository is based on twhl-community/halflife-updated, see its README.md for more information.
This repository contains a WASM runtime implementation for the GoldSrc
(Half-Life) engine using wasm-micro-runtime.
It allows modders and level-designers to load sandboxed executables at runtime,
allowing much more complex scripting than the entity system of the base engine
can do.
Exported native functions are documented in demo/wasmsrc/lib/native_engine.h.
Expected WASM entrypoints are documented in demo/wasmsrc/lib/native.h.
Example maps with WASM sources are available in the demo directory,
they require a clang ≥ 18 and wasm-ld to build. If this is too much of a
hassle and you don't want to build them you can remove demo/wasm/Tupfile and
demo/wasmsrc/Tupfile.
Demo maps use the GoldSrc dev textures WAD.
- On Windows, follow the instructions of the halflife-updated project, to build wasm artifacts, you're on your own.
- On Linux, install tup and run:
$ tup initonce at the root of the repository.$ tupto build. You can also use$ tup monitor -f -ato rebuild automatically when a file changes.- The built libraries are available at
dlls/hl.soandcl_dll/client.so.
For your convenience, the wasmr libraries are prebuilt, if you wish to compile
them yourself you can build the wasm-micro-runtime using the following
cmake invocations and put the resulting files in lib/public:
# win32
$ cmake .. \
-A Win32 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_GENERATOR_PLATFORM=Win32 \
-DWAMR_BUILD_PLATFORM=windows \
-DWAMR_BUILD_TARGET=X86_32 \
-DWAMR_BUILD_FAST_INTERP=0 \
-DWAMR_BUILD_SIMD=0 \
-DWAMR_BUILD_LIBC_BUILTIN=0 \
-DWAMR_BUILD_LIBC_WASI=0 \
-DWAMR_BUILD_AOT=0
# linux
$ cmake ../CMakeLists.txt \
-DCMAKE_BUILD_TYPE=Release \
-DWAMR_BUILD_PLATFORM=linux \
-DWAMR_BUILD_TARGET=X86_32 \
-DWAMR_BUILD_FAST_INTERP=0 \
-DWAMR_BUILD_SIMD=0 \
-DWAMR_BUILD_LIBC_BUILTIN=0 \
-DWAMR_BUILD_LIBC_WASI=0 \
-DWAMR_BUILD_AOT=0
- The native API exposed to the WASM runtime is to be considered mostly stable. New functions might be added but the existing ones should not change.
- The C library in
demo/wasmsrc/libis unstable and may change at any time depending on what my current project requires.
