Skip to content

AliOS Things build system

librae8226 edited this page Mar 1, 2018 · 2 revisions

EN | 中文

AliOS Things build system

build components

Generally speaking, the construction of a project contains following elements:

img

Component-based thought

The so-called component-based thought means that all functional modules can be tailored and spliced at will. The realization of this idea is mainly dependent on the construction of system, where each component has its corresponding .mk file.

Because of the idea of component-based management, in order to isolate each component and configure each of them independently, a .mk file is placed in each component's directory to store its specific operation configuration, and association among components is defined through dependency relationship. The unified operating mechanism shared among all components of the system is placed in the .mk file under the build directory. In this way, isolation of components and flexibility of modification can be achieved at the same time.

Overall process

There are three steps in the overall construction process:

img

In short, all the information required in the elements mentioned above except tool chain is included in, for example config.mk, xx.c_opts and link.opts in the second steps, and the core of the construction is the generation and usage of these files.

More details are shown as followed:

img

Content of mk file

A module's mk file basically describes how the component is build, so it's very important. In the following text, examples will be given to illustrate its main content:

img

In this list, the global is the settings used in compilation of all components, while the local is used only in compilation of a specific component. A mk file describes the configuration information of a component. All the configuration settings can be specified in _CFLAGS and _LDFLAGS, including link scripts used in links.

Detailed implementation process

In the following part, detailed implementation process and corresponding key code will be illustrated according to the elements mentioned above:

Choose tool chain

img

The host platform is set in aos.py, while the auxiliary command tools are set in aos_host_cmd.mk, which currently mainly support two host platforms, windows and linux64.

img

The setting of compilation tool chain is set in aos_target_xx.mk and aos_library_xx.mk.

Find source file

img

The compilation order is always the name of app @ the name of board. App and board are two entry components that the search process is relied on.

The dependency search is mainly implemented through recursion:

img

In fact, in addition to the source file, the search process will also find out information about the defined compilation options in mk file. The process is actually parsing the mk file of the component through recursion. It makes preparation for the later compilation and link steps.

Generate config.mk

Store the information getting from the above recursion parsing about mk file in config.mk:

img

Config.mk is actually the collection of information in mk file of all the components, while opts file is an independent file that reorganizes information in mk file based on each component.

Compile

compilation order

img

img

img

compilation option of each component is generated.

img

Link

Link order

img

link option is generated.

img

img

Binary and other processing

Unified binary processing, such as strip.

img

Execute self-defined operations for each component.

img

img

summary of key macro call relationship

FIND_COMPONENT --Find all the required component parameters: all basic components, recursive calls.

PREPROCESS_TEST_COMPONENT  -- Add the components needed for tests with no parameter.

PROCESS_COMPONENT -- Parse the mk file of each component, parameters: all components.

PROCESS_ONE_COMPONENT  -- Parse a component, parameter: a specific component.

WRITE_FILE_CREATE -- Write all the relevant information in config.mk and write compilation and link options in opts file.

Clone this wiki locally