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}
|
|
|
|
clang -c -g -Wno-extern-initializer -Dd_m3VerboseErrorMessages -o ./bin/obj/$name -I./ext/wasm3/source $file
|
|
|
|
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/
|
|
|
|
|
|
|
|
INCLUDES="-Imilepost/src -Imilepost/src/util -Imilepost/src/platform -Iext/wasm3/source -Imilepost/ext/"
|
|
|
|
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 \
|
|
|
|
--guest-stubs sdk/graphics.c \
|
|
|
|
--guest-include graphics.h \
|
|
|
|
--wasm3-bindings ./src/canvas_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
|