While working with jme3-android-naitve module, i found multiple sub-modules (or source directories if you will) with a headers folder generated automatically using (compileargs+= -h)…okay what’s wrong with this ?
Redundancy and unfamiliarity of build scripts, it complicates simple stuff, for instance when i did implemented the feature NativeBufferAllocator
it took me days to understand the building.
├── build.gradle
├── decode.gradle
├── openalsoft.gradle
├── src
│ └── native
│ ├── headers
│ │ ├── com_jme3_audio_android_AndroidALC.h
│ │ ├── com_jme3_audio_android_AndroidAL.h
│ │ ├── com_jme3_audio_android_AndroidEFX.h
│ │ ├── com_jme3_audio_plugins_NativeVorbisFile.h
│ │ ├── com_jme3_texture_plugins_AndroidNativeImageLoader.h
│ │ └── com_jme3_util_AndroidNativeBufferAllocator.h
│ ├── jme_bufferallocator
│ │ ├── Android.mk
│ │ ├── Application.mk
│ │ └── com_jme3_util_AndroidNativeBufferAllocator.c
│ ├── jme_decode
│ │ ├── Android.mk
│ │ ├── Application.mk
│ │ ├── com_jme3_audio_plugins_NativeVorbisFile.c
│ │ └── com_jme3_texture_plugins_AndroidNativeImageLoader.c
│ └── jme_openalsoft
│ ├── Android.mk
│ ├── Application.mk
│ ├── com_jme3_audio_android_AndroidAL.c
│ ├── com_jme3_audio_android_AndroidALC.c
│ ├── com_jme3_audio_android_AndroidEFX.c
│ ├── config.h
│ ├── util.h
│ └── version.h
as you can see Android.mk
, Application.mk
and build.gradle
are repeated across all sources (and they have redundant code inside as well).
How to make it better ?
Migrate to the classic native style under src/main/native
:
-
include
dir for all headers. -
lib
dir for all sources. - Unifying
Android.mk
,Application.mk
andgradle script
. - Merge all android native object files into one single file
libandroidjme.so
(this will add some changes to the static initializers of jme3-android module).
By doing so, it will be easy to add new features on android natives (without even touching the build script or understanding it) and we will avoid build up of non-sense redundant build scripts over time when new features are added to the module.
These changes might take a lot of time to do, let me know your opinion even if you haven’t touched an android code before, but has worked before on native code.
EDIT :
we might able to use folders too under src/main/native/lib
and ``src/main/native/include`, so :
-
src/main/native/include/decode/...
,src/main/native/lib/decode/...
-
src/main/native/include/openalsoft/...
,src/main/native/lib/openalsoft/...
-
src/main/native/include/bufferallocator/...
,src/main/native/lib/bufferallocator/...
Much cleaner, isn’t it ?