mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
27321a2110
This commit adds support for building the Nexus simulator for WebAssembly (WASM) using the Emscripten toolchain. This enables the simulator to run in a web browser environment with a JavaScript-based control interface and visualization. Key implementation details: - Introduced `nexus_wasm.cpp` which defines Emscripten bindings (using Embind) for core simulation controls, including stepping time, node creation, topology orchestration, and state manipulation. - Implemented a `WasmObserver` and a global event queue to capture simulation events (node state changes, link updates, packet events) and expose them to JavaScript via a polling mechanism (`pollEvent`). - Updated the CMake build system to support the `EMSCRIPTEN` platform, configuring specific linker options for ES6 module export, modularization, and memory growth. - Enhanced `build.sh` to allow targeting WASM via `emcmake`. - Guarded file-system-dependent operations in `nexus_pcap.cpp` and adjusted `nexus_core.cpp` to handle WASM-specific constraints where standard I/O or multiple observers might not be applicable. - Added `test_wasm_bindings.mjs`, a Node.js-based smoke test that verifies the integrity of the WASM bindings and event pipeline. - Integrated `nexus-wasm-tests` into the GitHub Actions workflow to ensure continuous verification of the WASM build and functionality.