From 9448104f4128aa90bfd0bbe91b6e4a541978eb5b Mon Sep 17 00:00:00 2001 From: Reuben Dunnington Date: Sun, 24 Sep 2023 23:15:44 -0400 Subject: [PATCH] macos: separate building orca core from samples --- samples/breakout/build.sh | 8 +++++++- samples/clock/build.sh | 8 +++++++- samples/fluid/build.sh | 8 +++++++- samples/triangle/build.sh | 8 +++++++- samples/ui/build.sh | 8 +++++++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/samples/breakout/build.sh b/samples/breakout/build.sh index 28b2d5d..807888c 100755 --- a/samples/breakout/build.sh +++ b/samples/breakout/build.sh @@ -15,6 +15,7 @@ fi ORCA_DIR=../.. STDLIB_DIR=$ORCA_DIR/src/libc-shim +# common flags to build wasm modules wasmFlags="--target=wasm32 \ --no-standard-libraries \ -mbulk-memory \ @@ -26,6 +27,11 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +# build orca core as wasm module +clang $wasmFlags -Wl,--relocatable -o ./liborca.a $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c +# build sample as wasm module and link it with the orca module +clang $wasmFlags -L . -lorca -o module.wasm src/main.c + +# create app directory and copy files into it orca bundle --orca-dir $ORCA_DIR --name Breakout --icon icon.png --resource-dir data module.wasm diff --git a/samples/clock/build.sh b/samples/clock/build.sh index 55b51fb..4069b4b 100755 --- a/samples/clock/build.sh +++ b/samples/clock/build.sh @@ -15,6 +15,7 @@ fi ORCA_DIR=../.. STDLIB_DIR=$ORCA_DIR/src/libc-shim +# common flags to build wasm modules wasmFlags="--target=wasm32 \ --no-standard-libraries \ -mbulk-memory \ @@ -26,6 +27,11 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +# build orca core as wasm module +clang $wasmFlags -Wl,--relocatable -o ./liborca.a $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c +# build sample as wasm module and link it with the orca module +clang $wasmFlags -L . -lorca -o module.wasm src/main.c + +# create app directory and copy files into it orca bundle --orca-dir $ORCA_DIR --name Clock --icon icon.png --resource-dir data module.wasm diff --git a/samples/fluid/build.sh b/samples/fluid/build.sh index 79bbf06..e13eb11 100755 --- a/samples/fluid/build.sh +++ b/samples/fluid/build.sh @@ -17,6 +17,7 @@ STDLIB_DIR=$ORCA_DIR/src/libc-shim python3 ../../scripts/embed_text_files.py --prefix=glsl_ --output src/glsl_shaders.h src/shaders/*.glsl +# common flags to build wasm modules wasmFlags="--target=wasm32 \ --no-standard-libraries \ -mbulk-memory \ @@ -28,6 +29,11 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +# build orca core as wasm module +clang $wasmFlags -Wl,--relocatable -o ./liborca.a $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c +# build sample as wasm module and link it with the orca module +clang $wasmFlags -L . -lorca -o module.wasm src/main.c + +# create app directory and copy files into it orca bundle --orca-dir $ORCA_DIR --name Fluid --icon icon.png module.wasm diff --git a/samples/triangle/build.sh b/samples/triangle/build.sh index a83b61a..ba68ae4 100755 --- a/samples/triangle/build.sh +++ b/samples/triangle/build.sh @@ -15,6 +15,7 @@ fi ORCA_DIR=../.. STDLIB_DIR=$ORCA_DIR/src/libc-shim +# common flags to build wasm modules wasmFlags="--target=wasm32 \ --no-standard-libraries \ -mbulk-memory \ @@ -26,6 +27,11 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +# build orca core as wasm module +clang $wasmFlags -Wl,--relocatable -o ./liborca.a $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c +# build sample as wasm module and link it with the orca module +clang $wasmFlags -L . -lorca -o module.wasm src/main.c + +# create app directory and copy files into it orca bundle --orca-dir $ORCA_DIR --name Triangle module.wasm diff --git a/samples/ui/build.sh b/samples/ui/build.sh index bffba7f..98c1e87 100755 --- a/samples/ui/build.sh +++ b/samples/ui/build.sh @@ -15,6 +15,7 @@ fi ORCA_DIR=../.. STDLIB_DIR=$ORCA_DIR/src/libc-shim +# common flags to build wasm modules wasmFlags="--target=wasm32 \ --no-standard-libraries \ -mbulk-memory \ @@ -26,6 +27,11 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +# build orca core as wasm module +clang $wasmFlags -Wl,--relocatable -o ./liborca.a $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c +# build sample as wasm module and link it with the orca module +clang $wasmFlags -L . -lorca -o module.wasm src/main.c + +# create app directory and copy files into it orca bundle --orca-dir $ORCA_DIR --name UI --resource-dir data module.wasm