From 5bb1623de80b5f9229174447870f23e04a108efa Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:10:32 +0100 Subject: [PATCH 01/14] Added Workflow for building WASM bindings --- .github/workflows/build_wasm.yml | 37 ++++++++++++++++++++++++++++++++ Cargo.toml | 13 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/build_wasm.yml diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml new file mode 100644 index 00000000..d76d7df5 --- /dev/null +++ b/.github/workflows/build_wasm.yml @@ -0,0 +1,37 @@ +name: 'Build WebAssembly' + +on: + push: + branches: + - master + + workflow_dispatch: + inputs: + build: + description: 'Build WASM files.' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v3 + + - name: 'Install wasm-pack' + run: | + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + export PATH="$HOME/.cargo/bin:$PATH" + + - name: 'Build WebAssembly' + run: | + rustup target add wasm32-unknown-unknown + wasm-pack build --release --target web --out-name index + mkdir -p artifacts + find pkg -type f \( -name "*.js" -o -name "*.d.ts" -o -name "*.wasm" \) -exec cp {} artifacts \; + + - name: 'Upload Artifacts' + uses: actions/upload-artifact@v3 + with: + name: 'wasm' + path: artifacts/* diff --git a/Cargo.toml b/Cargo.toml index 2598e479..ccf10c3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,3 +18,16 @@ lto = true codegen-units = 1 panic = 'abort' strip = true + +[package] +name = 'grass-wasm' +edition = "2021" + +[lib] +path = "crates/lib/src/lib.rs" +crate-type = ["cdylib"] + +[dependencies] +wasm-bindgen = "0.2" +grass_compiler = { path = "crates/compiler" } +getrandom = { version = "0.2", features = ["js"] } From 65f2556d582847667c4b5ae3c5d852d2f11961cc Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Fri, 2 Feb 2024 06:37:04 +0100 Subject: [PATCH 02/14] Update Cargo.toml --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index ccf10c3c..5151bf44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ strip = true [package] name = 'grass-wasm' edition = "2021" +version = "v0.1.0" [lib] path = "crates/lib/src/lib.rs" From e8d9c549343ba66836afd4f0f4e13209debd5db7 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Fri, 2 Feb 2024 06:38:53 +0100 Subject: [PATCH 03/14] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5151bf44..c96757b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ strip = true [package] name = 'grass-wasm' edition = "2021" -version = "v0.1.0" +version = "0.1.0" [lib] path = "crates/lib/src/lib.rs" From a1ce73fee027e1f7e0e839a014ddae3970e36802 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Fri, 2 Feb 2024 06:50:01 +0100 Subject: [PATCH 04/14] Update build_wasm.yml --- .github/workflows/build_wasm.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml index d76d7df5..46699254 100644 --- a/.github/workflows/build_wasm.yml +++ b/.github/workflows/build_wasm.yml @@ -1,14 +1,12 @@ name: 'Build WebAssembly' on: - push: - branches: - - master + release: workflow_dispatch: inputs: build: - description: 'Build WASM files.' + description: 'Build WebAssembly binding files.' jobs: build: From 41da790f1fba8f82e0c147add8cbefc5d3dd4e9b Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Fri, 2 Feb 2024 06:55:43 +0100 Subject: [PATCH 05/14] Update build_wasm.yml --- .github/workflows/build_wasm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml index 46699254..c45e4657 100644 --- a/.github/workflows/build_wasm.yml +++ b/.github/workflows/build_wasm.yml @@ -2,6 +2,9 @@ name: 'Build WebAssembly' on: release: + types: + - released + - prereleased workflow_dispatch: inputs: From d3e2877f2e97ad72fb5b3b31732373ec83a592f0 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Fri, 2 Feb 2024 07:13:31 +0100 Subject: [PATCH 06/14] Update .github/workflows/build_wasm.yml Co-authored-by: Katze719 <38188106+Katze719@users.noreply.github.com> --- .github/workflows/build_wasm.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml index c45e4657..49d26264 100644 --- a/.github/workflows/build_wasm.yml +++ b/.github/workflows/build_wasm.yml @@ -1,10 +1,8 @@ name: 'Build WebAssembly' on: - release: - types: - - released - - prereleased + push: + tags: [ '*' ] workflow_dispatch: inputs: From 0dd26a10502ea1aa7355ee8c7669623b73e822d2 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 06:44:59 +0100 Subject: [PATCH 07/14] Updated Workflow --- .github/workflows/build_wasm.yml | 11 +++++------ .github/workflows/tests.yml | 2 +- Cargo.toml | 13 ------------- crates/lib/Cargo.toml | 5 ++++- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml index 49d26264..ea96797e 100644 --- a/.github/workflows/build_wasm.yml +++ b/.github/workflows/build_wasm.yml @@ -5,9 +5,6 @@ on: tags: [ '*' ] workflow_dispatch: - inputs: - build: - description: 'Build WebAssembly binding files.' jobs: build: @@ -15,7 +12,7 @@ jobs: steps: - name: 'Checkout Repository' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Install wasm-pack' run: | @@ -25,12 +22,14 @@ jobs: - name: 'Build WebAssembly' run: | rustup target add wasm32-unknown-unknown + pushd ./crates/lib wasm-pack build --release --target web --out-name index + popd mkdir -p artifacts - find pkg -type f \( -name "*.js" -o -name "*.d.ts" -o -name "*.wasm" \) -exec cp {} artifacts \; + find crates/lib/pkg -type f \( -name "*.js" -o -name "*.d.ts" -o -name "*.wasm" \) -exec cp {} artifacts \; - name: 'Upload Artifacts' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: 'wasm' path: artifacts/* diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d40fba6f..787957d8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,7 +50,7 @@ jobs: rustup component add clippy cargo clippy --features=macro -- -D warnings - boostrap: + bootstrap: runs-on: ubuntu-latest steps: - name: Checkout diff --git a/Cargo.toml b/Cargo.toml index c96757b3..caa3e734 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,16 +19,3 @@ codegen-units = 1 panic = 'abort' strip = true -[package] -name = 'grass-wasm' -edition = "2021" -version = "0.1.0" - -[lib] -path = "crates/lib/src/lib.rs" -crate-type = ["cdylib"] - -[dependencies] -wasm-bindgen = "0.2" -grass_compiler = { path = "crates/compiler" } -getrandom = { version = "0.2", features = ["js"] } diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 85652ea2..33d19769 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -21,9 +21,10 @@ required-features = ["commandline"] [lib] name = "grass" path = "src/lib.rs" -# crate-type = ["cdylib", "rlib"] +crate-type = ["cdylib", "rlib"] bench = false + [package.metadata.docs.rs] # To build locally: # RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --features=macro --no-deps --open @@ -31,6 +32,8 @@ features = ["macro"] rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] +wasm-bindgen = "0.2" +getrandom = { version = "0.2", features = ["js"] } grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false } include_sass = { path = "../include_sass", version = "0.13.2", optional = true } clap = { version = "4.3.10", optional = true } From aefafbcf97e2b94c035a5f3e9f8ce7ff2ccc7dfd Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 08:40:38 +0100 Subject: [PATCH 08/14] Update Cargo.toml --- crates/lib/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 33d19769..9c6ca66d 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -21,7 +21,7 @@ required-features = ["commandline"] [lib] name = "grass" path = "src/lib.rs" -crate-type = ["cdylib", "rlib"] +# crate-type = ["cdylib", "rlib"] bench = false @@ -32,8 +32,8 @@ features = ["macro"] rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] -wasm-bindgen = "0.2" -getrandom = { version = "0.2", features = ["js"] } +# wasm-bindgen = "0.2" +# getrandom = { version = "0.2", features = ["js"] } grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false } include_sass = { path = "../include_sass", version = "0.13.2", optional = true } clap = { version = "4.3.10", optional = true } From fd14bd7f58c69e14fed7f24642f05a72cc6dd8d0 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 08:43:47 +0100 Subject: [PATCH 09/14] Update Cargo.toml --- crates/lib/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 9c6ca66d..a27e89c9 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -21,7 +21,7 @@ required-features = ["commandline"] [lib] name = "grass" path = "src/lib.rs" -# crate-type = ["cdylib", "rlib"] +crate-type = ["cdylib", "rlib"] bench = false From 2c2ecf119a901066d9dcbc2c4c95ca1df9655959 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 08:50:11 +0100 Subject: [PATCH 10/14] Update Cargo.toml --- crates/lib/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index a27e89c9..ebb54c34 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -33,7 +33,7 @@ rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] # wasm-bindgen = "0.2" -# getrandom = { version = "0.2", features = ["js"] } +getrandom = { version = "0.2", features = ["js"] } grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false } include_sass = { path = "../include_sass", version = "0.13.2", optional = true } clap = { version = "4.3.10", optional = true } From ab9144cf194b1f01fcd056757d0c5db8c0cd7a6b Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:02:58 +0100 Subject: [PATCH 11/14] Update Cargo.toml --- crates/lib/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index ebb54c34..155635e1 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -33,6 +33,7 @@ rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] # wasm-bindgen = "0.2" +wasm-exports = ["wasm-bindgen"] getrandom = { version = "0.2", features = ["js"] } grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false } include_sass = { path = "../include_sass", version = "0.13.2", optional = true } From 3e77592a6e5839fa9011b10e11b013129f65395e Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:04:48 +0100 Subject: [PATCH 12/14] Update Cargo.toml --- crates/lib/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 155635e1..4928bd12 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -33,7 +33,6 @@ rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] # wasm-bindgen = "0.2" -wasm-exports = ["wasm-bindgen"] getrandom = { version = "0.2", features = ["js"] } grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false } include_sass = { path = "../include_sass", version = "0.13.2", optional = true } @@ -45,7 +44,7 @@ default = ["commandline", "random"] # Option (enabled by default): build a binary using clap commandline = ["clap"] random = ["grass_compiler/random"] -wasm-exports = ["grass_compiler/wasm-exports"] +wasm-exports = ["grass_compiler/wasm-exports", "wasm-bindgen"] # Option: include the proc macro `include_sass!` macro = ["include_sass"] nightly = ["include_sass/nightly"] From 4e6fae427b0514db1d4c641fe39569d472bcc1e2 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:06:05 +0100 Subject: [PATCH 13/14] Update Cargo.toml --- crates/lib/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 4928bd12..e64e71fe 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -32,7 +32,7 @@ features = ["macro"] rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] -# wasm-bindgen = "0.2" +wasm-bindgen = "0.2" getrandom = { version = "0.2", features = ["js"] } grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false } include_sass = { path = "../include_sass", version = "0.13.2", optional = true } From f155bfa0d93e1ee8a73706e8304b2aadb9a592c3 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:07:33 +0100 Subject: [PATCH 14/14] Update Cargo.toml --- crates/lib/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index e64e71fe..9b7913fb 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -32,7 +32,7 @@ features = ["macro"] rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] -wasm-bindgen = "0.2" +wasm-bindgen = { version = "0.2", optional = true } getrandom = { version = "0.2", features = ["js"] } grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false } include_sass = { path = "../include_sass", version = "0.13.2", optional = true }