[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-04-04。"],[],[],null,["# Convert from Make to Soong\n\nBefore the Android 7.0 release, Android used\n[GNU Make](https://www.gnu.org/software/make/)\nexclusively to describe and execute its build rules. The Make build system is\nwidely supported and used, but at Android's scale became slow, error prone,\nunscalable, and difficult to test. The\nSoong build system\nprovides the flexibility required for Android builds.\n| **Caution:** Bazel isn't a supported build system. The planned multi-year migration from Soong to Bazel was halted in October of 2023. You can continue to use Bazel to [build kernels](/docs/setup/build/building-kernels#building), but you should use Soong for full AOSP builds.\n\nFor this reason, platform developers are expected to switch from Make and adopt\nSoong as soon as possible. Send questions to the\n[android-building](https://groups.google.com/g/android-building)\nGoogle Group to receive support.\n\nWhat is Soong?\n--------------\n\nThe Soong build system was introduced in Android 7.0 (Nougat) to replace Make.\nIt leverages the\n[Kati](https://github.com/google/kati/blob/master/README.md) GNU\nMake clone tool and [Ninja](https://ninja-build.org/) build system\ncomponent to speed up builds of Android.\n\nSee the\n[Android Make Build System](https://android.googlesource.com/platform/build/+/android16-release/README.md)\ndescription in the Android Open Source Project (AOSP) for general\n[instructions](https://android.googlesource.com/platform/build/+/android16-release/Usage.txt)\nand\n[Build System Changes for Android.mk Writers](https://android.googlesource.com/platform/build/+/android16-release/Changes.md)\nto learn about modifications needed to adapt from Make to Soong.\n\nSee the [build-related entries](/docs/setup/start/glossary#build) in the\nglossary for definitions of key terms and the\n[Soong reference files](https://ci.android.com/builds/latest/branches/aosp-build-tools/targets/linux/view/soong_build.html) for complete details.\n| **Caution:** Until Android fully converts from Make to Soong, the Make product configuration must specify the `PRODUCT_SOONG_NAMESPACES` value. See the [Namespace modules](#namespace_modules) section for instructions.\n\nMake and Soong comparison\n-------------------------\n\nHere is a comparison of Make configuration with Soong accomplishing the same in\na Soong configuration (Blueprint or `.bp`) file.\n\n### Make example\n\n LOCAL_PATH := $(call my-dir)\n\n include $(CLEAR_VARS)\n LOCAL_MODULE := libxmlrpc++\n LOCAL_MODULE_HOST_OS := linux\n\n LOCAL_RTTI_FLAG := -frtti\n LOCAL_CPPFLAGS := -Wall -Werror -fexceptions\n LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/src\n\n LOCAL_SRC_FILES := $(call \\\n all-cpp-files-under,src)\n include $(BUILD_SHARED_LIBRARY)\n\n### Soong example\n\n cc_library_shared {\n name: \"libxmlrpc++\",\n\n rtti: true,\n cppflags: [\n \"-Wall\",\n \"-Werror\",\n \"-fexceptions\",\n ],\n export_include_dirs: [\"src\"],\n srcs: [\"src/**/*.cpp\"],\n\n target: {\n darwin: {\n enabled: false,\n },\n },\n }\n\nFor test-specific Soong configuration examples, see\n[Simple Build Configuration](/docs/core/tests/development/blueprints).\n\nFor an explanation of the fields in an Android.bp file, refer to\n[Android.bp file format](/docs/setup/reference/androidbp).\n\nSpecial modules\n---------------\n\nSome special module groups have unique characteristics.\n\n### Defaults modules\n\nA defaults module can be used to repeat the same properties in multiple modules.\nFor example: \n\n cc_defaults {\n name: \"gzip_defaults\",\n shared_libs: [\"libz\"],\n stl: \"none\",\n }\n\n cc_binary {\n name: \"gzip\",\n defaults: [\"gzip_defaults\"],\n srcs: [\"src/test/minigzip.c\"],\n }\n\n### Prebuilt modules\n\nSome prebuilt module types allow a module to have the same name as its\nsource-based counterparts. For example, there can be a `cc_prebuilt_binary`\nnamed `foo` when there's already a `cc_binary` with the same name. This gives\ndevelopers the flexibility to choose which version to include in their final\nproduct. If a build configuration contains both versions, the `prefer` flag\nvalue in the prebuilt module definition dictates which version has priority.\nNote that some prebuilt modules have names that don't start with `prebuilt`,\nsuch as `android_app_import`.\n\n### Namespace modules\n\nUntil Android fully converts from Make to Soong, the Make product configuration\nmust specify a `PRODUCT_SOONG_NAMESPACES` value. Its\nvalue should be a space-separated list of namespaces that Soong exports to Make\nto be built by the `m` command. After Android's conversion to Soong is complete,\nthe details of enabling namespaces could change.\n\nSoong provides the ability for modules in different directories to specify the\nsame name, as long as each module is declared within a separate namespace. A\nnamespace can be declared like this: \n\n soong_namespace {\n imports: [\"path/to/otherNamespace1\", \"path/to/otherNamespace2\"],\n }\n\nNote that a namespace doesn't have a name property; its path is automatically\nassigned as its name.\n\nEach Soong module is assigned a namespace based on its location in the tree.\nEach Soong module is considered to be in the namespace defined by the\n`soong_namespace` found in an `Android.bp` file in the current directory or\nclosest ancestor directory. If no such `soong_namespace` module is found, the\nmodule is considered to be in the implicit root namespace.\n\nHere's an example: Soong attempts to resolve dependency D declared by module M\nin namespace N that imports namespaces I1, I2, I3...\n\n1. Then if D is a fully qualified name of the form `//namespace:module`, only the specified namespace is searched for the specified module name.\n2. Otherwise, Soong first looks for a module named D declared in namespace N.\n3. If that module doesn't exist, Soong looks for a module named D in namespaces I1, I2, I3...\n4. Lastly, Soong looks in the root namespace."]]