我正在为
Android构建一些硬件测试.我有一个Android.mk文件,它逐个构建这些可执行文件,每个文件使用一块makefile代码,如下所示:
##### shared #####
LOCAL_PATH := $(my-dir)
##### test_number_one #####
test_name := test_number_one
include $(CLEAR_VARS)
LOCAL_CFLAGS := $(commonCflags)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
LOCAL_MODULE_TAGS := optional eng
LOCAL_SHARED_LIBRARIES := some_library some_other_library
LOCAL_MODULE := $(test_name)
LOCAL_SRC_FILES := tests/$(test_name)/$(test_name).c
include $(BUILD_EXECUTABLE)
##### test_number_two #####
test_name := test_number_two
include $(CLEAR_VARS)
LOCAL_CFLAGS := $(commonCflags)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
LOCAL_MODULE_TAGS := optional eng
LOCAL_SHARED_LIBRARIES := some_library some_other_library
LOCAL_MODULE := $(test_name)
LOCAL_SRC_FILES := tests/$(test_name)/$(test_name).c
include $(BUILD_EXECUTABLE)
如您所见,大多数代码都是针对每个测试重复的(包括$(CLEAR_VARS)和include $(CLEAR_VARS)).我想简化这一点,以便我有一个测试名称列表和一段makefile代码,每个代码都被“调用”.我不在乎该代码是否必须拆分成另一个文件.这里有一些python-esque伪代码来演示我的目标:
##### shared #####
LOCAL_PATH := $(my-dir)
##### test_number_one #####
test_names := test_number_one test_numer_two
for each item in test_names:
include $(CLEAR_VARS)
LOCAL_CFLAGS := $(commonCflags)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
LOCAL_MODULE_TAGS := optional eng
LOCAL_SHARED_LIBRARIES := some_library some_other_library
LOCAL_MODULE := $(item)
LOCAL_SRC_FILES := tests/$(item)/$(item).c
include $(BUILD_EXECUTABLE)
这在Android.mk文件中是否可行?怎么做到呢?