Skip to content

Commit

Permalink
fix build script
Browse files Browse the repository at this point in the history
  • Loading branch information
freestrings committed Apr 15, 2020
1 parent 81bbf47 commit 4917946
Show file tree
Hide file tree
Showing 25 changed files with 3,360 additions and 8,913 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ matrix:
- sh /tmp/rustup.sh -y
- export PATH="$HOME/.cargo/bin:$PATH"
- source "$HOME/.cargo/env"
- node -v
- npm -v
before_script:
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f
script:
Expand All @@ -65,8 +63,6 @@ matrix:
- sh /tmp/rustup.sh -y
- export PATH="$HOME/.cargo/bin:$PATH"
- source "$HOME/.cargo/env"
- node -v
- npm -v
before_script:
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f
script:
Expand Down
222 changes: 0 additions & 222 deletions benchmark/javascript/package-lock.json

This file was deleted.

109 changes: 48 additions & 61 deletions build-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ DIR="$(pwd)"
WASM="${DIR}"/wasm
WASM_WWW="${WASM}"/www
WASM_WWW_BENCH="${WASM}"/www_bench
WASM_BROWSER_PKG="${WASM}"/browser_pkg
WASM_NODEJS_PKG="${WASM}"/nodejs_pkg
WASM_ALL_PKG="${WASM}"/all_pkg
WASM_WEB_PKG="${WASM}"/web_pkg
WASM_TEST="${WASM}"/tests
DOCS="${DIR}"/docs
DOCS_BENCH="${DOCS}"/bench
Expand All @@ -19,6 +18,8 @@ __msg () {
}

__cargo_clean () {
rm -f "${DIR}"/Cargo.lock
rm -f "${WASM}"/Cargo.lock
cd "${WASM}" && cargo clean && \
cd "${DIR}" && cargo clean
}
Expand All @@ -27,78 +28,64 @@ echo
__msg "clean wasm"
rm -rf \
"${WASM_NODEJS_PKG}" \
"${WASM_BROWSER_PKG}" \
"${WASM_ALL_PKG}" \
"${WASM_WWW}"/node_modules \
"${WASM_WWW_BENCH}"/node_modules \
"${WASM_WEB_PKG}" \
"${WASM_WWW}"/dist \
"${WASM_WWW}"/node_modules \
"${WASM_WWW}"/package-lock.json \
"${WASM_WWW_BENCH}"/dist \
"${WASM_TEST}"/node_modules
"${WASM_WWW_BENCH}"/node_modules \
"${WASM_WWW_BENCH}"/package-lock.json \
"${WASM_TEST}"/node_modules \
"${WASM_TEST}"/package-lock.json

if [ "$1" = "all" ]; then
__msg "clean all wasm"
__cargo_clean
fi
__msg "clean cargo clean"
__cargo_clean

__msg "npm install: wasm"
cd "${WASM_WWW}" && npm install
__msg "npm install: wasm_bench"
cd "${WASM_WWW_BENCH}" && npm install
__msg "npm install: wasm test"
cd "${WASM_TEST}" && npm install

echo
echo
__msg "wasm-pack"
cd "${WASM}" && \
wasm-pack build --release --target=nodejs --out-dir "${WASM_NODEJS_PKG}"

cd "${WASM}" && \
wasm-pack build --release --target=browser --out-dir "${WASM_BROWSER_PKG}"
# && \
# wasm-pack test --chrome --firefox --headless

__msg "wasm npm packaging"
cp -r "${WASM_BROWSER_PKG}" "${WASM_ALL_PKG}/" && \
sed "s/require[\(]'\.\/jsonpath_wasm_bg/require\('\.\/jsonpath_wasm_nodejs/" "${WASM_NODEJS_PKG}/jsonpath_wasm.js" \
> "${WASM_ALL_PKG}/jsonpath_wasm_main.js" && \
sed "s/require[\(]'\.\/jsonpath_wasm/require\('\.\/jsonpath_wasm_main/" "${WASM_NODEJS_PKG}/jsonpath_wasm_bg.js" \
> "${WASM_ALL_PKG}/jsonpath_wasm_nodejs.js" && \
jq ".files += [\"jsonpath_wasm_nodejs.js\"]" ${WASM_ALL_PKG}/package.json \
| jq ".main = \"jsonpath_wasm_main.js\"" \
| jq ".keywords += [\"jsonpath\", \"json\", \"webassembly\", \"parsing\", \"rust\"]" \
> ${WASM_ALL_PKG}/temp.json && \
mv -v "${WASM_ALL_PKG}/temp.json" "${WASM_ALL_PKG}/package.json" && \
cd "${WASM_ALL_PKG}" && npm link
wasm_pack_version=$(wasm-pack -V)
__msg "wasm-pack: ${wasm_pack_version}"

echo
__msg "link"
cd "${WASM_WWW}" && \
npm link jsonpath-wasm

cd "${WASM_WWW_BENCH}" && \
npm link jsonpath-wasm
__msg "wasm-pack nodejs"
cd "${WASM}" && wasm-pack build --release --target "nodejs" --out-dir "${WASM_NODEJS_PKG}"

cd "${WASM_TEST}" && \
npm link jsonpath-wasm
__msg "npm install: wasm test"
cd "${WASM_TEST}" && npm install "${WASM_NODEJS_PKG}" && npm install

echo
echo
__msg "wasm test"
cd "${WASM_TEST}" && npm test

if [ "$1" = "all" ] || [ "$1" = "docs" ]; then
echo
__msg "docs"
cd "${WASM_WWW}" && \
npm run build &&
rm -f "${DOCS}"/*.js "${DOCS}"/*.wasm "${DOCS}"/*.html && \
cp "${WASM_WWW}"/dist/*.* "${DOCS}"/

cd "${WASM_WWW_BENCH}" && \
npm run build &&
rm -f "${DOCS_BENCH}"/*.js "${DOCS_BENCH}"/*.wasm "${DOCS_BENCH}"/*.html && \
cp "${WASM_WWW_BENCH}"/dist/*.* "${DOCS_BENCH}"/
if [ "$1" = "docs" ]; then
echo
__msg "wasm-pack web"
cd "${WASM}" && wasm-pack build --release --out-dir "${WASM_WEB_PKG}"

echo
__msg "jsonpath-wasm npm link"
cd "${WASM_WEB_PKG}" && npm link

__msg "npm install: wasm"
cd "${WASM_WWW}" && npm install
__msg "npm install: wasm_bench"
cd "${WASM_WWW_BENCH}" && npm install

echo
__msg "link"
cd "${WASM_WWW}" && npm link jsonpath-wasm
cd "${WASM_WWW_BENCH}" && npm link jsonpath-wasm

echo
__msg "docs"
cd "${WASM_WWW}" && \
npm run build &&
rm -f "${DOCS}"/*.js "${DOCS}"/*.wasm "${DOCS}"/*.html && \
cp "${WASM_WWW}"/dist/*.* "${DOCS}"/

cd "${WASM_WWW_BENCH}" && \
npm run build &&
rm -f "${DOCS_BENCH}"/*.js "${DOCS_BENCH}"/*.wasm "${DOCS_BENCH}"/*.html && \
cp "${WASM_WWW_BENCH}"/dist/*.* "${DOCS_BENCH}"/
fi

__msg "wasm done"
Loading

0 comments on commit 4917946

Please sign in to comment.