A simple crossplatform SDL2 + skia CMake build environment example/test. Based on simpleSDL (thank you so much!).
Tested to build and run successfully with:
- Linux (Ubuntu): Clang
- Android: Gradle + NDK
- Windows: mingw-w64 or Visual Studio 2015
Table of contents:
WIP
WIP
WIP
The standard skia build does not have CMake compatibility so we will transform the build. Learn more about the skia build.
Step-by-step:
-
Run
python2 tools/git-sync-deps
insideexternals
; -
Generate CMake project:
bin/gn gen out/cmake --ide=json --json-ide-script=../../gn/gn_to_cmake.py --args='is_official_build=true'
to build skia as a static library or
bin/gn gen out/cmake --ide=json --json-ide-script=../../gn/gn_to_cmake.py --args='is_official_build=true is_component_build=true'
to build skia as a dynamic library. To see all available arguments:
bin/gn args out/cmake --list
suggestion for Android build:
bin/gn gen out/cmake --ide=json --json-ide-script=../../gn/gn_to_cmake.py --args=' skia_use_system_libjpeg_turbo = false skia_use_system_libwebp = false skia_use_system_expat = false skia_use_system_libpng = false skia_use_system_freetype2 = false ndk="/home/you/Android/Sdk/ndk/21.3.6528147" target_os="android" target_cpu="arm" is_debug=false is_component_build=true extra_cflags=["-O3"] skia_use_angle = false skia_use_icu = false skia_use_lua = false skia_use_opencl = false skia_use_piex = false skia_use_zlib = false skia_enable_tools = false skia_enable_pdf = false skia_use_gl = true skia_enable_skottie = false '
WIP
Just run build.sh
inside platforms
folder.
or
Alternatively you can do something like this in the project root dir:
mkdir build/make_debug
cd build/make_debug
cmake -DCMAKE_BUILD_TYPE:STRING=Debug ../..
make
Make sure you have NDK and CMake plugins installed on Android SDK (https://developer.android.com/studio/projects/add-native-code.html).
Step-by-step:
-
Make sure you have installed:
- Android SDK Build Tools 30;
- NDK 21;
- Android CMake 10.
-
Have the
ANDROID_HOME
environment variable; -
Copy all content from
externals/SDL/android-project/app/src/main/java/org/libsdl/app
and put it into
platforms/android/android-app/src/main/java/org/libsdl/app/
-
Pay attention to the skia build and see if all the arguments are in the
arg.gn
file. See build options here. -
Run
gradlew assemble
inplatforms/android
or
Open the project in Android Studio and build using the IDE. NOTE: Make sure to open the
platforms/android/
dir. Android studio can also open the root dir but it's not recognized as an android project.
The included Android Gradle CMake project is pretty much what Android Studio generates when you create a new empty app with native CMake support. Just pointing to the CMakeLists.txt in the project root.
WIP
WIP