Android compilation system (III)

Source: Internet
Author: User

++ ++

This article is original on this site. You are welcome to repost it! Reprinted please indicate the source:

Http://blog.csdn.net/mr_raptor/article/details/7540730

++ ++

 

Android compilation system (I): http://blog.csdn.net/mr_raptor/article/details/7539978

Android compilation system (2): http://blog.csdn.net/mr_raptor/article/details/7540066

Android compilation system (3): http://blog.csdn.net/mr_raptor/article/details/7540730

The previous two sections explain how to customize Android compilation items and create product configuration files. In addition to compiling and defining product-related environment variables, you also need to define board-related environment variables.

1. Build/CORE/config. mk

[Plain]
View plaincopy
  1. 109 #---------------------------------------------------------------
  2. 110 # define most of the global variables. These are the ones that
  3. 111 # are specific to the user's build configuration.
  4. 112 include $ (build_system)/envsetup. mk
  5. 113
  6. 114 # boards may be defined under $ (src_target_dir)/board/$ (target_device)
  7. 115 # Or under vendor/*/$ (target_device). Search in both places,
  8. 116 # Make sure only one exists.
  9. 117 # Real boards shoshould always be associated with an OEM vendor.
  10. 118 board_config_mk: = \
  11. 119 $ (Strip $ (wildcard \
  12. 120 $ (src_target_dir)/board/$ (target_device)/boardconfig. mk \
  13. 121 vendor/*/$ (target_device)/boardconfig. mk \
  14. 122 ))
  15. 123 ifeq ($ (board_config_mk ),)
  16. 124 $ (error no config file found for target_device $ (target_device ))
  17. 125 endif
  18. 126 ifneq ($ (words $ (board_config_mk), 1)
  19. 127 $ (error multiple board config files for target_device $ (target_device): $ (board_config_mk ))
  20. 128 endif
  21. 129 include $ (board_config_mk)
  22. 130 target_device_dir: = $ (patsubst %/, %, $ (DIR $ (board_config_mk )))
  23. 131 board_config_mk: =

The above code has been seen in the previous section, but it only analyzes the envsetup of Line 1. mk. According to the content in the previous section, envsetup. MK sets many out variables and sets target_device = fs100 In the build/CORE/product_config.mk file.

We continue the analysis from row 3.

  • From 114 ~ The explanations in line 3 are as follows:

The configuration files related to the Board will exist in the $ (src_target_dir)/board/$ (target_device)/or vendor/*/$ (target_device)/directory, one vendor can have only one corresponding board configuration file.

  • 118 rows, definedBoard_config_mkVariable:

$ (Wildcard XXX) is used to locate the matching item of XXX and put it in the space list. The target_device variable = fs100 is defined before, so $ (src_target_dir)/board/fs100/boardconfig. MK does not exist. It must exist in the vendor/*/fs1 00/boardconfig. MK file to define the development board configuration information.

  • Line 3: Include vendor/*/fs100/boardconfig. mk through include,
  • Row 3: target_device_dir is the path of board_config_mk, that is, vendor/*/fs100.

Summary:

A vendor must have a corresponding board configuration file, that is, vendor/*/fs100/boardconfig. mk.

Define the target_device_dir variable, which is the path of board_config_mk, that is, vendor/*/fs100.

Specify the relevant features of the board, which must include:
Target_cpu_abi: = armeabi /...
For other attributes, see other Board examples (build/target/board/xxx


2. Build/CORE/Main. mk

[Plain]
View plaincopy
  1. 141 # Bring in Standard build system definitions.
  2. 142 include $ (build_system)/definitions. mk
  3. ...
  4. 347 ifeq ($ (sdk_only), true)
  5. 348
  6. 349 # ----- SDK for Windows ------
  7. 350 # These configure the Build targets that are available for the SDK under cygwin.
  8. 351 # The first section defines all the C/C ++ tools that can be compiled under cygwin,
  9. 352 # The second section defines all the Java ones (assuming javac is available .)
  10. 353
  11. 354 subdirs: = \
  12. 355 prebuilt \
  13. 356 build/libs/host \
  14. 357 build/tools/zipalign \
  15. ...
  16. 382 # The following can only be built if "javac" is available.
  17. 383 # this check is used when building parts of the SDK under cygwin.
  18. 384 ifneq (, $ (shell which javac 2>/dev/null ))
  19. 385 $ (warning SDK-only: javac available .)
  20. 386 subdirs + = \
  21. 387 build/tools/signapk \
  22. 388 Dalvik/dx \
  23. 389 Dalvik/libcore \
  24. ...
  25. 414 else #! Sdk_only
  26. 415 ifeq ($ (build_tiny_android), true)
  27. 416
  28. 417 # tiny_android is a super-Minimal build configuration, handy for Board
  29. 418 # bringup and very low level debugging
  30. 419
  31. 420 subdirs: = \
  32. 421 bionic \
  33. 422 system/core \
  34. 423 build/libs \
  35. 424 build/target \
  36. ...
  37. 433 else #! Build_tiny_android
  38. 434
  39. 435 #
  40. 436 # typical build; include any android. mk files we can find.
  41. 437 #
  42. 438 subdirs: = $ (top)
  43. 439
  44. 440 full_build: = true
  45. 441
  46. 442 endif #! Build_tiny_android
  47. 443
  48. 444 endif #! Sdk_only
  49. ...
  50. 464 #
  51. 465 # include all of the makefiles IN THE SYSTEM
  52. 466 #
  53. 467
  54. 468 # Can't use first-makefiles-under here because
  55. 469 # -- mindepth = 2 makes the prunes not work.
  56. 470 subdir_makefiles: = \
  57. 471 $ (shell build/tools/findleaves. py -- prune = out -- prune =. Repo -- prune =. Git $ (subdirs) Android. mk)
  58. 472
  59. 473 include $ (subdir_makefiles)

In the previous section, we only talked about the main. mk 49th line containing config. mk. We will continue to analyze it.

Row 142 contains: build/CORE/definitions. mk. This file defines many global variables and functions.

See the following common functions:

My-Dir: returns the current path.

All-Java-files-under: obtain all java files in the specified directory and subdirectory.

All-subdir-C-Files: obtains all c files in the current directory and subdirectory.

354 ~ Row 3, definedSubdirsVariable, which contains different directories in the android source code based on different user compilation conditions.

Row 3, definedSubdir_makefileThe value is the Android. mk file in the directory defined by subdirs.

Line 3 contains all android. mk files in the compiled directory.


3. Build/target/board/Android. mk

[Plain]
View plaincopy
  1. 26 ifeq (, $ (wildcard $ (target_device_dir)/androidboard. mk ))
  2. 27 ifeq (, $ (wildcard $ (target_device_dir)/Android. mk ))
  3. 28 $ (error missing "$ (target_device_dir)/androidboard. mk ")
  4. 29 else
  5. 30 # todo: Remove this check after people have had a chance to switch,
  6. 31 # After creating l 2009.
  7. 32 $ (error Please rename "$ (target_device_dir)/Android. mk" to "$ (target_device_dir)/androidboard. mk ")
  8. 33 endif
  9. 34 endif
  10. 35 include $ (target_device_dir)/androidboard. mk

Because android. MK File Include, build/target/board/android. MK is naturally included. According to the previous analysis, target_device_dir = vendor/*/fs100, of which 26 ~ Line 35 is used to determine whether androdiboard. mk exists in the corresponding product directory. If not, an error is prompted to exit. If so, include it in the compilation script.

Therefore, we must create androdiboard under the product directory. MK file to describe the configuration items of the Development Board. For details, refer to build/target/board/generic/androidboard. MK content, and also create boardconfig according to the previous analysis. MK file.

[Plain]
View plaincopy
  1. $ CP build/target/board/generic/androidboard. mk build/target/board/generic/boardconfig. mk vendor/farsight/fs100/

At this point, the basic steps for custom Android compilation options have been analyzed by division, and the details need to be analyzed for different development boards.

Summary:

Build/CORE/Main. mk contains config. mk, which mainly defines the dependency between compiling all codes.

Build/CORE/config. mk defines a large number of compilation script commands, environment variables used during compilation, introduced the envsetup. mk file, and loaded the configuration files related to the Board.
Build/CORE/envsetup. mk defines a large number of out output directories used during compilation and loads the product_config.mk file.
Build/CORE/product_config.mk defines the parsing script for product-related configuration files under the vendor directory, and reads androdproducts. mk to generate the target_device variable.
Build/target/product config
Build/target/board config
Build/CORE/Combo build flags config

Here we will explain the board and product here. Borad is mainly designed for hardware chip configurations, such as whether to provide certain hardware functions, such as GPU, or whether the chip supports floating point operations. Product is a pointer to the current chip configuration. It defines the personalized configuration of the product to be produced. It mainly refers to the APK configuration and the product to which the APK will be included, which APK is not provided in the current product.
Config. MK is a general concept that defines the host tools required for module compilation and how to compile various modules. For example, built_prebuilt defines how to compile the pre-compilation module. Envsetup. mk mainly reads some variables written by envsetup. Sh to the environment variables to configure the output directory during the compilation process. Combo mainly defines the compiler and compilation options that combine host and target.

1. Create your own company directory under the vendor directory, create a new vendorsetup. Sh under the company directory, and add your own product compilation items to it.

[Plain]
View plaincopy
  1. $ Mkdir vendor/farsight/
  2. $ Touch vendor/farsight/vendorsetup. Sh
  3. $ Echo "add_lunch_combo fs100-eng"> vendor/farsight/vendorsetup. Sh

2. Create the products directory under the company directory like the android sample code

[Plain]
View plaincopy
  1. $ Mkdir-P vendor/farsight/products

3. Create two MK files under the products directory, similar to the android sample code.

[Plain]
View plaincopy
  1. $ Touch vendor/farsight/products/androidproduct. mk vendor/farsight/products/fs100.mk

Add the following content to androidproduct. mk:

[Plain]
View plaincopy
  1. Product_makefiles: = $ (local_dir)/fs100.mk

Add the most basic information to the Product Configuration File

[Plain]
View plaincopy
  1. $ (Call inherit-product, build/target/product/generic. mk)
  2. # Overrides
  3. Product_manufacturer: = farsight
  4. Product_name: = fs100
  5. Product_device: = fs100

4. Use build/target/board/generic/androidboard. mk and boardconfig. mk to create the corresponding file.

[Plain]
View plaincopy
  1. $ CP build/target/board/generic/androidboard. mk build/target/board/generic/boardconfig. mk vendor/farsight/fs100/

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.