Android Source compile-time copy replaces specified file

Source: Internet
Author: User

Due to the version customization, some versions of the resource files (such as style.xml) need different configuration, but the android compiler switch can not be used in XML, and then think of compile-time according to the different compilation switches to compile different files, as follows:

1. Build the A.xml file and compile the file to the specified directory when the compile switch oem_customer_support=22.

Build the B.xml file, and copy the file to the specified directory when the compile switch oem_customer_support not equal to 22 o'clock.

2. Write the copy script file mydefine.sh, as follows:

#!/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. Add the Copy script file mydefine.sh to the system compilation 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 isn't work.

$ (Shell chmod 777 packages/apps/peephole/config/peepholestyle.sh)
$ (Shell packages/apps/peephole/config/peepholestyle.sh)

......

The bold part is the new content, the first sentence is to make the SH script has read and write execution permission, the second sentence is the real execution

Android Source compile-time copy replaces specified file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.