Skip to content

Commit

Permalink
gh-13: Builds wasm version entirely with Meson.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbdclark committed Jan 2, 2022
1 parent 347f286 commit 8311563
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ jobs:
meson compile -C build/native
# Build libstar for wasm
# TODO: Determine why Windows can't find emcc.
- name: meson wasm build
if: runner.os != 'Windows'
run: |
cd libstar
meson setup build/wasm --cross-file wasm-cross-compile.txt
meson compile -C build/wasm
cd ../hosts/web
./build.sh
# Tests
- name: run unit tests
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ To remove all previous build artifacts and rebuild, run ```rm -r build/native &&
2. ```./build/native/libstar-console-example```

#### Web Example
1. ```cd hosts/web/```
2. ```./build.sh```
3. Open ```examples/midi-to-freq/index.html``` using VS Code's Live Server plugin or other web server.
1. Build libstar Web Assembly
2. Open ```hosts/web/examples/midi-to-freq/index.html``` using VS Code's Live Server plugin or other web server.

##### Daisy Bluemchen Example
1. ```cd hosts/daisy/vendor/libDaisy```
Expand Down
4 changes: 0 additions & 4 deletions hosts/web/build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion hosts/web/examples/midi-to-freq/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
}
};
</script>
<script src="../../build/libstar.js"></script>
<script src="../../../../libstar/build/wasm/libstar.js"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions libstar/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ libstar_dep = declare_dependency(
link_with: libstar_library
)

# Meson only seems to build .wasm and .js files for executables
if host_machine.system() == 'emscripten'
executable(
'libstar',
dependencies: [libstar_dep],
link_args: '--no-entry'
)
endif

# Examples
executable(
'libstar-console-example',
Expand Down
4 changes: 1 addition & 3 deletions libstar/wasm-cross-compile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ needs_exe_wrapper = true

[built-in options]
c_args = []
c_link_args = ['-s','EXPORT_ALL=1', '-s', 'LINKABLE=1', '-s']
cpp_args = []
cpp_link_args = ['-s','EXPORT_ALL=1', '-s', 'LINKABLE=1', '-s']
c_link_args = ['-s','EXPORT_ALL=1', '-s', 'LINKABLE=1', '-s', 'EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]']

[host_machine]
system = 'emscripten'
Expand Down

0 comments on commit 8311563

Please sign in to comment.