build scripts support android platform subfolders
diff --git a/.gitignore b/.gitignore
index c61f2be..e685e1a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,6 +64,9 @@
skia/dependencies/FFmpeg
skia/dependencies/x264
skia/renderer/build/bin
+skia/renderer/build/obj
+skia/renderer/build/macosx
+skia/renderer/build/android
skia/**/build/bin
/skia/dependencies/glfw
/skia/dependencies/gl3w
@@ -74,3 +77,4 @@
/skia/viewer/build/macosx
/skia/thumbnail_generator/build/macosx
/build/macosx
+/build/android
diff --git a/build.sh b/build.sh
index 890b113..633c507 100755
--- a/build.sh
+++ b/build.sh
@@ -1,69 +1,78 @@
#!/bin/bash
-
set -e
pushd build &>/dev/null
-while getopts p: flag
-do
+while getopts p: flag; do
case "${flag}" in
- p)
- shift 2
- platform=${OPTARG}
- ;;
+ p)
+ shift 2
+ platform=${OPTARG}
+ ;;
+ \?) help ;;
esac
done
-# make sure argument is lowercase
-OPTION="$(echo $1 | tr '[A-Z]' '[a-z]')"
-
-if [ "$OPTION" = 'help' ]
-then
+help() {
echo build.sh - build debug library
echo build.sh clean - clean the build
- echo build.sh release - build release library
- echo build.sh -p ios release - build release ios library
- echo build.sh -p android release - build release android library
- exit
+ echo build.sh release - build release library
+ echo build.sh -p ios release - build release ios library
+ echo build.sh -p android release - build release android library
+ exit 1
+}
+
+# make sure argument is lowercase
+OPTION="$(echo "$1" | tr '[A-Z]' '[a-z]')"
+
+if [ "$OPTION" = 'help' ]; then
+ help
else
build() {
echo "Building Rive for platform=$platform option=$OPTION"
+ echo premake5 gmake2 "$1"
PREMAKE="premake5 gmake2 $1"
- eval $PREMAKE
- if [ "$OPTION" = "clean" ]
- then
+ eval "$PREMAKE"
+ if [ "$OPTION" = "clean" ]; then
make clean
make clean config=release
- elif [ "$OPTION" = "release" ]
- then
+ elif [ "$OPTION" = "release" ]; then
make config=release -j7
else
make -j7
fi
}
- case $platform in
- ios)
- echo "Building for iOS"
- export IOS_SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path)
- build "--os=ios"
- export IOS_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
- build "--os=ios --variant=emulator"
- if [ "$OPTION" = "clean" ]
- then
- exit
- elif [ "$OPTION" = "release" ]
- then
- config="release"
- else
- config="debug"
- fi
+ case $platform in
+ ios)
+ echo "Building for iOS"
+ export IOS_SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path)
+ build "--os=ios"
+ export IOS_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
+ build "--os=ios --variant=emulator"
+ if [ "$OPTION" = "clean" ]; then
+ exit
+ elif [ "$OPTION" = "release" ]; then
+ config="release"
+ else
+ config="debug"
+ fi
+ xcrun -sdk iphoneos lipo -create -arch x86_64 ios_sim/bin/$config/librive.a ios/bin/$config/librive.a -output ios/bin/$config/librive_fat.a
+ # print all the available architectures
+ lipo -info ios/bin/$config/librive_fat.a
;;
- android)
- build "--os=android"
+ # Android supports ABIs via a custom platform format:
+ # e.g. 'android.x86', 'android.x64', etc.
+ android*)
+ echo "Building for ${platform}"
+ # Extract ABI from this opt by splitting on '.' character
+ # e.g. android.x86
+ IFS="." read -ra strarr <<<"$platform"
+ ARCH=${strarr[1]}
+ build "--os=android --arch=${ARCH}"
;;
- *)
- build
+ *)
+ build
;;
esac
fi
diff --git a/build/premake5.lua b/build/premake5.lua
index 097eb39..c724b92 100644
--- a/build/premake5.lua
+++ b/build/premake5.lua
@@ -30,6 +30,23 @@
targetdir "%{cfg.system}_sim/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}_sim/obj/%{cfg.buildcfg}"
+ -- Is there a way to pass 'arch' as a variable here?
+ filter { "system:android", "options:arch=x86" }
+ targetdir "%{cfg.system}/x86/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/x86/obj/%{cfg.buildcfg}"
+
+ filter { "system:android", "options:arch=x64" }
+ targetdir "%{cfg.system}/x64/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/x64/obj/%{cfg.buildcfg}"
+
+ filter { "system:android", "options:arch=arm" }
+ targetdir "%{cfg.system}/arm/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/arm/obj/%{cfg.buildcfg}"
+
+ filter { "system:android", "options:arch=arm64" }
+ targetdir "%{cfg.system}/arm64/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/arm64/obj/%{cfg.buildcfg}"
+
filter "configurations:debug"
defines {"DEBUG"}
symbols "On"
@@ -48,4 +65,17 @@
{ "emulator", "Builds for an emulator/simulator for the provided system" }
},
default = "system"
+}
+
+newoption {
+ trigger = "arch",
+ value = "ABI",
+ description = "The ABI with the right toolchain for this build, generally with Android",
+ allowed = {
+ { "x86" },
+ { "x64" },
+ { "arm" },
+ { "arm64" }
+ }
+
}
\ No newline at end of file
diff --git a/skia/renderer/build.sh b/skia/renderer/build.sh
index 76718b6..f50f126 100755
--- a/skia/renderer/build.sh
+++ b/skia/renderer/build.sh
@@ -3,76 +3,83 @@
# build main rive
cd ../..
-./build.sh $@
+./build.sh "$@"
# build skia renderer
cd skia/renderer
pushd build &>/dev/null
-
-while getopts p: flag
-do
+while getopts p: flag; do
case "${flag}" in
- p)
- shift 2
- platform=${OPTARG}
- ;;
+ p)
+ shift 2
+ platform=${OPTARG}
+ ;;
+
+ \?) help ;;
esac
done
# make sure argument is lowercase
-OPTION="$(echo $1 | tr '[A-Z]' '[a-z]')"
+OPTION="$(echo "$1" | tr '[A-Z]' '[a-z]')"
-if [ "$OPTION" = 'help' ]
-then
+help() {
echo build.sh - build debug library
echo build.sh clean - clean the build
- echo build.sh release - build release library
- echo build.sh -p ios release - build release ios library
- echo build.sh -p android release - build release android library
- exit
+ echo build.sh release - build release library
+ echo build.sh -p ios release - build release ios library
+ echo build.sh -p android release - build release android library
+ exit 1
+}
+
+if [ "$OPTION" = 'help' ]; then
+ help
else
build() {
echo "Building Skia Renderer for $platform option=$OPTION"
PREMAKE="premake5 gmake2 $1"
- eval $PREMAKE
- if [ "$OPTION" = "clean" ]
- then
+ eval "$PREMAKE"
+ if [ "$OPTION" = "clean" ]; then
make clean
make clean config=release
- elif [ "$OPTION" = "release" ]
- then
+ elif [ "$OPTION" = "release" ]; then
make config=release -j7
else
make -j7
fi
}
- case $platform in
- ios)
- echo "Building for iOS"
- export IOS_SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path)
- build "--os=ios"
- export IOS_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
- build "--os=ios --variant=emulator"
- if [ "$OPTION" = "clean" ]
- then
- exit
- elif [ "$OPTION" = "release" ]
- then
- config="release"
- else
- config="debug"
- fi
+ case $platform in
+ ios)
+ echo "Building for iOS"
+ export IOS_SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path)
+ build "--os=ios"
+ export IOS_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
+ build "--os=ios --variant=emulator"
+ if [ "$OPTION" = "clean" ]; then
+ exit
+ elif [ "$OPTION" = "release" ]; then
+ config="release"
+ else
+ config="debug"
+ fi
+ xcrun -sdk iphoneos lipo -create -arch x86_64 ios_sim/bin/$config/librive_skia_renderer.a ios/bin/$config/librive_skia_renderer.a -output ios/bin/$config/librive_skia_renderer_fat.a
+ # print all the available architectures
+ lipo -info ios/bin/$config/librive_skia_renderer_fat.a
;;
- android)
-
- build "--os=android"
+ # Android supports ABIs via a custom platform format:
+ # e.g. 'android.x86', 'android.x64', etc.
+ android*)
+ echo "Building for ${platform}"
+ # Extract ABI from this opt by splitting on '.' character
+ IFS="." read -ra strarr <<<"$platform"
+ ARCH=${strarr[1]}
+ build "--os=android --arch=${ARCH}"
;;
- *)
- build
+ *)
+ build
;;
esac
fi
diff --git a/skia/renderer/build/premake5.lua b/skia/renderer/build/premake5.lua
index 381ef0e..8d99447 100644
--- a/skia/renderer/build/premake5.lua
+++ b/skia/renderer/build/premake5.lua
@@ -37,6 +37,24 @@
buildoptions {"-mios-version-min=10.0 -arch x86_64 -arch arm64 -isysroot " .. (os.getenv("IOS_SYSROOT") or "")}
targetdir "%{cfg.system}_sim/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}_sim/obj/%{cfg.buildcfg}"
+
+ -- Is there a way to pass 'arch' as a variable here?
+ filter { "system:android", "options:arch=x86" }
+ targetdir "%{cfg.system}/x86/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/x86/obj/%{cfg.buildcfg}"
+
+ filter { "system:android", "options:arch=x64" }
+ targetdir "%{cfg.system}/x64/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/x64/obj/%{cfg.buildcfg}"
+
+ filter { "system:android", "options:arch=arm" }
+ targetdir "%{cfg.system}/arm/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/arm/obj/%{cfg.buildcfg}"
+
+ filter { "system:android", "options:arch=arm64" }
+ targetdir "%{cfg.system}/arm64/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/arm64/obj/%{cfg.buildcfg}"
+
filter "configurations:debug"
defines {"DEBUG"}
@@ -55,4 +73,17 @@
{ "emulator", "Builds for an emulator/simulator for the provided system" }
},
default = "system"
+}
+
+newoption {
+ trigger = "arch",
+ value = "ABI",
+ description = "The ABI with the right toolchain for this build, generally with Android",
+ allowed = {
+ { "x86" },
+ { "x64" },
+ { "arm" },
+ { "arm64" }
+ }
+
}
\ No newline at end of file