Extends vab to support compiling V applications that use vlang/sdl.
vab-sdl can be used standalone or as an extra command
for vlang/vab.
Any issues about this extra command should be reported to this project,
not to the v or vab projects.
vab-sdl is pure V software that can download and compile SDL2 and SDL3 for Android from source
using only the Android NDK provided compilers (in parallel).
That means you do not need to use cmake, gradle or anything else in order to
compile and run V source code that does import sdl on Android. Because of this
build times is greatly improved in contrast to SDL's own solution that is
based on gradle and ndk-build.
- An application or example that import
vlang/sdl. - A working install of the
vabcommand-line tool (optionally) compiled with-d vab_allow_extra_commands.
To compile vab with the extra command feature you can build vab like in this example:
v -d vab_allow_extra_commands ~/.vmodules/vabMake sure you read the section about extending vab in vab's documentation.
To install and make this extra command available as "vab sdl" run the following:
vab install extra larpon/vab-sdl
vab doctor # Should show a section with installed extra commands where `vab-sdl` should show.To install as a standalone tool:
git clone https://github.com/larpon/vab-sdl.git
v ./vab-sdl && cd ./vab-sdl
./vab-sdl -h # or ./vab-sdl doctorOnce vab-sdl is installed you can test it with:
vab sdl ~/.vmodules/sdl/examples/tvintris -o /tmp/tvintris.apk... or if used as standalone tool:
./vab-sdl ~/.vmodules/sdl/examples/tvintris -o /tmp/tvintris.apkThe first time the above command is run it will download all needed SDL dependencies
(including SDL2_image, SDL2_mixer and/or SDL2_ttf) to a cache location
and then build each dependency specifically for Android without invoking anything
but the Android NDK compilers and tools. When it has built the dependencies it will
package the SDL based application into an APK package using a specially crafted VSDLActivity
that derive from the SDL source's own main activity (SDLActivity).
Since vab-sdl is basically just a modified reimplementation of vab's main
function vab.v it can mostly be called just like vab itself.
That means you can pass the same flags to vab-sdl as you can pass
to vab - this includes the run command for easy running and testing of apps.
Example:
vab sdl run ~/.vmodules/sdl/examples/tvintris- Currently
vab-sdlsupports SDL2 and SDL3 versions from2.0.14and up. The reason we do not support all SDL2 versions is because SDL2's own Android support was cumbersome and cryptic at the time the older versions was developed. It can surely be achieved but requires a lot of time and effort to get working. In reality this should not be a problem since SDL2 is backwards compatible. So source written for SDL2 versions <=2.0.12should compile and run just fine for Android with newer versions of SDL2. vab-sdldetermines what version of SDL to build based on the version branch checked out in~/.vmodules/sdl. Alternatively you can set the ENV varSDL_VERSIONor pass--sdl-versionwhen building.vab-sdlships it's own modules for building SDL from source.- As a convenience,
vab-sdlwraps most ofvab's existing functionality, if something is missing or broken please open an issue with this project. - The lib name of the
.sofile thatvab-sdlproduces is currently alwayslibmain.so. This behavior can be changed but is somewhat cumbersome since it requires modification of code in the Java Activity. - Run
vab sdl doctorto see the state of the tool. - Run
vab sdl -hfor an overview of how to invoke the tool.