Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between Android.bp and Android.mk

In Android O framework code, we see both Android.bp and Android.mk files. What is the need for both files? As per documentation .bp files are used for soong build system. When we do a build which file will be executed? .mk or .bp?

like image 897
MayureshG Avatar asked Sep 18 '18 10:09

MayureshG


People also ask

What is an Android BP file?

Android now uses the Soong build system for simpler test configuration. Soong uses Blueprint or . bp files, which are JSON-like simple declarative descriptions of modules to build. This format replaces the Make-based system used in previous releases.

How do I comment a BP file in Android?

Comments. Android. bp files can contain C-style multiline /* */ and C++ style single-line // comments.

What is Android build system?

The Android build system compiles app resources and source code, and packages them into APKs or Android App Bundles that you can test, deploy, sign, and distribute.


1 Answers

Soong is a build system for Android, intended as a replacement for the old make-based build system. Soong reads Android.bp files, which define modules in a Bazel-like syntax. Soong itself is written in Go on top of the Blueprint framework, which in turn uses Ninja as a back-end. Ninja is designed for high efficiency, especially for incremental builds.

Because Android is a large project, the move to Soong/Android.bp will take some time. During the transitionary period, both formats are supported, with Soong for Android.bp, and Kati for Android.mk. A standard build will run both. Modules in Android.mk files can depend on modules in Android.bp files, but not the other way.

An important difference of Android.bp is the absence of explicit if-statements to increase performance. Whereas Android.mk files can contain ifeq checks over arbitrary environment variables, the Android.bp format only allows to differentiate pre-defined cases such as processor architecture or debug/release builds (reference). Custom case distinctions have to be defined separately in Go (reference).

Because of the design differences, automatic conversion of Android.mk to Android.bp is not feasible, though there is a tool called androidmk that can translate simple Android.mk files (e.g. no if-statements) to Android.bp.

like image 125
f9c69e9781fa194211448473495534 Avatar answered Sep 25 '22 08:09

f9c69e9781fa194211448473495534