Repository navigation
feat(wasm): scaffold @csound/plugins npm package #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cdc51c0
feat(wasm): scaffold @csound/plugins npm package
hlolli 0ace7f0
chore(wasm): use reviewed plugin runtime
hlolli e0b4674
build(wasm): use released SDK and enable Cachix
hlolli 59771ad
build(wasm): test against published browser runtime
hlolli 70ead80
ci(wasm): disable checkout credential persistence
hlolli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: Csound 7 WASM plugins | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [develop] | ||
| push: | ||
| branches: [develop] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| package: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - uses: actions/checkout@v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@v7.1.0 | ||
| with: | ||
| node-version: 22 | ||
| cache: npm | ||
| - uses: cachix/install-nix-action@v31.11.1 | ||
| - uses: cachix/cachix-action@v17 | ||
| with: | ||
| name: csound | ||
| authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | ||
| skipPush: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} | ||
| - name: Install JS dependencies | ||
| run: npm ci | ||
| - name: Build WASM plugins with CMake and Nix | ||
| run: npm run build | ||
| - name: Test and pack | ||
| run: npm pack | ||
| - uses: actions/upload-artifact@v7.0.2 | ||
| with: | ||
| name: csound-plugins-npm | ||
| path: csound-plugins-*.tgz | ||
| if-no-files-found: error | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| build | ||
| dist | ||
| csound6-plugins-win_x86_64-* | ||
| node_modules/ | ||
| result* | ||
| *.tgz | ||
| .csound/ | ||
| .wasm-dist.*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Match platform/wasm-wasi/src/plugin_example*.nix in csound/csound. | ||
| set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
| set(USE_COMPILER_OPTIMIZATIONS OFF CACHE BOOL "" FORCE) | ||
| set(REQUIRE_PTHREADS OFF CACHE BOOL "" FORCE) | ||
| set(USE_DOUBLE ON CACHE BOOL "" FORCE) | ||
| execute_process(COMMAND ${CMAKE_C_COMPILER} --print-libgcc-file-name | ||
| OUTPUT_VARIABLE WASM_BUILTINS OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| COMMAND_ERROR_IS_FATAL ANY) | ||
|
|
||
| function(configure_wasm_plugin target) | ||
| set_target_properties(${target} PROPERTIES SUFFIX ".wasm") | ||
| target_compile_features(${target} PRIVATE c_std_11) | ||
| target_compile_definitions(${target} PRIVATE | ||
| USE_DOUBLE=1 _WASI_EMULATED_SIGNAL _WASI_EMULATED_MMAN) | ||
| target_compile_options(${target} PRIVATE | ||
| -fPIC "SHELL:-mllvm -wasm-enable-sjlj" | ||
| "$<$<COMPILE_LANGUAGE:C>:-std=gnu11>" | ||
| "$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions;-nostdinc++>" | ||
| "$<$<COMPILE_LANGUAGE:CXX>:-isystem${WASM_CXX_INCLUDE_DIR}>") | ||
| target_link_options(${target} PRIVATE | ||
| -shared -nostdlib -nostartfiles | ||
| "LINKER:-Bsymbolic" | ||
| "LINKER:--experimental-pic" | ||
| "LINKER:--no-entry" | ||
| "LINKER:--import-table" | ||
| "LINKER:--import-memory" | ||
| "LINKER:--allow-undefined" | ||
| "LINKER:--export=__wasm_call_ctors" | ||
| "LINKER:--export-if-defined=__wasm_apply_data_relocs" | ||
| "LINKER:--export-if-defined=csound_opcode_init" | ||
| "LINKER:--export-if-defined=csoundModuleInfo" | ||
| "LINKER:--export-if-defined=csoundModuleInit" | ||
| "LINKER:--export-if-defined=csoundModuleCreate" | ||
| "LINKER:--export-if-defined=csoundModuleDestroy") | ||
| target_link_libraries(${target} PRIVATE | ||
| "${WASM_LIBCXX}" "${WASM_LIBC}" "${WASM_SETJMP}" "${WASM_BUILTINS}") | ||
| endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Third-party code in the WASM package | ||
|
|
||
| The plugins use the LGPL-2.1-or-later license in `LICENSE`. Their source and | ||
| copyright notices live under [`7.x/src`](https://github.com/csound/plugins/tree/develop/7.x/src). | ||
| The package also contains code from these libraries: | ||
|
|
||
| | Library | Used by | License notices | | ||
| | --- | --- | --- | | ||
| | Eigen | Chua | `dist/licenses/eigen/` | | ||
| | GMM++ (GetFEM) | Linear algebra | `dist/licenses/gmm.txt`; LGPL-3.0-or-later with the exception in the headers | | ||
| | libpng | Image | `dist/licenses/libpng.txt` | | ||
| | zlib | Image | `dist/licenses/zlib.txt` | | ||
| | wasi-libc, musl, cloudlibc, musl-fts | C runtime | `dist/licenses/wasi-libc/` | | ||
| | LLVM libc++, libc++abi, compiler-rt | C++ runtime and compiler support | `dist/licenses/libcxx.txt`, `libcxxabi.txt`, `compiler-rt.txt` | | ||
|
|
||
| The Nix build copies these notices from the source used to build each library. | ||
| [`wasm/nixpkgs.nix`](https://github.com/csound/plugins/blob/develop/wasm/nixpkgs.nix) | ||
| pins their source versions. The GMM++ headers live in this repository. The build | ||
| uses upstream CMake and make options for static PIC libraries; it adds no source | ||
| patches. `wasm/default.nix` records those options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /** Asset URLs for Csound 7's `withPlugins` option. */ | ||
| export declare const plugins: Readonly<{ | ||
| chua: string; | ||
| image: string; | ||
| linearAlgebra: string; | ||
| }>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /** Asset URLs for Csound 7's `withPlugins` option. */ | ||
| export const plugins = Object.freeze({ | ||
| chua: new URL("./dist/chua.wasm", import.meta.url).href, | ||
| image: new URL("./dist/image.wasm", import.meta.url).href, | ||
| linearAlgebra: new URL("./dist/linear_algebra.wasm", import.meta.url).href, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.