Commit08672e86Recorded9 Jul 2026Repositorysigil-audio
Gate native audio C out of wasm builds
Message
sigil-audio's native C (sokol_audio, vendored libogg/libvorbis) has no wasm32-wasi backend, so a wasm app depending on sigil-audio for the (sigil audio sink) facade failed to compile it ("unsupported platform").
Wrap the C-compilation build steps in skip-on-wasm so they are a no-op on wasm/wasi targets; compile-sigil-modules still runs, producing the facade + module bytecode. On wasm the facade delegates to the WebAudio bridge, so none of this C is needed. Native builds are byte-identical (the guard is false), and test-streaming-sink.sgl stays green.
Note: run-steps threads each step's return value as the next step's ctx, so a skipped step must return ctx unchanged.
Changed
package.sgl | 37 ++++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)Diff
package.sglmodified
@@ -4,7 +4,21 @@
4
;;; Sound effects are loaded into memory, music is streamed via stb_vorbis. 5
;;; OGG Vorbis encoding ships in-tree via vendored libogg + libvorbis. 6
−7
(package+7
;; skip-on-wasm wraps a build step so it is a no-op on wasm/wasi targets.+8
;; The native audio C (sokol_audio, vendored libogg/libvorbis) has no+9
;; wasm32-wasi backend; on wasm the (sigil audio sink) facade delegates to+10
;; the WebAudio bridge, so none of this C is needed. Only compile-sigil-modules+11
;; runs on wasm, producing the facade + module bytecode. Native builds are+12
;; unaffected (the guard is false), so behavior there is byte-identical.+13
;; run-steps threads each step's return value as the ctx for the next step+14
;; (fold-left over steps), so a skipped step must return ctx UNCHANGED.+15
(let ((skip-on-wasm+16
(lambda (step)+17
(lambda (ctx)+18
(if (memq (target-os ctx) '(wasm wasi))+19
ctx+20
(step ctx))))))+21
(package 22
name: "sigil-audio" 23
version: "0.11.0" 24
sigil: "^0.17"@@ -83,7 +97,12 @@
97
;; vendor/ogg/README.md); keeping warnings off avoids polluting 98
;; sigil-audio's own strict-flag set when upstream's style 99
;; trips -Wparentheses / -Wunused-* / -Wsign-compare.−86
(compile-c-sources+100
;;+101
;; The C steps are wrapped in skip-on-wasm: none of this native audio+102
;; C cross-compiles to wasm32-wasi, and the (sigil audio sink) facade's+103
;; wasm arm uses the WebAudio bridge instead. compile-sigil-modules is+104
;; NOT wrapped: the facade + module bytecode must still build on wasm.+105
(skip-on-wasm (compile-c-sources 106
sources: '("vendor/ogg/src/bitwise.c" 107
"vendor/ogg/src/framing.c") 108
include-dirs: '("vendor/ogg/include")@@ -92,13 +111,13 @@
111
"-Wno-unused-function" 112
"-Wno-unused-but-set-variable" 113
"-Wno-sign-compare"−95
"-Wno-strict-aliasing"))+114
"-Wno-strict-aliasing"))) 115
116
;; Compile vendored libvorbis (full library + encoder + file 117
;; I/O). Upstream sources are byte-identical to the 1.3.7 118
;; tarball (see vendor/vorbis/README.md). Same relaxed-warning 119
;; rationale as libogg above.−101
(compile-c-sources+120
(skip-on-wasm (compile-c-sources 121
sources: '("vendor/vorbis/lib/analysis.c" 122
"vendor/vorbis/lib/bitrate.c" 123
"vendor/vorbis/lib/block.c"@@ -143,16 +162,16 @@
162
"-Wno-unused-function" 163
"-Wno-unused-but-set-variable" 164
"-Wno-sign-compare"−146
"-Wno-strict-aliasing")))+165
"-Wno-strict-aliasing")))) 166
167
;; sigil-audio's own C sources.−149
(compile-c-sources+168
(skip-on-wasm (compile-c-sources 169
sources: '("src/c/sokol-audio.c" "src/c/audio.c" "src/c/audio-stream.c" "src/c/ogg-encode.c") 170
include-dirs: '("vendor/sokol" "vendor/stb" 171
"vendor/ogg/include" 172
"vendor/vorbis/include") 173
flags: (with-sigil-c-flags '("-std=c11" "-D_GNU_SOURCE"−155
"-Wno-unused-parameter" "-Wno-unused-function" "-Wno-sign-compare")))−156
(create-static-library name: "sigil-audio")+174
"-Wno-unused-parameter" "-Wno-unused-function" "-Wno-sign-compare"))))+175
(skip-on-wasm (create-static-library name: "sigil-audio")) 176
(compile-sigil-modules sources: "src/**/*.sgl"−158
output-dir: (config-output-subdir "lib"))))))+177
output-dir: (config-output-subdir "lib")))))))