-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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,24 +1,67 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Change to the script directory | ||
cd "$(dirname "$0")" | ||
|
||
# Get root directory | ||
REPO_ROOT_DIR=$(git rev-parse --show-toplevel) | ||
|
||
# Check if emscripten is installed | ||
if ! command -v emcmake &> /dev/null; then | ||
echo "Emscripten is not installed. Please install it and make sure it is in your PATH." | ||
exit 1 | ||
fi | ||
|
||
# Generate the package structure | ||
mkdir -p package/src/build | ||
mkdir -p package/dist | ||
|
||
# Find core count for make. Prefer nproc, then sysctl, then default to 1 | ||
if command -v nproc &> /dev/null; then | ||
CORE_COUNT=$(nproc) | ||
elif command -v sysctl &> /dev/null; then | ||
CORE_COUNT=$(sysctl -n hw.logicalcpu) | ||
else | ||
CORE_COUNT=1 | ||
fi | ||
|
||
# Build the wasm module | ||
mkdir -p build | ||
cd build | ||
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DKIWI_USE_CPUINFO=OFF -DKIWI_BUILD_TEST=OFF -DKIWI_USE_MIMALLOC=OFF -DKIWI_BUILD_CLI=OFF -DKIWI_BUILD_EVALUATOR=OFF -DKIWI_BUILD_MODEL_BUILDER=OFF ../../../ | ||
make -j8 | ||
emcmake cmake \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DKIWI_USE_CPUINFO=OFF \ | ||
-DKIWI_USE_MIMALLOC=OFF \ | ||
-DKIWI_BUILD_TEST=OFF \ | ||
-DKIWI_BUILD_CLI=OFF \ | ||
-DKIWI_BUILD_EVALUATOR=OFF \ | ||
-DKIWI_BUILD_MODEL_BUILDER=OFF \ | ||
$REPO_ROOT_DIR | ||
make -j $CORE_COUNT | ||
cd .. | ||
|
||
# Copy the generated files to the package | ||
cp bindings/wasm/kiwi-wasm.js ../package/src/build/kiwi-wasm.js | ||
cp bindings/wasm/kiwi-wasm.wasm ../package/dist/kiwi-wasm.wasm | ||
cp build/bindings/wasm/kiwi-wasm.js package/src/build/kiwi-wasm.js | ||
cp build/bindings/wasm/kiwi-wasm.wasm package/dist/kiwi-wasm.wasm | ||
|
||
# Build typescript wrapper package | ||
cd ../package | ||
cd package | ||
npm install | ||
npm run build | ||
cd .. | ||
|
||
# Build the demo package if --demo or --demo-dev is passed | ||
# --demo with create a static build | ||
# --demo-dev will start a development server | ||
if [ "$1" == "--demo" ] || [ "$1" == "--demo-dev" ]; then | ||
cd package-demo | ||
npm install | ||
if [ "$1" == "--demo-dev" ]; then | ||
npm run dev | ||
else | ||
npm run build | ||
fi | ||
cd .. | ||
fi |
This file was deleted.
Oops, something went wrong.