参考资料:
https://www.cnblogs.com/linhaostudy/p/12361659.html
https://blog.csdn.net/hxp1994/article/details/113853459
https://blog.csdn.net/tkwxty/article/details/104395820
Android.bp
Android.bp文件首先是Android系统的一种编译配置文件,是用来代替原来的Android.mk文件的。在Android7.0以前,Android都是使用make来组织各模块的编译,对应的编译配置文件就是Android.mk。在Android7.0开始,Google引入了ninja和kati来编译,为啥引入ninja?因为随着Android越来越庞大,module越来越多,编译时间也越来越久,而使用ninja在编译的并发处理上较make有很大的提升。Ninja的配置文件就是Android.bp,Android系统使用Blueprint和Soong工具来解析Android.bp转换生成ninja文件。为了兼容老的mk配置文件,Android当初也开发了Kati 工具来转换mk文件生成ninja,目前Android Q里边,还是支持Android.mk方式的。相信在将来的版本中,会彻底让mk文件废弃,同时Kati也就淘汰了,只保留bp配置方式,所以要熟练掌握bp语法。 Android.bp文件配置规则 cc_library_shared :编译成动态库,类似于Android.mk中的BUILD_SHARED_LIBRARY cc_binary:编译成可执行文件,类似于Android.mk中的BUILD_EXECUTABLE name :编译出的模块的名称,类似于Android.mk中的LOCAL_MODULE srcs:源文件,类似于Android.mk中的LOCAL_SRC_FILES local_include_dirs:指定路径查找头文件,类似于Android.mk中的LOCAL_C_INCLUDES shared_libs:编译所依赖的动态库,类似于Android.mk中的LOCAL_SHARED_LIBRARIES static_libs:编译所依赖的静态库,类似于Android.mk中的LOCAL_STATIC_LIBRARIES cflags:编译flag,类似于Android.mk中的LOCAL_CFLAGS 举个例子:cc_library_shared { //编译成动态库,类似于Android.mk中的BUILD_SHARED_LIBRARY name: "libbluetooth_jni", //编译出的模块的名称,类似于Android.mk中的LOCAL_MODULE srcs: [ //源文件,类似于Android.mk中的LOCAL_SRC_FILES "com_android_bluetooth_btservice_AdapterService.cpp", "com_android_bluetooth_hfp.cpp", "com_android_bluetooth_hfpclient.cpp", "com_android_bluetooth_a2dp.cpp", "com_android_bluetooth_a2dp_sink.cpp", "com_android_bluetooth_avrcp.cpp", "com_android_bluetooth_avrcp_controller.cpp", "com_android_bluetooth_hid.cpp", "com_android_bluetooth_hidd.cpp", "com_android_bluetooth_hdp.cpp", "com_android_bluetooth_pan.cpp", "com_android_bluetooth_gatt.cpp", "com_android_bluetooth_sdp.cpp", ], include_dirs: [ //用户指定的头文件查找路径,类似于Android.mk中的LOCAL_C_INCLUDES "libnativehelper/include/nativehelper", "system/bt/types", ], shared_libs: [ //编译所依赖的动态库,类似于Android.mk中的LOCAL_SHARED_LIBRARIES "libandroid_runtime", "libchrome", "libnativehelper", "libcutils", "libutils", "liblog", "libhardware", ], static_libs: [ //编译所依赖的静态库,类似于Android.mk中的LOCAL_STATIC_LIBRARIES "libbluetooth-types", ], cflags: [ ///编译flag,类似于Android.mk中的LOCAL_CFLAGS "-Wall", "-Wextra", "-Wno-unused-parameter", ], }
举一个简单的示例:
cc_binary { name:"test", srcs:["./test.c"], shared_libs:["liblog"], owner: "qti", proprietary: true, // proprietary为true会编译到/vendor/bin,不然就会编译到/system/bin }
标签:mk,bluetooth,语法,bp,cpp,Android,com,android From: https://www.cnblogs.com/lethe1203/p/18104137