Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does APP_OPTIM manifest in code?

Tags:

android-ndk

In Application.mk you can set:

APP_OPTIM := release
APP_OPTIM := debug

How can I test for release/debug build in C++?

I'm assuming there are defines so I've tried this, but only "NOT" messages are logged:

#ifdef RELEASE
    LOGV("RELEASE");
#else
    LOGV("NOT RELEASE");
#endif

#ifdef DEBUG
    LOGV("DEBUG");
#else
    LOGV("NOT DEBUG");
#endif
like image 547
weston Avatar asked Oct 27 '12 11:10

weston


People also ask

How does Android MK work?

The syntax of the Android.mk allows you to group your sources into modules. A module is either a static library, a shared library, or a standalone executable. You can define one or more modules in each Android.mk file, and you can use the same source file in multiple modules.

Where is Application mk?

The Application.mk specifies project-wide settings for ndk-build. By default, it is located at jni/Application.mk , in your application's project directory.

What is an ndk build?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android and provides platform libraries you can use to manage native activities.


1 Answers

In android-ndk-r8b/build/core/add-application.mk we read:

ifeq ($(APP_OPTIM),debug)
  APP_CFLAGS := -O0 -g $(APP_CFLAGS)
else
  APP_CFLAGS := -O2 -DNDEBUG -g $(APP_CFLAGS)
endif

So, to answer your question: in NDK r8b (the latest for today) you can check

#ifdef NDEBUG
// this is "release"
#else
// this is "debug"
#endif

But you can add any other compilation flags through your Android.mk or Application.mk depending on $(APP_OPTIM), if you want.

like image 185
Alex Cohn Avatar answered Oct 29 '22 14:10

Alex Cohn