NDK build with different mk file for release/debug
Asked Answered
L

1

6

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?

Lycia answered 5/1, 2014 at 9:5 Comment(0)
C
9

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
...
Crystie answered 5/1, 2014 at 10:30 Comment(2)
The photon.mk doesn't include anything, that's the problem. I added the include directive.Lycia
You can also lean on the ndk, by checking ifeq ($(APP_OPTIM),debug). APP_OPTIM is normally set or chosen in Application.mk, see https://mcmap.net/q/769821/-android-ndk-release-build.Crystie

© 2022 - 2024 — McMap. All rights reserved.