aboutsummaryrefslogtreecommitdiff
path: root/Android.bp
diff options
context:
space:
mode:
authorConnor O'Brien <connoro@google.com>2022-01-14 21:46:07 -0800
committerConnor O'Brien <connoro@google.com>2022-01-19 10:26:19 -0800
commit34bb032e6e4552d940b4dc43d59a3ad7d6de1c3a (patch)
tree976f73d1a44c0bb5cf9306c39f1ca651017dc851 /Android.bp
parentd92368896a608268507d8223e35c3ef214fd9181 (diff)
downloadlibbpf-34bb032e6e4552d940b4dc43d59a3ad7d6de1c3a.tar.gz
build libelf-free minimal libbpf for device
Add a device build of libbpf that includes only code with no libelf dependency, and which can therefore be used from framework code. bpf.c depends on a few symbols implemented in libbpf.c, so add a new file with stub implementations for those symbols. Also, the local linux/compiler.h and linux/types.h clobber the bionic versions, with the result that __user, __force and __poll_t are undefined. Since other bionic headers expect these to be defined, this causes most of the files under src/ to fail to compile. Add a header under android/ to ensure these are defined, and include it via Android.bp to minimize Android-specific changes to upstream libbpf code. Test: m libbpf_minimal Bug: 203823368 Signed-off-by: Connor O'Brien <connoro@google.com> Change-Id: I326b31cac62bbd58905d25d45483cf968c00b971
Diffstat (limited to 'Android.bp')
-rw-r--r--Android.bp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
index ec55963..809e349 100644
--- a/Android.bp
+++ b/Android.bp
@@ -64,3 +64,30 @@ cc_library_host_static {
],
compile_multilib: "64",
}
+
+cc_library {
+ name: "libbpf_minimal",
+ native_bridge_supported: true,
+ srcs: [
+ "android/bpf_stub.c",
+ "src/bpf.c",
+ "src/libbpf_errno.c",
+ "src/netlink.c",
+ "src/nlattr.c",
+ "src/ringbuf.c",
+ ],
+ local_include_dirs: [
+ "android",
+ "include"
+ ],
+ export_include_dirs: [
+ "include/uapi"
+ ],
+ generated_headers: ["libbpf_headers"],
+ export_generated_headers: ["libbpf_headers"],
+ cflags: [
+ "-include android/android.h",
+ "-Wno-pointer-arith",
+ "-Wno-unused-parameter",
+ ],
+}