2023-04-12 14:21:03 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
target="$1"
|
|
|
|
|
|
|
|
if [ -z $target ] ; then
|
|
|
|
target='orca'
|
|
|
|
fi
|
|
|
|
target=$(echo $target | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
|
|
|
if [ ! \( -e bin \) ] ; then
|
|
|
|
mkdir ./bin
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! \( -e resources \) ] ; then
|
|
|
|
mkdir ./resources
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ $target = milepost ] ; then
|
|
|
|
echo "building milepost"
|
|
|
|
pushd milepost > /dev/null
|
|
|
|
./build.sh lib "$2"
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
elif [ $target = wasm3 ] ; then
|
|
|
|
|
|
|
|
echo "building wasm3"
|
|
|
|
mkdir ./bin/obj
|
|
|
|
for file in ./ext/wasm3/source/*.c ; do
|
|
|
|
name=$(basename $file)
|
|
|
|
name=${name/.c/.o}
|
2023-05-09 16:44:23 +00:00
|
|
|
clang -c -g -foptimize-sibling-calls -Wno-extern-initializer -Dd_m3VerboseErrorMessages -o ./bin/obj/$name -I./ext/wasm3/source $file
|
2023-04-12 14:21:03 +00:00
|
|
|
done
|
|
|
|
ar -rcs ./bin/libwasm3.a ./bin/obj/*.o
|
|
|
|
rm -rf ./bin/obj
|
|
|
|
|
|
|
|
elif [ $target = orca ] ; then
|
|
|
|
echo "building orca"
|
|
|
|
|
2023-04-14 09:48:36 +00:00
|
|
|
# copy libraries
|
2023-04-12 14:21:03 +00:00
|
|
|
cp milepost/bin/mtl_renderer.metallib bin/
|
|
|
|
cp milepost/bin/libmilepost.dylib bin/
|
|
|
|
cp milepost/bin/libGLESv2.dylib bin/
|
|
|
|
cp milepost/bin/libEGL.dylib bin/
|
|
|
|
|
2023-05-09 16:44:23 +00:00
|
|
|
INCLUDES="-Isrc -Isdk -Imilepost/src -Imilepost/src/util -Imilepost/src/platform -Iext/wasm3/source -Imilepost/ext/"
|
2023-04-12 14:21:03 +00:00
|
|
|
LIBS="-Lbin -lmilepost -lwasm3"
|
|
|
|
FLAGS="-g -DLOG_COMPILE_DEBUG -mmacos-version-min=10.15.4 -maes"
|
|
|
|
|
|
|
|
# generate wasm3 api bindings
|
|
|
|
./scripts/bindgen.py core ./src
|
|
|
|
./scripts/bindgen.py gles ./src
|
|
|
|
|
2023-04-17 08:56:38 +00:00
|
|
|
python3 ./scripts/bindgen2.py canvas \
|
2023-04-14 09:48:36 +00:00
|
|
|
src/canvas_api.json \
|
2023-04-26 12:57:12 +00:00
|
|
|
--guest-stubs sdk/orca_surface.c \
|
2023-04-14 09:48:36 +00:00
|
|
|
--guest-include graphics.h \
|
|
|
|
--wasm3-bindings ./src/canvas_api_bind_gen.c
|
|
|
|
|
2023-05-09 16:44:23 +00:00
|
|
|
python3 ./scripts/bindgen2.py io \
|
|
|
|
src/io_api.json \
|
|
|
|
--guest-stubs sdk/io_stubs.c \
|
|
|
|
--wasm3-bindings ./src/io_api_bind_gen.c
|
|
|
|
|
2023-04-12 14:21:03 +00:00
|
|
|
# compile orca
|
|
|
|
clang $FLAGS $INCLUDES $LIBS -o bin/orca src/main.c
|
|
|
|
|
|
|
|
# fix libs imports
|
|
|
|
install_name_tool -change "./bin/libmilepost.dylib" "@rpath/libmilepost.dylib" bin/orca
|
|
|
|
install_name_tool -add_rpath "@executable_path/" bin/orca
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "unknown build target $target"
|
|
|
|
fi
|