diff --git a/.gitignore b/.gitignore index 9933885..22ca4fd 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ build *.wasm *.app *.dylib +*.a Debug/* @@ -39,4 +40,4 @@ scripts/files /ext src/ext/angle -sketches/*/bin \ No newline at end of file +sketches/*/bin diff --git a/samples/breakout/build.bat b/samples/breakout/build.bat index a63b8ae..74e181d 100644 --- a/samples/breakout/build.bat +++ b/samples/breakout/build.bat @@ -15,7 +15,7 @@ if exist "..\..\scripts\sample_build_check.py" ( set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim -:: compile wasm module +:: common flags to build wasm modules set wasmFlags=--target=wasm32^ --no-standard-libraries ^ -mbulk-memory ^ @@ -27,7 +27,13 @@ set 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 -if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! +:: build orca core as wasm module +clang %wasmFlags% -Wl,--relocatable -o .\liborca.a %ORCA_DIR%\src\orca.c %ORCA_DIR%\src\libc-shim\src\*.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +:: build sample as wasm module and link it with the orca module +clang %wasmFlags% -L . -lorca -o module.wasm src/main.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% + +:: 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/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.bat b/samples/clock/build.bat index f9579fb..9eedbf0 100644 --- a/samples/clock/build.bat +++ b/samples/clock/build.bat @@ -15,7 +15,7 @@ if exist "..\..\scripts\sample_build_check.py" ( set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim -:: compile wasm module +:: common flags to build wasm modules set wasmFlags=--target=wasm32^ --no-standard-libraries ^ -mbulk-memory ^ @@ -27,7 +27,13 @@ set 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 -if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! +:: build orca core as wasm module +clang %wasmFlags% -Wl,--relocatable -o .\liborca.a %ORCA_DIR%\src\orca.c %ORCA_DIR%\src\libc-shim\src\*.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +:: build sample as wasm module and link it with the orca module +clang %wasmFlags% -L . -lorca -o module.wasm src/main.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% + +:: 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/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.bat b/samples/fluid/build.bat index 338a853..1c22a58 100644 --- a/samples/fluid/build.bat +++ b/samples/fluid/build.bat @@ -15,7 +15,7 @@ if exist "..\..\scripts\sample_build_check.py" ( set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim -:: compile wasm module +:: common flags to build wasm modules set wasmFlags=--target=wasm32^ --no-standard-libraries ^ -mbulk-memory ^ @@ -27,6 +27,10 @@ set wasmFlags=--target=wasm32^ -I%ORCA_DIR%\src ^ -I%ORCA_DIR%\src\ext +:: build orca core as wasm module +clang %wasmFlags% -Wl,--relocatable -o .\liborca.a %ORCA_DIR%\src\orca.c %ORCA_DIR%\src\libc-shim\src\*.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% + set shaders=src/shaders/advect.glsl^ src/shaders/blit_div_fragment.glsl^ src/shaders/blit_div_vertex.glsl^ @@ -45,7 +49,9 @@ set shaders=src/shaders/advect.glsl^ call python ../../scripts/embed_text_files.py --prefix=glsl_ --output src/glsl_shaders.h %shaders% if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! -clang %wasmFlags% -o .\module.wasm %ORCA_DIR%\src\orca.c %STDLIB_DIR%\src\*.c src\main.c -if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! +:: build sample as wasm module and link it with the orca module +clang %wasmFlags% -L . -lorca -o .\module.wasm src\main.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% -orca bundle --orca-dir %ORCA_DIR% --name Fluid --icon icon.png module.wasm \ No newline at end of file +:: 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/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.bat b/samples/triangle/build.bat index 910e4c5..d5c07a9 100644 --- a/samples/triangle/build.bat +++ b/samples/triangle/build.bat @@ -15,7 +15,7 @@ if exist "..\..\scripts\sample_build_check.py" ( set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim -:: compile wasm module +:: common flags to build wasm modules set wasmFlags=--target=wasm32^ --no-standard-libraries ^ -mbulk-memory ^ @@ -27,7 +27,13 @@ set 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 -if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! +:: build orca core as wasm module +clang %wasmFlags% -Wl,--relocatable -o .\liborca.a %ORCA_DIR%\src\orca.c %ORCA_DIR%\src\libc-shim\src\*.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% -orca bundle --orca-dir %ORCA_DIR% --name Triangle module.wasm +:: build sample as wasm module and link it with the orca module +clang %wasmFlags% -L . -lorca -o module.wasm src/main.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% + +:: create app directory and copy files into it +orca bundle --orca-dir %ORCA_DIR% --name Triangle --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.bat b/samples/ui/build.bat index 4a7b1eb..cf64748 100644 --- a/samples/ui/build.bat +++ b/samples/ui/build.bat @@ -15,7 +15,7 @@ if exist "..\..\scripts\sample_build_check.py" ( set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim -:: compile wasm module +:: common flags to build wasm modules set wasmFlags=--target=wasm32^ --no-standard-libraries ^ -mbulk-memory ^ @@ -27,7 +27,13 @@ set 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 -if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! +:: build orca core as wasm module +clang %wasmFlags% -Wl,--relocatable -o .\liborca.a %ORCA_DIR%\src\orca.c %ORCA_DIR%\src\libc-shim\src\*.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +:: build sample as wasm module and link it with the orca module +clang %wasmFlags% -L . -lorca -o .\module.wasm src\main.c +IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% + +:: create app directory and copy files into it orca bundle --orca-dir %ORCA_DIR% --name UI --resource-dir data 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