Samples: build orca core lib as a separate lib from the app #144

Merged
MartinFouilleul merged 2 commits from samples-build-corelib into main 2023-09-27 11:08:20 +00:00
11 changed files with 84 additions and 23 deletions

3
.gitignore vendored
View File

@ -14,6 +14,7 @@ build
*.wasm
*.app
*.dylib
*.a
Debug/*
@ -39,4 +40,4 @@ scripts/files
/ext
src/ext/angle
sketches/*/bin
sketches/*/bin

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
:: create app directory and copy files into it
orca bundle --orca-dir %ORCA_DIR% --name Fluid --icon icon.png module.wasm

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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