Split compile_source function for readability

Split the `compile_source` function into `compile_source_android` and `compile_source_webasm` instead of using a parameter to switch between the functionality.
This commit is contained in:
Robert Müller 2024-05-11 18:08:05 +02:00
parent 45f619722b
commit 930836f349

View file

@ -15,8 +15,7 @@ fi
COMPILEFLAGS=$3
LINKFLAGS=$4
function compile_source() {
if [[ "${4}" == "android" ]]; then
function compile_source_android() {
cmake \
-H. \
-G "Unix Makefiles" \
@ -46,8 +45,10 @@ function compile_source() {
cd "$2" || exit 1
cmake --build .
)
else
${5} cmake \
}
function compile_source_webasm() {
emcmake cmake \
-H. \
-DCMAKE_BUILD_TYPE=Release \
-B"$2" \
@ -71,17 +72,16 @@ function compile_source() {
cd "$2" || exit 1
cmake --build .
)
fi
}
if [[ "${2}" == "android" ]]; then
compile_source "$1" build_"$2"_arm armeabi-v7a "$2" "" &
compile_source "$1" build_"$2"_arm64 arm64-v8a "$2" "" &
compile_source "$1" build_"$2"_x86 x86 "$2" "" &
compile_source "$1" build_"$2"_x86_64 x86_64 "$2" "" &
compile_source_android "$1" build_android_arm armeabi-v7a &
compile_source_android "$1" build_android_arm64 arm64-v8a &
compile_source_android "$1" build_android_x86 x86 &
compile_source_android "$1" build_android_x86_64 x86_64 &
elif [[ "${2}" == "webasm" ]]; then
sed -i "s/include(CheckSizes)//g" CMakeLists.txt
compile_source "$1" build_"$2"_wasm wasm "$2" emcmake &
compile_source_webasm "$1" build_webasm_wasm wasm &
fi
wait