Convert from Make to Soong

Before the Android 7.0 release, Android used GNU Make exclusively to describe and execute its build rules. The Make build system is widely supported and used, but at Android's scale became slow, error prone, unscalable, and difficult to test. The Soong build system provides the flexibility required for Android builds. We're making significant changes to the Android build system, deprecating the Make (Android.mk) build system and replacing it with Soong (Android.bp).

For this reason, platform developers are expected to switch from Make and adopt Soong as soon as possible. Send questions to the Android Building Google Group to receive support.

What is Soong?

The Soong build system was introduced in Android 7.0 (Nougat) to replace Make. It leverages the Kati GNU Make clone tool and Ninja build system component to speed up builds of Android.

See the Android Make Build System description in the Android Open Source Project (AOSP) for general instructions and Build System Changes for Android.mk Writers to learn about modifications needed to adapt from Make to Soong. See the build-related entries in the glossary for definitions of key terms and the Soong Modules Reference for complete details.

Make and Soong comparison

Here is a comparison of Make configuration with Soong accomplishing the same in a Soong configuration (Blueprint or .bp) file.

Make example

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := libxmlrpc++
LOCAL_MODULE_HOST_OS := linux

LOCAL_RTTI_FLAG := -frtti
LOCAL_CPPFLAGS := -Wall -Werror -fexceptions
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/src

LOCAL_SRC_FILES := $(call \
     all-cpp-files-under,src)
include $(BUILD_SHARED_LIBRARY)

Soong example

cc_library_shared {
     name: "libxmlrpc++",

     rtti: true,
     cppflags: [
           "-Wall",
           "-Werror",
           "-fexceptions",
     ],
     export_include_dirs: ["src"],
     srcs: ["src/**/*.cpp"],

     target: {
           darwin: {
                enabled: false,
           },
     },
}

For test-specific Soong configuration examples, see Simple build configuration.

Basic conversion procedure

The conversion of an Android.mk file to an Android.bp file typically follows this general workflow using the androidmk helper tool. In general the following steps are followed in the conversion.

  1. Set up the terminal environment and build androidmk tool.

    androidmk is a command line tool that parses a Android.mk file and tries to output an analogous Android.bp file. It can convert most of the Android.mk files to Android.bp with few or no manual changes.

    cd <root-of-the-tree>
    source build/envsetup.sh
    lunch <lunch-target>
    m androidmk
    
  2. Build with the Android.mk: sh m <module-name>

  3. Run the androidmk conversion tool: sh androidmk <path-to-Android.mk>/Android.mk > <path-to-Android.bp>/Android.bp

  4. Manually edit the Android.bp file:

    • Address any warnings emitted by the androidmk tool.
    • Retain or add a copyright header. If adding a new one, use the current year.
  5. Remove the Android.mk file and build with the Android.bp file.

  6. Validate the conversion by comparing the built artifacts or running unit and functional tests.

  7. Save the changes and upload for review.

Refer to Android.bp file format for more information.