0

我有一个如下所示的 C 文件,它内置于 2 个可执行文件 test0 和 test1 中。但是,foo.c 不是为 test1 构建的,尽管当我使用“mm”时它具有不同的标志,并且“mm -B”是可以的。这是一个错误吗?

foo.c #ifdef TEST1 ... #else ... #endif

makefile 是这样的。安卓.mk

LOCAL_PATH := $(call my-dir)
##### build for test 0 ####
include $(CLEAR_VARS)
LOCAL_SRC_FILES := foo.c
LOCAL_MODULE := test0
    ...
include $(BUILD_EXECUTABLE)

##### build for test 1 ####
include $(CLEAR_VARS)
LOCAL_SRC_FILES := foo.c
LOCAL_MODULE := test1
LOCAL_CFLAGS := TEST1
    ...
include $(BUILD_EXECUTABLE)
##### end of Android.mk ##########
4

1 回答 1

0

You need to define TEST in the LOCAL_CFLAGS using -D. This is standard compile ( gcc ) behaviour, The build for test 1 fragment should look like this

##### build for test 1 ####
include $(CLEAR_VARS)
LOCAL_SRC_FILES := foo.c
LOCAL_MODULE := test1
LOCAL_CFLAGS := -DTEST1
...
include $(BUILD_EXECUTABLE)

Touching the file is not required as Android compiles the object files to an intermediate directory found in the out directory tree, so in this case they will be named as follows

out/target/product/[PRODUCT_DEVICE]/obj/EXECUTABLES/test0_intermediates out/target/product/[PRODUCT_DEVICE]/obj/EXECUTABLES/test1_intermediates

于 2013-10-07T05:46:05.020 回答