12

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?

MayureshG
  • 354
  • 2
  • 5
  • 14

1 Answers1

19

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.

  • Any good resources to help one easily determine the alternative dependencies that are equivalently supported by Android.bp? For example, I am trying to add the libVLC lib to my project when migrating to bp from mk. I cant get the exact architecture so I feel like for bp there might have been an alternative library (or typecase). – Naman Jain Oct 06 '21 at 13:21