一。android大约从7.0开始引入 .bp文件代替以前的.mk文件,用于帮助android项目的编译配置文件。
二。mk文件转化为bp文件,可以使用下面命令转化,注意命令中>,这是写入文件。androidmk是android源码自带的工具,他可以显示mk转换后的bp,后面是写入Android.bp
androidmk Android.mk > Android.bp
三。这两个编译脚本可以对应,所以能够转化,可以在下面的文件中看到对应的规则,事实是,虽然使用了bp,但mk依然可以正常使用,如果有老项目,可以不必转化
/build/soong/androidmk/cmd/androidmk/android.go
四。bp编译脚本常用的模块关键字
1.编译成 Java 库 java_library 2.编译成 Java 静态库 java_library_static 3.编译成 App 应用 Android.bp android_app { ...... }
4编译成 Native 动态库 Android.bp cc_library_shared { ...... } 5 编译成 Native 静态库 Android.bp cc_library_static { ...... } 6 编译成 Native 执行程序 Android.bp cc_binary { ...... } 7 编译成头文件库 Android.bp cc_library_headers { ...... } 8 预加载静态库 cc_prebuilt_library_static 9 预加载动态库 cc_prebuilt_library 五文件路径 1 本地头文件路径 Android.bp local_include_dirs: ["xxx", ...] 2 导出的头文件路径 Android.bp export_include_dirs: ["xxx", ...] 3 资源文件路径 Android.bp resource_dirs: ["xxx", ...] 六 库依赖 1 依赖的静态库 Android.bp static_libs: ["xxx", "xxx", ...] 2 依赖的动态库 Android.bp shared_libs: ["xxx", "xxx", ...] 3 依赖的头文件库 Android.bp header_libs: ["xxx", "xxx", ...] 4 依赖的 Java 库 Android.bp static_libs: ["xxx", "xxx", ...] 七安装到不同分区中 1 安装到vendor中 Android.bp proprietary: true or vendor: true 2 安装到product中 Android.bp product_specific: true 3 安装到odm中 Android.bp device_specific: true 八编译参数 1 C flags Android.bp cflags: ["xxx", "xxx", ...] 2 Cpp flags Android.bp cppflags: ["xxx", "xxx", ...] 3 Java flags Android.bp javacflags: ["xxx", "xxx", ...]
九一个放置第三方open ssl so和a的bp
cc_prebuilt_library_static {
name: "liboopenssl",
//product_available: true,
//vendor_available: true,
//vndk: {
// enabled: true,
//},
srcs: [
"lib/libssl.a",
],
export_include_dirs: ["include"],
//vendor: true
}
cc_prebuilt_library {
name: "libopenssl_shared",
product_available: true,
vendor_available: true,
vndk: {
enabled: true,
},
srcs: [
"lib/libssl.so",
],
shared_libs: [
],
//sanitize: {
// never: true,
//},
static_libs: [
//"liboopenssl",
],
export_include_dirs: ["include"],
//vendor: true
}
cc_prebuilt_library_static {
name: "liboopencrypto",
//product_available: true,
//vendor_available: true,
//vndk: {
// enabled: true,
//},
srcs: [
"lib/libcrypto.a",
],
export_include_dirs: ["include"],
//vendor: true
}
cc_prebuilt_library {
name: "libopencrypto_shared",
product_available: true,
vendor_available: true,
vndk: {
enabled: true,
},
srcs: [
"lib/libcrypto.so",
],
shared_libs: [
],
//sanitize: {
// never: true,
//},
static_libs: [
//"liboopencrypto",
],
export_include_dirs: ["include"],
//vendor: true
}
十。C++ aidl生成
cc_library_static{
name:"libaidltest",
local_include_dirs:[
"include"
],
aidl:{
local_include_dirs:["aidl"],
include_dirs:[
"frameworks/native/aidl/binder"
],
export_aidl_headers:true,
},
srcs:[
"FileInfo.cpp",
":libfile_aidl"
],
shared_libs:[
"libbinder",
"libutils",
],
}
filegroup{
name:"libfile_aidl",
srcs:[
"aidl/com/hht/FileInfo.aidl",
"aidl/com/hht/IFileInfoCallback.aidl",
"aidl/com/hht/IGetFileInfo.aidl"
],
path:"aidl",
}
十二
// 生成一个so库
cc_library_static {
name: "libfileservice_aidl",
srcs: [
":fileservice_aidl",
],
aidl: {
local_include_dirs: ["aidl"],
include_dirs: [
"frameworks/native/aidl/binder"
],
export_aidl_headers: true,
},
shared_libs: [
"libbinder",
"libutils",
"liblog",
],
}
filegroup {
name: "fileservice_aidl",
srcs: [
"aidl/com/filetool/IFileOperation.aidl",
],
path:"aidl",
}
//
// 生成可执行文件
cc_binary {
name: "fileservice",
srcs: [
"main.cpp",
"FileService.cpp",
],
init_rc: ["sota.rc"],
cflags: [
"-Werror",
"-Wno-error=deprecated-declarations",
"-Wall",
"-Wformat-security",
"-Wno-unused-parameter",
],
shared_libs: [
"libbinder",
"libcutils",
"liblog",
"libutils",
"libbase",
],
static_libs:[
"libfileservice_aidl",
]
}
十。错误总结
。。。
Android.bp语法和使用方法讲解 (yii666.com)aidl 实现native service和App通信_aidl native service_东东旭huster的博客-CSDN博客