Android.bp 预编译
程序员文章站
2024-02-26 21:10:34
...
Android.bp 支持的预编译
以Bluetooth为例子,其中
动态库 : [email protected]
静态库 :android.hardware.bluetooth-async android.hardware.bluetooth-hci
运行库 :[email protected]
先进行正常编译。
//
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
cc_library_shared {
name: "[email protected]",
defaults: ["hidl_defaults"],
vendor: true,
relative_install_path: "hw",
srcs: [
"bluetooth_hci.cc",
"bluetooth_address.cc",
"vendor_interface.cc",
],
shared_libs: [
"[email protected]",
"libbase",
"libcutils",
"libhardware",
"libhidlbase",
"libhidltransport",
"liblog",
"libutils",
],
static_libs: [
"android.hardware.bluetooth-async",
"android.hardware.bluetooth-hci",
],
}
cc_library_static {
name: "android.hardware.bluetooth-async",
vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"async_fd_watcher.cc",
],
export_include_dirs: ["."],
shared_libs: [
"liblog",
],
}
cc_library_static {
name: "android.hardware.bluetooth-hci",
vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"hci_packetizer.cc",
"hci_protocol.cc",
"h4_protocol.cc",
"mct_protocol.cc",
],
export_include_dirs: ["."],
shared_libs: [
"libbase",
"libhidlbase",
"liblog",
"libutils",
],
}
cc_test {
name: "bluetooth-vendor-interface-unit-tests",
vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"test/async_fd_watcher_unittest.cc",
"test/h4_protocol_unittest.cc",
"test/mct_protocol_unittest.cc",
],
local_include_dirs: [
"test",
],
shared_libs: [
"libbase",
"libhidlbase",
"liblog",
"libutils",
],
static_libs: [
"android.hardware.bluetooth-async",
"android.hardware.bluetooth-hci",
"libgmock",
],
}
cc_test_host {
name: "bluetooth-address-unit-tests",
defaults: ["hidl_defaults"],
srcs: [
"bluetooth_address.cc",
"test/bluetooth_address_test.cc",
"test/properties.cc",
],
local_include_dirs: [
"test",
],
shared_libs: [
"libbase",
"liblog",
],
}
cc_binary {
name: "[email protected]",
defaults: ["hidl_defaults"],
relative_install_path: "hw",
vendor: true,
init_rc: ["[email protected]"],
srcs: ["service.cpp"],
shared_libs: [
"liblog",
"libcutils",
"libdl",
"libbase",
"libutils",
"libhardware",
"libhidlbase",
"libhidltransport",
"[email protected]",
],
}
动态库生成位置:out/target/product/(PRODUCT_NAME)/obj(obj_arm)/SHARED_LIBRARIES/
静态库生成位置:out/target/product/(PRODUCT_NAME)/obj(obj_arm)/STATIC_LIBRARIES/
其中obj是64位,obj_arm是32位。也可以用以下命令进行确认。
静态库:
objdump -a abc.a
动态库:
file abc.so
预编译
Android.bp 支持五种预编译,如下:
var prebuiltTypes = map[string]string{
"SHARED_LIBRARIES": "cc_prebuilt_library_shared",
"STATIC_LIBRARIES": "cc_prebuilt_library_static",
"EXECUTABLES": "cc_prebuilt_binary",
"JAVA_LIBRARIES": "java_import",
"ETC": "prebuilt_etc",
}
预编译的问下如下:
cc_prebuilt_library_shared {
name: "[email protected]",
vendor: true,
relative_install_path: "hw",
multilib: {
lib64: {
srcs: ["lib64/[email protected]"],
},
lib32: {
srcs: ["lib/[email protected]"],
},
},
strip: {
none:true,
},
compile_multilib:"both",
}
cc_prebuilt_library_static {
name: "android.hardware.bluetooth-async",
vendor: true,
export_include_dirs: ["."],
multilib: {
lib64: {
srcs: ["lib64/android.hardware.bluetooth-async.a"],
},
lib32: {
srcs: ["lib/android.hardware.bluetooth-async.a"],
},
},
strip: {
none:true,
},
compile_multilib:"both",
}
cc_prebuilt_library_static {
name: "android.hardware.bluetooth-hci",
vendor: true,
export_include_dirs: ["."],
multilib: {
lib64: {
srcs: ["lib64/android.hardware.bluetooth-hci.a"],
},
lib32: {
srcs: ["lib/android.hardware.bluetooth-hci.a"],
},
},
strip: {
none:true,
},
compile_multilib:"both",
}
cc_prebuilt_binary {
name: "[email protected]",
relative_install_path: "hw",
vendor: true,
srcs:["[email protected]"],
init_rc: ["[email protected]"],
strip: {
none:true,
},
}
推荐阅读
-
Android 编译系统之Android.bp
-
Android10(Q)系统源码编译
-
Android.bp 预编译
-
Android.bp 屏蔽编译
-
Linux中编译带clock_gettime函数的代码,提示undefined reference to 'clock_gettime'
-
java教程之java程序编译运行图解(java程序运行)
-
java编译时出现使用了未经检查或不安全的操作解决方法
-
详谈Android编译命令
-
交叉编译完全解决方案 博客分类: 技术 DebianMaemo嵌入式Linux虚拟机
-
交叉编译完全解决方案 博客分类: 技术 DebianMaemo嵌入式Linux虚拟机