Move build:wasm commands to dedicated scripts (#5813)
* add script to build on mac mini * Remove wasm-prep, rust flag only on wasm-pack build, add ps1 script * Make it exectuable, tested on macOS * Add set -e * Stop scripts on error --------- Co-authored-by: lf94 <ircsurfer33@gmail.com>
This commit is contained in:
@ -93,11 +93,9 @@
|
||||
"fetch:wasm:windows": "./scripts/get-latest-wasm-bundle.ps1",
|
||||
"fetch:samples": "rm -rf public/kcl-samples* && curl -L -o public/kcl-samples.zip https://github.com/KittyCAD/kcl-samples/archive/refs/heads/achalmers/kw-args-xylineto.zip && unzip -o public/kcl-samples.zip -d public && mv public/kcl-samples-* public/kcl-samples",
|
||||
"build:wasm-dev": "yarn wasm-prep && (cd rust && wasm-pack build kcl-wasm-lib --dev --target web --out-dir pkg && cargo test -p kcl-lib export_bindings) && yarn isomorphic-copy-wasm && yarn fmt",
|
||||
"build:wasm:nocopy": "yarn wasm-prep && cd rust && RUSTFLAGS='--cfg getrandom_backend=\"wasm_js\"' wasm-pack build kcl-wasm-lib --release --target web --out-dir pkg && cargo test -p kcl-lib export_bindings",
|
||||
"build:wasm": "yarn build:wasm:nocopy && cp rust/kcl-wasm-lib/pkg/kcl_wasm_lib_bg.wasm public && yarn fmt",
|
||||
"build:wasm:windows": "yarn install:wasm-pack:cargo && yarn build:wasm:nocopy && ./scripts/copy-wasm.ps1 && yarn fmt",
|
||||
"build:wasm": "./scripts/build-wasm.sh",
|
||||
"build:wasm:windows": "./scripts/build-wasm.ps1",
|
||||
"remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\" || echo \"sed for both mac and linux\"",
|
||||
"wasm-prep": "rimraf rust/kcl-wasm-lib/pkg && mkdirp rust/kcl-wasm-lib/pkg && rimraf rust/kcl-lib/bindings",
|
||||
"lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
|
||||
"lint": "eslint --max-warnings 0 --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
|
||||
"files:set-version": "echo \"$(jq --arg v \"$VERSION\" '.version=$v' package.json --indent 2)\" > package.json",
|
||||
|
18
scripts/build-wasm.ps1
Normal file
18
scripts/build-wasm.ps1
Normal file
@ -0,0 +1,18 @@
|
||||
# Stop the script when a cmdlet or a native command fails
|
||||
# from https://www.meziantou.net/stop-the-script-when-an-error-occurs-in-powershell.htm
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$PSNativeCommandUseErrorActionPreference = $true
|
||||
|
||||
rm -Recurse -Force rust/kcl-wasm-lib/pkg
|
||||
mkdir -p rust/kcl-wasm-lib/pkg
|
||||
rm -Recurse -Force rust/kcl-lib/bindings
|
||||
|
||||
cd rust
|
||||
$env:RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
|
||||
wasm-pack build kcl-wasm-lib --release --target web --out-dir pkg
|
||||
$env:RUSTFLAGS=''
|
||||
cargo test -p kcl-lib export_bindings
|
||||
cd ..
|
||||
|
||||
copy rust\kcl-wasm-lib\pkg\kcl_wasm_lib_bg.wasm public
|
||||
yarn fmt
|
16
scripts/build-wasm.sh
Executable file
16
scripts/build-wasm.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
rm -rf rust/kcl-wasm-lib/pkg
|
||||
mkdir -p rust/kcl-wasm-lib/pkg
|
||||
rm -rf rust/kcl-lib/bindings
|
||||
|
||||
cd rust
|
||||
export RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
|
||||
wasm-pack build kcl-wasm-lib --release --target web --out-dir pkg
|
||||
export RUSTFLAGS=''
|
||||
cargo test -p kcl-lib export_bindings
|
||||
cd ..
|
||||
|
||||
cp rust/kcl-wasm-lib/pkg/kcl_wasm_lib_bg.wasm public
|
||||
yarn fmt
|
@ -1 +0,0 @@
|
||||
copy rust\kcl-wasm-lib\pkg\kcl_wasm_lib_bg.wasm public
|
Reference in New Issue
Block a user