Android.mk转Android.bp及介绍

一、Android.mk转成Android.bp是可以通过工具转换的

工具的路径为:ASOP/out/soong/host/linux-x86/bin/androidmk

直接把你要转换的Android.mk 文件放置到此目录下,然后执行命令:

./androidmk Android.mk > Android.bp

二、编译不同类型模块的写法

1、编译成 Java 库

Android.mk
include $(BUILD_JAVA_LIBRARY)

Android.bp
java_library {

......

}

2 编译成 Java 静态库

Android.mk
include $(BUILD_STATIC_JAVA_LIBRARY)

Android.bp
java_library_static {
......
}

3 编译成 App 应用

Android.mk
include $(BUILD_PACKAGE)

Android.bp
android_app {
......
}

4、 编译成 Native 动态库

Android.mk
include $(BUILD_SHARED_LIBRARY)

Android.bp
cc_library_shared {
......
}

5 编译成 Native 静态库

Android.mk
include $(BUILD_STATIC_LIBRARY)

Android.bp
cc_library_static {
......
}

6、编译成 Native 执行程序

Android.mk
include $(BUILD_EXECUTABLE)

Android.bp
cc_binary {
......
}

7、编译成头文件库

Android.mk
include $(BUILD_HEADER_LIBRARY)

Android.bp
cc_library_headers {
......
}

8、添加本地头文件路径

Android.mk
LOCAL_C_INCLUDES :=

Android.bp
local_include_dirs: ["xxx", ...]

9、导出的头文件路径

Android.mk
LOCAL_EXPORT_C_INCLUDE_DIRS :=

Android.bp
export_include_dirs: ["xxx", ...]

10、设置资源文件路径

Android.mk
LOCAL_RESOURCE_DIR :=

Android.bp
resource_dirs: ["xxx", ...]

11、添加依赖的静态库

Android.mk
LOCAL_STATIC_LIBRARIES :=

Android.bp
static_libs: ["xxx", "xxx", ...]

12、添加依赖的动态库

Android.mk
LOCAL_SHARED_LIBRARIES :=

Android.bp
shared_libs: ["xxx", "xxx", ...]

13、添加依赖的头文件库

Android.mk
LOCAL_JAVA_LIBRARIES :=

Android.bp
header_libs: ["xxx", "xxx", ...]

14、添加依赖的 Java 库

Android.mk
LOCAL_STATIC_JAVA_LIBRARIES :=

Android.bp
static_libs: ["xxx", "xxx", ...]

15、应用安装到vendor中

Android.mk
LOCAL_VENDOR_MODULE := true
or
LOCAL_PROPRIETARY_MODULE := true

Android.bp
proprietary: true
or
vendor: true

16、应用安装到product中

Android.mk
LOCAL_PRODUCT_MODULE := true

Android.bp
product_specific: true

17、应用安装到odm中

Android.mk
LOCAL_ODM_MODULE := true

Android.bp
device_specific: true

18、添加编译参数(宏开关)

C语言
Android.mk
LOCAL_CFLAGS :=

Android.bp
cflags: ["xxx", "xxx", ...]

------------------------------------------------------
C++
Android.mk
LOCAL_CPPFLAGS :=

Android.bp
cppflags: ["xxx", "xxx", ...]

----------------------------------------------------------
JAVA
Android.mk
LOCAL_JAVACFLAGS :=

Android.bp
javacflags: ["xxx", "xxx", ...]

更多精彩尽在公众号:Android全贯通