源码编译之Android.mk和Android.bp

简介

Android.mk和Android.bp都是差不多的。Android.bp是google在android N之后新的编译配置文件。

源码在:build/soong/androidmk
我们在out下面找下androidmk工具,如果没有可以执行命令:m -j blueprint_tools
然后在在out/soong/host/linux-x86/bin/androidmk生成工具

./androidmk  Android.mk > android.bp

基本使用

@/build/soong/androidmk/cmd/androidmk/android.go

相互转换的定义在:
/build/soong/androidmk/cmd/androidmk/android.go
func init() {
	addStandardProperties(bpparser.StringType,
		map[string]string{
			"LOCAL_MODULE":                  "name",
			"LOCAL_CXX_STL":                 "stl",
			"LOCAL_STRIP_MODULE":            "strip",
			"LOCAL_MULTILIB":                "compile_multilib",
			"LOCAL_ARM_MODE_HACK":           "instruction_set",
			"LOCAL_SDK_VERSION":             "sdk_version",
			"LOCAL_NDK_STL_VARIANT":         "stl",
			"LOCAL_JAR_MANIFEST":            "manifest",
			"LOCAL_JARJAR_RULES":            "jarjar_rules",
			"LOCAL_CERTIFICATE":             "certificate",
			"LOCAL_PACKAGE_NAME":            "name",
			"LOCAL_MODULE_RELATIVE_PATH":    "relative_install_path",
			"LOCAL_PROTOC_OPTIMIZE_TYPE":    "proto.type",
			"LOCAL_MODULE_OWNER":            "owner",
			"LOCAL_RENDERSCRIPT_TARGET_API": "renderscript.target_api",
			"LOCAL_NOTICE_FILE":             "notice",
			"LOCAL_JAVA_LANGUAGE_VERSION":   "java_version",
			"LOCAL_INSTRUMENTATION_FOR":     "instrumentation_for",
			"LOCAL_MANIFEST_FILE":           "manifest",

			"LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING": "dex_preopt.profile",
		})

 

-------------------原始Android.mk----packages/apps/Gallery2------------------
LOCAL_PACKAGE_NAME := Gallery2
include $(BUILD_PACKAGE)

-------------------转化后的android.bp------------------
android_app {           //android_app表示编译为app 对应 include $(BUILD_PACKAGE)
    name: "Gallery2",       //name对应  LOCAL_PACKAGE_NAME := Gallery2

 

 

你可能感兴趣的:(Android)