• android源码编译时拷贝替换指定文件


    由于要做版本定制,某些版本的资源文件等(例如style.xml)需要不同的配置,但是android的编译开关无法在xml里使用,于是想到了编译时根据不同的编译开关编译不同的文件,如下:

    1.建立A.xml文件,当编译开关OEM_CUSTOMER_SUPPORT=22时编译将该文件拷贝到指定目录。

    建立B.xml文件,当编译开关OEM_CUSTOMER_SUPPORT不等于22时,将该文件拷贝到指定目录。

    2.编写拷贝脚本文件myDefine.sh,内容为:

    #!/bin/bash
    #
    if [ $OEM_CUSTOMER_SUPPORT -eq 22 ] ; then
    cp packages/apps/xxx/config/A.xml packages/apps/xxx/res/values/styles.xml
    else
    cp packages/apps/xxx/config/B.xml packages/apps/xxx/res/values/styles.xml
    fi

    3.将拷贝脚本文件myDefine.sh加入到系统编译build/core/main.mk

    ......

    # A helper goal printing out install paths
    .PHONY: GET-INSTALL-PATH
    GET-INSTALL-PATH:
    @$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED),
    echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';))

    else # ONE_SHOT_MAKEFILE

    ifneq ($(dont_bother),true)
    #
    # Include all of the makefiles in the system
    #

    # Can't use first-makefiles-under here because
    # --mindepth=2 makes the prunes not work.

    $(shell chmod 777 packages/apps/PeepHole/config/PeepHoleStyle.sh)
    $(shell packages/apps/PeepHole/config/PeepHoleStyle.sh)

    ......

    粗体部分为新加内容,第一句是使得sh脚本有读写执行的权限,第二句是真正的执行

  • 相关阅读:
    敏捷的调试
    敏捷的编码
    敏捷的需求分析
    敏捷的反馈
    敏捷的方法论
    敏捷的世界观
    MarkDown添加数学公式
    性能分析初学者指南
    可执行文件的装载与进程
    会话技术------客户端技术cookie
  • 原文地址:https://www.cnblogs.com/suxiaoqi/p/7299643.html
Copyright © 2020-2023  润新知