Question

I have a native shared library (.so) in my app that I would like to run unit tests on. In particular, there are several functions in my .so that I would like directly call from my unit tests. However, I do not want these functions to be visible in the release version.

The way I'm currently planning to do this is to remove the -fvisibility=hidden compile option when building for debug (NDK_DEBUG=1). However, I can't seem to figure out how to do this from the Android.mk file.

Here is my current Android.mk (a little simplified):

TARGET_PLATFORM := android-8
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := nuke_launcher
LOCAL_SRC_FILES := red_button.c abort_sequence.c

ifdef NDK_DEBUG
    LOCAL_CFLAGS := -fvisibility=default  # <-- Doesn't work
endif

include $(BUILD_SHARED_LIBRARY)

Thanks!

Was it helpful?

Solution

default (visible) is on by default; you probably want to set LOCAL_CFLAGS += -fvisibility=hidden for non-debug build.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top