floooh / sokol-zig

Zig bindings for the sokol headers (https://github.com/floooh/sokol)
zlib License
341 stars 46 forks source link

[Request] samples on Android #34

Closed 20kano closed 1 year ago

20kano commented 1 year ago

It would be helpful to have an example of Zig + Sokol running on Android.

floooh commented 1 year ago

That's a bit tricky. In C with CMake I have created a lot of build system magic to build an Android APK without Gradle. I guess this would need to be replicated in the Zig build system and it wouldn't be standalone but require an installed Android SDK (for the extra tools required for bundling and signing the APK file).

Googling around a bit it looks like this project solves that issue: https://github.com/MasterQ32/ZigAndroidTemplate, but it's a bit much to include in the sokol-zig repo. Might make sense to create a separate repository... or hopefully once Zig gets its package manager it might be possible to put this stuff into a helper package...

20kano commented 1 year ago

In C with CMake I have created a lot of build system magic to build an Android APK without Gradle.

Thanks. I've tried your https://github.com/floooh/sokol-samples#to-build-for-android and tried to find out how to do it, but due to my unfamiliarity with compiling C, I could not find which file to refer to. Could you please tell me which file to refer to?

floooh commented 1 year ago

The interesting stuff actually is all in Python scripts...

E.g. the automated Android SDK and NDK installation is here,

https://github.com/floooh/fips/blob/master/mod/android.py

Creating and signing the Android-APK is here:

https://github.com/floooh/fips/blob/master/tools/android-create-apk.py

...that last script is integrated into cmake as a custom post-build-step here:

https://github.com/floooh/fips/blob/ab2c3bef9ad3ab79efd816f22e2a151bb51714e7/cmake/fips_platform.cmake#L189-L203