mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-04-30 19:09:26 +08:00
* Fix #472: Add Emscripten/WebAssembly build for browser-based ChaiScript Port Rob Loach's ChaiScript.js work (https://github.com/RobLoach/ChaiScript.js) into the main repository as an Emscripten build target. Adds a GitHub Actions workflow that builds ChaiScript to WebAssembly and publishes artifacts (JS, WASM, HTML) for embedding in the official ChaiScript.com website. Includes an HTML interactive playground frontend and a native test validating the eval API surface. Co-Authored-By: Rob Loach <robloach@gmail.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Address review: publish WASM assets as release under wasm-latest tag Add a publish job to the emscripten workflow that creates a prerelease tagged wasm-latest with chaiscript.js, chaiscript.wasm, and chaiscript.html as downloadable assets. Runs only on pushes to the develop branch. The website repo can fetch these via the public GitHub Releases API on a daily cron without any cross-repo auth. Requested by @lefticus in PR #662 review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: leftibot <leftibot@users.noreply.github.com> Co-authored-by: Rob Loach <robloach@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.0 KiB
CMake
36 lines
1.0 KiB
CMake
# Emscripten/WebAssembly build for ChaiScript
|
|
# Based on work by Rob Loach: https://github.com/RobLoach/ChaiScript.js
|
|
#
|
|
# Usage:
|
|
# emcmake cmake -B build-em -S emscripten
|
|
# cmake --build build-em
|
|
|
|
cmake_minimum_required(VERSION 3.12)
|
|
project(chaiscript_em)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Emscripten-specific compiler/linker flags
|
|
add_definitions(-DCHAISCRIPT_NO_THREADS -DCHAISCRIPT_NO_DYNLOAD)
|
|
|
|
add_executable(chaiscript chaiscript_em.cpp)
|
|
target_include_directories(chaiscript PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
|
|
|
# Emscripten link flags: enable embind, allow memory growth, export as ES module-compatible
|
|
target_link_options(chaiscript PRIVATE
|
|
--bind
|
|
-sALLOW_MEMORY_GROWTH=1
|
|
-sEXPORT_ES6=0
|
|
-sMODULARIZE=0
|
|
-sINVOKE_RUN=0
|
|
)
|
|
|
|
# Copy the HTML shell to the build output directory
|
|
add_custom_command(TARGET chaiscript POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
${CMAKE_CURRENT_SOURCE_DIR}/chaiscript.html
|
|
${CMAKE_CURRENT_BINARY_DIR}/chaiscript.html
|
|
COMMENT "Copying HTML frontend to build directory"
|
|
)
|