在 Eclipse 中更改构建配置时,有没有办法强制 Android NDK 重新构建特定库?
我正在使用 Android NDK 构建一个 Android 项目来构建 C++ 库。我正在使用带有 Sequoyah 插件的 Eclipse。一切都已设置并且运行良好。
但是,我遇到了构建配置的问题。您可以通过右键单击项目-> 属性来管理构建配置,然后转到 C/C++ 构建部分。这允许您创建大多数 C++ 库以某种方式依赖的传统调试和发布版本。
这是我的“调试”配置的示例:
V=1 NDK_DEBUG=1 NDK_APPLICATION_MK=config/debug/Application.mk
这些运行良好,除了当我在配置之间来回切换时,它不会触发我正在构建的库的重建。这对于像 Visual Studio 这样的东西来说是可以预期的,其中每个构建配置都转储到不同的目录,但在 Eclipse 中,所有内容都会转储到同一个目录。我被迫实际更改相关的源文件以触发重建。所以最终发生的事情是我最终在调试配置中运行(例如),但链接到在 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)