简体   繁体   中英

building a prebuilt static library with ndk-build all

I have a problem with an ndk-build script that builds a static library.

The problem is that this script gets included by our application's larger build script, which gets called with ndk-build all

The build script for the static library looks like this:

# LoadBalancing-cpp

LOCAL_PATH := $(call my-dir)

all_static_libraries = common-cpp-static-prebuilt \
                       photon-cpp-static-prebuilt

lib_suffix := ${APP_OPTIM}_android_${APP_ABI}

lib_loadbalancing_cpp_static_name := loadbalancing-cpp-prebuilt-static_${lib_suffix}

include $(CLEAR_VARS)
LOCAL_MODULE            := loadbalancing-cpp-static-prebuilt
LOCAL_SRC_FILES         := lib$(lib_loadbalancing_cpp_static_name).a
LOCAL_STATIC_LIBRARIES  := $(all_static_libraries)
include $(PREBUILT_STATIC_LIBRARY)

$(call import-module,common-cpp-prebuilt)
$(call import-module,photon-cpp-prebuilt)

The problem is, building a static library requires the LOCAL_SRC_FILES to point to a single value (the path to the library), however when called with ndk-build all in this case, it will contain multiple values (since lib_suffix will point to all available architectures).

Is there a way to build this file using ndk-build all ?

You can use TARGET_ARCH variable which is managed by ndk-build:

lib_suffix := $(APP_OPTIM)_android_$(TARGET_ARCH)

... and so on.

Essentially, ndk-build will "call" your Android.mk file multiple times, each time setting the TARGET_ARCH variable differently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM