[转载]Android make中变量记录

作者 by adtxl / 2021-06-16 / 暂无评论 / 583 个足迹

转载自Android make 中变量记录

转换mk文件到bp文件

$ out/soong/host/linux-x86/bin/androidmk Android.mk > Android.bp 

编译不同类型的模块

编译成 Native 动态库

Android.mk
include $(BUILD_SHARED_LIBRARY)

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

编译成 Native 静态库

Android.mk
include $(BUILD_STATIC_LIBRARY)

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

编译成 Native 执行程序

Android.mk
include $(BUILD_EXECUTABLE)

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

编译成头文件库

Android.mk
include $(BUILD_HEADER_LIBRARY)

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

编译成 Java 库

Android.mk
include $(BUILD_JAVA_LIBRARY)

Android.bp
java_library {
......
}

编译成 Java 静态库

Android.mk
include $(BUILD_STATIC_JAVA_LIBRARY)

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

编译成 App 应用

Android.mk
include $(BUILD_PACKAGE)

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

文件路径

本地头文件路径

Android.mk
LOCAL_C_INCLUDES :=

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

导出的头文件路径

Android.mk
LOCAL_EXPORT_C_INCLUDE_DIRS :=

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

资源文件路径

Android.mk
LOCAL_RESOURCE_DIR :=

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

库依赖

依赖的静态库

Android.mk
LOCAL_STATIC_LIBRARIES :=

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

依赖的动态库

Android.mk
LOCAL_SHARED_LIBRARIES :=

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

依赖的头文件库

Android.mk
LOCAL_JAVA_LIBRARIES :=

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

依赖的 Java 库

Android.mk
LOCAL_STATIC_LIBRARIES :=

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

依赖的 Java 静态库

Android.mk
LOCAL_STATIC_JAVA_LIBRARIES :=

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

安装到不同分区中

安装到vendor中

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

Android.bp
proprietary: true
or
vendor: true

安装到product中

Android.mk
LOCAL_PRODUCT_MODULE := true

Android.bp
product_specific: true

安装到odm中

Android.mk
LOCAL_ODM_MODULE := true
Android.bp
device_specific: true

编译参数

C flags

Android.mk
LOCAL_CFLAGS :=

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

Cpp flags

Android.mk
LOCAL_CPPFLAGS :=

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

Java flags

Android.mk
LOCAL_JAVACFLAGS :=

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

独特见解