Introduction to android.bp file

Android.bp is a configuration file used to replace android.mk, which uses the blueprint framework to parse. Blueprint is a tool for generating and parsing android.bp. It is a part of Soong. Soong is a tool specially designed for Android compilation. Blueprint only parses the form of the file, while Soong explains the meaning of the content and finally converts it into a ninja file.

The definition of a module starts from the type of the module, which has different types. In the following example, "cc_binary", the module contains some properties in the format of "property name:

Property value ", where the name property must be specified and its property value must be globally unique.

cc_binary{

    name: "gzip",    srcs: ["src/test/minigzip.c"],    shared_libs: ["libz"],    stl: "none",}

The usage of the default module "cc_defaults" is as follows.

cc_defaults{

    name: "gzip_defaults",  shared_libs: ["libz"],}



cc_binary{

    name: "gzip",    defaults: ["gzip_defaults"],}

Variable assignment can be assigned by "=".

gzip_srcs = ["src/test/minigzip.c"],cc_binary {

  name: "gzip",    srcs: gzip_srcs,  stl: "none",}

注释包括单行注释//和多行注释/* */。

The following types are supported:

Bool(`true` or `false`)

Integers(`int`)

Strings(`"string"`)

Listsof strings (`["string1","string2"]`)

Maps(`{key1: "value1",key2: ["value2"]}`)

Invalid Sign

Bpfmt is a format control tool for BP files, including the indentation of four spaces, one line for each element when the list has multiple elements, one redundant comma for the last element of the list and map, and so on. The tool directory is: build / blueprint / bpfmt/

Execute the following command in the current directory:

Android MK tool can convert MK files into BP files, but some complex usage and custom rules need to be converted manually. The tool directory is: build / Soong / Android MK/

androidmkAndroid.mk>Android.bp

Android.bp can support Android_ app、cc_ binary、cc_ binary_ Host and other types, as shown in the figure below:

Android.bp can support five precompiled types, as shown in the following figure:

Soong provides that the same module name can be configured in different directories, as long as the name of each module is declared in a different command space.

soong_namespace{

    imports: ["path/to/otherNamespace1","path/to/otherNamespace2"],}

cc_library{

    ...

    srcs: ["generic.cpp"],    arch: {

        arm: {

            srcs: ["arm.cpp"],        },        x86: {

            srcs: ["x86.cpp"],    },}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>