Skip to content

About

WASM runtime for Half-Life and GoldSrc mods.

Topics

Resources

Stars

14 stars

Watchers

1 watching

Forks

 
 

Latest commit

 

History

886 Commits

Folders and files

Repository files navigation

wasm runtime for GoldSrc

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.

Demo

Demo

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.

Building

  • 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:
    1. $ tup init once at the root of the repository.
    2. $ tup to build. You can also use $ tup monitor -f -a to rebuild automatically when a file changes.
    3. The built libraries are available at dlls/hl.so and cl_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

Unstable API warning

  • 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/lib is unstable and may change at any time depending on what my current project requires.

About

WASM runtime for Half-Life and GoldSrc mods.

Topics

Resources

Stars

14 stars

Watchers

1 watching

Forks

Contributors

Languages