Setup scripts for building skia on Android, some fixes
diff --git a/renderer/library/build.sh b/renderer/library/build.sh
index b7c47f3..1d38da5 100755
--- a/renderer/library/build.sh
+++ b/renderer/library/build.sh
@@ -1,7 +1,7 @@
#!/bin/bash
-
+set -e
cd ../..
-./build.sh $@
+./build.sh "$@"
cd renderer/library
@@ -9,21 +9,17 @@
OPTION=$1
-if [ "$OPTION" = 'help' ]
-then
+if [ "$OPTION" = 'help' ]; then
echo build.sh - build debug library
echo build.sh clean - clean the build
- echo build.sh release - build release library
-elif [ "$OPTION" = "clean" ]
-then
+ echo build.sh release - build release library
+elif [ "$OPTION" = "clean" ]; then
echo Cleaning renderer_library project ...
premake5 clean
-elif [ "$OPTION" = "release" ]
-then
+elif [ "$OPTION" = "release" ]; then
premake5 --for-macos gmake && make config=release -j7
-elif [ "$OPTION" = "android" ]
-then
+elif [ "$OPTION" = "android" ]; then
premake5 --for-android gmake && make config=release -j7
else
premake5 --for-macos gmake && make -j7
-fi
\ No newline at end of file
+fi
diff --git a/renderer/library/build/premake5.lua b/renderer/library/build/premake5.lua
index f2391b2..1435471 100644
--- a/renderer/library/build/premake5.lua
+++ b/renderer/library/build/premake5.lua
@@ -27,17 +27,19 @@
optimize "On"
configuration "for-android"
- links {"rive"}
- defines {"RIVE_HAS_OPENGL", "ANDROID", "GL_SILENCE_DEPRECATION"}
- libdirs {"../../../build/bin/%{cfg.buildcfg}"}
+links {"rive"}
+defines {"RIVE_HAS_OPENGL", "ANDROID", "GL_SILENCE_DEPRECATION"}
+libdirs {"../../../build/bin/%{cfg.buildcfg}"}
configuration "for-macos"
- links {"Cocoa.framework", "rive"}
- defines {"RIVE_HAS_METAL", "RIVE_HAS_OPENGL"}
- defines {"GL_SILENCE_DEPRECATION"}
- includedirs {"../../dependencies/DiligentEngine_build/build/include"}
- files {"../src/**.mm"}
- libdirs {"../../../build/bin/%{cfg.buildcfg}", "../../dependencies/skia/out/Static"}
+links {"Cocoa.framework", "rive"}
+defines {"RIVE_HAS_METAL", "RIVE_HAS_OPENGL"}
+defines {"GL_SILENCE_DEPRECATION"}
+includedirs {"../../dependencies/DiligentEngine_build/build/include"}
+files {"../src/**.mm"}
+libdirs {
+ "../../../build/bin/%{cfg.buildcfg}", "../../dependencies/skia/out/Static"
+}
-- Clean Function --
newaction {
diff --git a/skia/dependencies/make_skia.sh b/skia/dependencies/make_skia.sh
index 6927c45..598d04e 100755
--- a/skia/dependencies/make_skia.sh
+++ b/skia/dependencies/make_skia.sh
@@ -19,7 +19,7 @@
git clone $SKIA_REPO
else
echo "Already have Skia, update it."
- cd skia && git checkout master && git fetch && git pull
+ cd skia && git checkout main && git fetch && git pull
cd ..
fi
diff --git a/skia/dependencies/make_skia_android.sh b/skia/dependencies/make_skia_android.sh
new file mode 100755
index 0000000..edffeb2
--- /dev/null
+++ b/skia/dependencies/make_skia_android.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+set -e
+
+# Requires depot_tools and git:
+# https://skia.org/user/download
+# Build notes:
+# https://skia.org/user/build
+
+SKIA_REPO=https://github.com/google/skia
+# New Skia version is compatible with Android NDK > v19
+SKIA_STABLE_BRANCH=chrome/m95
+
+# -----------------------------
+# Get & Build Skia
+# -----------------------------
+if [ ! -d skia ]; then
+ echo "Cloning Skia stable branch."
+ # TODO:(umberto) --depth 1
+ git clone -b $SKIA_STABLE_BRANCH $SKIA_REPO
+fi
+
+cd skia
+
+python tools/git-sync-deps
+
+# TODO: Pass these as arguments.
+# ARCH=x86
+ARCH=x64
+# ARCH=arm
+# ARCH=arm64
+
+# Useful for debugging the build process.
+# bin/gn args --list out/${ARCH}
+bin/gn gen out/${ARCH} --args=" \
+ ndk=\"${NDK_PATH}\" \
+ target_cpu=\"${ARCH}\" \
+ is_official_build=false \
+ skia_use_egl=true \
+ skia_use_gl=true \
+ skia_gl_standard=\"gles\" \
+ "
+ninja -C out/${ARCH}
+cd ..
diff --git a/skia/viewer/build.sh b/skia/viewer/build.sh
index e0d0eb5..b247535 100755
--- a/skia/viewer/build.sh
+++ b/skia/viewer/build.sh
@@ -6,6 +6,7 @@
# ./build.sh $@
# cd $dir
+set -e
cd build
@@ -24,3 +25,5 @@
else
premake5 gmake && make -j7
fi
+
+set +e
\ No newline at end of file
diff --git a/skia/viewer/build/premake5.lua b/skia/viewer/build/premake5.lua
index 028e186..17e3869 100644
--- a/skia/viewer/build/premake5.lua
+++ b/skia/viewer/build/premake5.lua
@@ -15,21 +15,35 @@
cppdialect "C++17"
targetdir "bin/%{cfg.buildcfg}"
objdir "obj/%{cfg.buildcfg}"
-includedirs {"../include", "../../../include", "../../renderer/include", "../../dependencies/glfw/include",
- "../../dependencies/skia", "../../dependencies/skia/include/core",
- "../../dependencies/skia/include/effects", "../../dependencies/skia/include/gpu",
- "../../dependencies/skia/include/config", "../../dependencies/imgui", "../../dependencies",
- "../../dependencies/gl3w/build/include"}
+includedirs {
+ "../include", "../../../include", "../../renderer/include",
+ "../../dependencies/glfw/include", "../../dependencies/skia",
+ "../../dependencies/skia/include/core",
+ "../../dependencies/skia/include/effects",
+ "../../dependencies/skia/include/gpu",
+ "../../dependencies/skia/include/config", "../../dependencies/imgui",
+ "../../dependencies", "../../dependencies/gl3w/build/include"
+}
-links {"Cocoa.framework", "IOKit.framework", "CoreVideo.framework", "rive", "skia", "rive_skia_renderer", "glfw3"}
-libdirs {"../../../build/bin/%{cfg.buildcfg}", "../../dependencies/glfw_build/src",
- "../../dependencies/skia/out/Static", "../../renderer/build/bin/%{cfg.buildcfg}"}
+links {
+ "Cocoa.framework", "IOKit.framework", "CoreVideo.framework", "rive", "skia",
+ "rive_skia_renderer", "glfw3"
+}
+libdirs {
+ "../../../build/bin/%{cfg.buildcfg}", "../../dependencies/glfw_build/src",
+ "../../dependencies/skia/out/Static",
+ "../../renderer/build/bin/%{cfg.buildcfg}"
+}
-files {"../src/**.cpp", "../../dependencies/gl3w/build/src/gl3w.c",
- "../../dependencies/imgui/backends/imgui_impl_glfw.cpp",
- "../../dependencies/imgui/backends/imgui_impl_opengl3.cpp", "../../dependencies/imgui/imgui_widgets.cpp",
- "../../dependencies/imgui/imgui.cpp", "../../dependencies/imgui/imgui_tables.cpp",
- "../../dependencies/imgui/imgui_draw.cpp"}
+files {
+ "../src/**.cpp", "../../dependencies/gl3w/build/src/gl3w.c",
+ "../../dependencies/imgui/backends/imgui_impl_glfw.cpp",
+ "../../dependencies/imgui/backends/imgui_impl_opengl3.cpp",
+ "../../dependencies/imgui/imgui_widgets.cpp",
+ "../../dependencies/imgui/imgui.cpp",
+ "../../dependencies/imgui/imgui_tables.cpp",
+ "../../dependencies/imgui/imgui_draw.cpp"
+}
buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti"}