2

I'm trying to understand the Android.mk better. I'm using a library to build a project right now and my Android.mk looks like this:

LOCAL_PATH := $(call my-dir)
SUPERPOWERED_PATH := ../../../../superpowered/Superpowered

include $(CLEAR_VARS)
LOCAL_MODULE := Superpowered
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_SRC_FILES := $(SUPERPOWERED_PATH)/libSuperpoweredARM.a
else
    ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
        LOCAL_SRC_FILES := $(SUPERPOWERED_PATH)/libSuperpoweredARM64.a
    else
        LOCAL_SRC_FILES := $(SUPERPOWERED_PATH)/libSuperpoweredX86.a
    endif
endif
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)  
LOCAL_MODULE := SuperpoweredExample  

LOCAL_SRC_FILES := \
    SuperpoweredExample.cpp \
    $(SUPERPOWERED_PATH)/SuperpoweredAndroidAudioIO.cpp
LOCAL_C_INCLUDES += $(SUPERPOWERED_PATH)

LOCAL_LDLIBS := -llog -landroid -lOpenSLES 
LOCAL_STATIC_LIBRARIES := Superpowered
LOCAL_CFLAGS = -O3
include $(BUILD_SHARED_LIBRARY)

My question is about the include $(CLEAR_VARS) line between include $(PREBUILT_STATIC_LIBRARY) and LOCAL_MODULE := SuperpoweredExample

From reading http://android.mk My understanding of CLEAR_VARS is that is clears all of the LOCAL_ variables on the execution space for MAKE parsing. So how am I able to point at the Superpowered module later in the file. It seems to me like this should no longer be possible.

My thinking is that the MAKE parser does its parsing, and then maintains some "Module" space after each module is declared and parsed, which is separate from the actual parsing space. Thats a complete guess though, and I've had some difficulty finding a resource that covers whats happening in the background.

Nathaniel D. Waggoner
  • 2,856
  • 2
  • 19
  • 41

2 Answers2

1

The current directory is not changed for the whole lifecycle of ndk-build, even when there are many modules, embedded Android.mk files, etc. That's why $(SUPERPOWERED_PATH) will stay relevant for all modules (it won't be so if it uses $(LOCAL_PATH) or other *make* variables).

The role of CLEAR_VARS is to reset all make variables that are listed in the variable modules-LOCALS. Here is an example how this behavior can be customized.

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
0

SUPERPOWERED_PATH set a current path of you jni folder path in that line and also in

particular format

C:/Users/Text/Desktop/TimeStreach/app/src/main/jni