这次进行模块移植的过程中,遇到了一种情况,那就是,当我们有些模块我们需要整块的移植到新的项目下。但是,新的项目下,本来就有这个模块,我们好需要保留这个模块,只不过是,这个项目可以根据我们的需求,选择行编译其中的一个模块。具体的方法就是,我们在这个项目下,创建一个我们自己的文件夹,然后把我们的模块放进来。接下来的工作就是如何选择性编译了。当时的方法就是通过宏控控制。具体操作如下
1.在自己需要移植的模块编译文件中(Android.mk),加入宏判断,如下【目录 vanzo/packages/SoundRecord】
ifeq ($(strip $(VANZO_FEATURE_OOS_SOUNDRECORDER)), yes)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
#LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := com.mediatek.soundrecorder.ext
# for mediatek sdk MediaRecorderEx and StorageManagerEx
LOCAL_JAVA_LIBRARIES += mediatek-framework
LOCAL_PACKAGE_NAME := SoundRecorder
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
2.在原本模块的Android.mk文件中,加入宏判断,这个当然是跟欲移植模块是互斥的 【目录 packages/apps/SoundRecord】
ifeq ($(strip $(VANZO_FEATURE_OOS_SOUNDRECORDER)), no)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
#LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := com.mediatek.soundrecorder.ext
# for mediatek sdk MediaRecorderEx and StorageManagerEx
LOCAL_JAVA_LIBRARIES += mediatek-framework
LOCAL_PACKAGE_NAME := SoundRecorder
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
说白了,也就是在之前的编译下,加了一个条件判断
ifeq(hong)
bianyi
endif
3.最后,别忘了添加这个宏,在env_common.ini文件中【zprojects/common】
VANZO_FEATURE_OOS_FMRADIO=no
# Vanzo:wangjianhua VANZO_FEATURE_OOS_FILEMANAGER start
# Description:是否启用OOS风格的Filemanager
# Category:Filemanager
# end
VANZO_FEATURE_OOS_FILEMANAGER=no
# Vanzo:wangjianhua VANZO_FEATURE_OOS_CALENDAR start
# Description:是否启用OOS风格的Calendar
# Category:Calendar
# end
VANZO_FEATURE_OOS_CALENDAR=no
# Vanzo:zhangshuli VANZO_FEATURE_OOS_SOUNDRECORDER start
# Description:是否启用OOS风格的SoundRecorder
# Category:SoundRecorder
# end
VANZO_FEATURE_OOS_SOUNDRECORDER=no