Search code examples
androidandroid-ndkndk-build

NDK build with different mk file for release/debug


We have a setup where our Android game contains a few native libraries that get built using ndk-build.

Our project contains the following structure:

Root
 |
 |-- jni
      |
      |-- Android.mk   // $include ( lib.mk ) and ( photon/photon.mk)
      |-- lib.mk
      |-- photon
            |
            |----- photon.mk
            |----- debug_android_armeabi.mk
            |----- release_android_armeabi.mk

One of the libs that get built (Photon) comes with 2 additional makefiles besides its main one - one for debug and one for release.

My question is - how can i pass this info to ndk-build such that the correct additional mk file will be picked up when building?


Solution

  • Probably, your photon.mk looks like

    ...
    ifdef DEBUG
      include debug_android_armeabi.mk
    else
      include release_android_armeabi.mk
    endif
    ...
    

    This way you can simply use

    ndk-build DEBUG=1
    

    If you want to lean on the ndk official features for release/debug build, you may prefer

    ...
    ifeq ($(APP_OPTIM),debug)
      include debug_android_armeabi.mk
    else
      include release_android_armeabi.mk
    endif
    ...