Android(AOSP)7:先于其他模块构建模块/作为构建过程的一部分修补模块/修改系统源 [英] Android (AOSP) 7: Build module before other / Patch module as part of build process / Modify system sources

查看:97
本文介绍了Android(AOSP)7:先于其他模块构建模块/作为构建过程的一部分修补模块/修改系统源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑使用Android.mk文件构建AOSP 7:

Considering the AOSP 7 build with Android.mk files:

如何在不同的LOCAL_MODULE之间添加内置时间依赖关系,特别是在构建特定模块之前构建目标?我想在编译系统模块之前运行补丁应用目标.

How can I add built-time dependency between different LOCAL_MODULE, specifically build a target BEFORE an certain MODULE is built? I want to run a patch apply target, before the a system module is compiled.

我的目标是在构建的过程中修补WifiStateMachine.java,因为它当前不支持动态禁用RSSI轮询.

My goal is to patch the WifiStateMachine.java from within the built process, because it currently does not support to dynamically disable RSSI polling.

推荐答案

TL; DR:复制要修补的模块的Android.mk并添加修补规则作为源代码的前提条件被补丁作为目标.然后使用LOCAL_OVERRIDES_MODULE:=...使修补的模块覆盖旧模块.确保将新模块的名称添加到您的PRODUCT_PACKAGES中,否则覆盖无效.

TL;DR: copy the Android.mk of the module you want to patch and add a patching rule as prerequisite for the source being targetet by the patch. Then use LOCAL_OVERRIDES_MODULE:=... to make your patched module override the old one. Make sure to add the name of the new module to your PRODUCT_PACKAGES, otherwise the overriding does not work.

确保在构建目标之前已对其进行修补的唯一方法是,仅对目标进行修补的唯一方法是从wifi-service模块的frameworks/opt/net/wifi/service/Android.mk复制代码,并使我自己的Android.mk覆盖旧的代码. 原始的Android.mk看起来像这样.

The only way to make sure my target is patched before being built and patched only one was to copy the code from frameworks/opt/net/wifi/service/Android.mk of the wifi-service module and make my own Android.mk overriding the old one. The original Android.mk looks like this.

# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH := $(call my-dir)

ifneq ($(TARGET_BUILD_PDK), true)

...

# Build the java code
# ============================================================

include $(CLEAR_VARS)

LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/java
LOCAL_SRC_FILES := $(call all-java-files-under, java) \
    $(call all-Iaidl-files-under, java) \
    $(call all-logtags-files-under, java) \
    $(call all-proto-files-under, proto)

ifndef INCLUDE_NAN_FEATURE
LOCAL_SRC_FILES := $(filter-out $(call all-java-files-under, \
          java/com/android/server/wifi/nan),$(LOCAL_SRC_FILES))
endif

LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt services
LOCAL_REQUIRED_MODULES := services
LOCAL_MODULE_TAGS :=
LOCAL_MODULE := wifi-service
LOCAL_PROTOC_OPTIMIZE_TYPE := nano

ifeq ($(EMMA_INSTRUMENT_FRAMEWORK),true)
LOCAL_EMMA_INSTRUMENT := true
endif

LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.server.wifi.*

include $(BUILD_JAVA_LIBRARY)

endif

我在vendor/<target>中添加了一个新目录,包括wifi状态机的修补程序和以下Android.mk.要打补丁的源在标记文件上具有先决条件,该文件是使用patch apply命令构建的.在此图章文件中,我在补丁之前添加模块的提交哈希.在干净的步骤中使用此哈希将模块正确重置为原始的HEAD提交.由于Android.mk的不同位置,我必须更改的唯一变量是protoc的参数.

I added a new directory in my vendor/<target>, including the patch for the wifi state machine and the following Android.mk. The source being patched has a prerequisite on a stamp file, which is being built using the patch apply command. In this stamp file i add the commit hash of the module before the patch. This hash is used in the clean steps to properly reset the module to the original HEAD commit. The only variable I had to change because of the different location of the Android.mk is the arguments of protoc.

# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

THIS_LOCAL_PATH := $(realpath $(call my-dir))
LOCAL_PATH := $(ANDROID_BUILD_TOP)/frameworks/opt/net/wifi/service

# Partwise taken from frameworks/opt/net/wifi/service/Android.mk
# ============================================================

ifneq ($(TARGET_BUILD_PDK), true)

include $(CLEAR_VARS)

PATCHED_STAMP_FILE := $(ANDROID_HOST_OUT)/.wsm_patched.stamp
TO_BE_PATCHED_DIR := $(ANDROID_BUILD_TOP)/frameworks/opt/net/wifi
CHECK_IF_PATCHED_FILE := $(LOCAL_PATH)/java/com/android/server/wifi/WifiStateMachine.java
PREVIOUS_HASH := $(shell grep -hs ^ $(PATCHED_STAMP_FILE))

LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/java
LOCAL_SRC_FILES := $(call all-java-files-under, java) \
    $(call all-Iaidl-files-under, java) \
    $(call all-logtags-files-under, java) \
    $(call all-proto-files-under, proto) \
    $(PATCHED_STAMP_FILE)

$(PATCHED_STAMP_FILE): $(CHECK_IF_PATCHED_FILE)

$(CHECK_IF_PATCHED_FILE):
    git -C $(TO_BE_PATCHED_DIR) rev-parse HEAD > $(PATCHED_STAMP_FILE)
    git -C $(TO_BE_PATCHED_DIR) am $(THIS_LOCAL_PATH)/wifiStateMachine.patch

ifndef INCLUDE_NAN_FEATURE
LOCAL_SRC_FILES := $(filter-out $(call all-java-files-under, \
    java/com/android/server/wifi/nan),$(LOCAL_SRC_FILES))
endif

ifdef PREVIOUS_HASH
$(call add-clean-step, git -C $(TO_BE_PATCHED_DIR) reset --hard $(PREVIOUS_HASH))
$(call add-clean-step, rm $(PATCHED_STAMP_FILE))
endif

LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt services
LOCAL_REQUIRED_MODULES := services
LOCAL_MODULE_TAGS :=
LOCAL_MODULE := wifi-service-anbox
LOCAL_OVERRIDES_MODULE := wifi-service
LOCAL_PROTOC_OPTIMIZE_TYPE := nano

# Protoc uses proto_path=., but wifi.proto is not here
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)

ifeq ($(EMMA_INSTRUMENT_FRAMEWORK),true)
LOCAL_EMMA_INSTRUMENT := true
endif

LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.server.wifi.*

include $(BUILD_JAVA_LIBRARY)

endif

这篇关于Android(AOSP)7:先于其他模块构建模块/作为构建过程的一部分修补模块/修改系统源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆