Skip to content

[Feature]: Support WebAssembly (WASM) Compilation and Linking for C/C++ FFI Crate (tinyxml2-capi) #28

Description

@AteebNoOne

Description

Add official support, CI verification, and documentation for compiling the C/C++ FFI bindings crate (tinyxml2-capi) to WebAssembly targets (wasm32-unknown-unknown and wasm32-wasip1). This allows C and C++ applications compiled to WebAssembly (via Emscripten or WASI SDK) to link with the generated static library (libtinyxml2_capi.a) as a drop-in replacement for TinyXML2.

Use Case

Developers writing C or C++ applications targeted for the web (via Emscripten/WebAssembly) or standalone WebAssembly runtimes (via WASI/Wasmtime) want to use tinyxml2-rs as a safe, drop-in replacement for the original C++ tinyxml2 library.
Currently, WebAssembly support is only validated and documented for Rust applications using tinyxml2. Enabling WASM target compilation in CI and documenting the compilation/linking commands (e.g., for emcc and clang with WASI SDK) allows C/C++ developers to easily adopt tinyxml2-rs in their WebAssembly build pipelines.

TinyXML2 C++ Equivalent

The original TinyXML2 C++ library is a header+source library that can be compiled to WebAssembly targets using Emscripten or `clang`. This feature ensures that our C FFI replacement (`tinyxml2-capi`) has parity in supporting WebAssembly target compilation and linking.

Additional Context

No Rust code changes are necessary in tinyxml2-capi since it is already target-agnostic and compiles to WASM out-of-the-box. The required changes include:

  1. Workspace Version Bump: Update workspace package version to 1.1.1 in the root Cargo.toml.
  2. CI Pipeline Integration: Add matrix targets wasm32-unknown-unknown-capi and wasm32-wasip1-capi to .github/workflows/wasm-build.yml to compile tinyxml2-capi to WASM targets on every push/PR.
  3. Integration Guide: Update docs/architecture/wasm.md with instructions on compiling tinyxml2-capi for WebAssembly and linking it in projects using Emscripten (emcc) and WASI SDK (clang).
  4. Roadmap & Changelog: Document the additions in ROADMAP.md and CHANGELOG.md.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Fields

Area

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions