有沒有辦法在Eclipse中更改構建配置時強制Android NDK重建特定庫?Android NDK - 配置更改時強制庫重建
我正在構建一個使用Android NDK構建C++庫的Android項目。我使用Eclipse與Sequoyah插件。一切都建立並運作良好。
但是,我遇到了構建配置的問題。您可以通過右鍵單擊項目 - >屬性來管理構建配置,然後轉到C/C++構建部分。這允許您以某種方式創建大多數C++庫所依賴的傳統調試和發佈版本。
這裏是我的「調試」配置的例子:
V=1 NDK_DEBUG=1 NDK_APPLICATION_MK=config/debug/Application.mk
這些工作得很好,只是當我再次打開和配置之間來回,它不會觸發重建我建立了圖書館。對於像Visual Studio這樣的東西,每個構建配置都會轉儲到不同的目錄,但是在Eclipse中,所有東西都會被轉儲到同一個目錄。我被迫實際改變相關的源文件來觸發重建。所以最終發生的是我最終在Debug配置中運行(例如),但鏈接到在Release中構建的庫。
所以我的問題是:有沒有辦法在更改配置時強制NDK重建庫?我知道我可以添加-B命令,但重建的一切,每次。我可以重建每一次,如果我可以只爲一個特定的庫(在本例中爲libBootInfo)。
這裏是我的根Android.mk文件看起來像:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game$(MY_BUILD_CONFIG_EXTENSION)
# Include files are relative to the NDK root directly (fix by prepending with $(LOCAL_PATH))
# Source files are relative $(LOCAL_PATH)
#LOCAL_LDLIBS := -landroid
# Add all source file names to be included in lib separated by a whitespace
LOCAL_SRC_FILES := ../../../../../../engine/code/main/mainandroid.cpp
# Module dependencies are expressed with LOCAL_STATIC_LIBRARIES and LOCAL_SHARED_LIBRARIES.
# we're building the "main" entry point, so it doesn't depend on much
LOCAL_STATIC_LIBRARIES := libDebug$(MY_BUILD_CONFIG_EXTENSION) libCore$(MY_BUILD_CONFIG_EXTENSION)
include $(BUILD_SHARED_LIBRARY)
$(call import-module,libBdCore)
$(call import-module,libDebug)
##################################################################
## In addition to the core game library, we also build another
## *.so file here: "libBootInfo". This very small library is used
## by Java to find out which version of game to load based on
## the current build configuration.
##
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libBootInfo
# Add all source file names to be included in lib separated by a whitespace
# TODO: This path is relative to "android-ndk\build\core" which seems
# different from the LOCAL_SRC_FILES in game above. It seems like
# the build process leaves us in a different directory than we started.
# We make need to look into a way to make sure that this path always
# works regardless of what came before it.
#
LOCAL_SRC_FILES := ../../../../engine/code/main/bootinfo.cpp
include $(BUILD_SHARED_LIBRARY)
在您的'Android.mk'文件中,構建** libBootInfo **的部分不應該重新計算'LOCAL_PATH:= $(call my-dir)'。這是因爲'$(call my-dir)'實際上在此語句之前包含最後一個_make file_的路徑。如果你將所有的** libBootInfo **部分移動到你的'Android.mk'的頂部,它將會順利運行。 –
另外,其他評論也不正確:_「包含文件直接相對於NDK根目錄」_。實際上,包含文件'LOCAL_C_INCLUDES'是相對於_current目錄_通常是項目根目錄。 –