blob: 7b368a1ef6a510f51d5569dbf8d1dd08220b4300 [file] [log] [blame]
Matthias Maennicheba15fd2020-06-23 10:50:41 +02001// Copyright (C) 2020 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Bob Badoure578be32022-01-27 14:09:11 -080015package {
16 default_applicable_licenses: ["external_libbpf_license"],
17}
18
19// See: http://go/android-license-faq
20license {
21 name: "external_libbpf_license",
22 visibility: [":__subpackages__"],
23 license_kinds: [
24 "SPDX-license-identifier-BSD-2-Clause",
25 "SPDX-license-identifier-GPL-2.0",
26 "SPDX-license-identifier-LGPL-2.1-only",
27 ],
28 license_text: [
29 "LICENSE.BSD-2-Clause",
30 "LICENSE.LGPL-2.1",
31 ],
32}
33
Connor O'Briend9236882021-12-16 19:24:05 -080034genrule {
35 name: "libbpf_headers",
36 srcs: [
37 "src/*.h",
38 ],
39 cmd: "mkdir -p $(genDir)/bpf && cp $(in) $(genDir)/bpf/",
40 out: [
41 "bpf/bpf_core_read.h",
42 "bpf/bpf_endian.h",
43 "bpf/bpf.h",
44 "bpf/bpf_helper_defs.h",
45 "bpf/bpf_helpers.h",
46 "bpf/bpf_tracing.h",
47 "bpf/btf.h",
Connor O'Brien616e3af2022-02-01 18:11:31 -080048 "bpf/hashmap.h",
Connor O'Briend9236882021-12-16 19:24:05 -080049 "bpf/libbpf_common.h",
50 "bpf/libbpf.h",
51 "bpf/libbpf_legacy.h",
52 "bpf/libbpf_version.h",
Connor O'Brien616e3af2022-02-01 18:11:31 -080053 "bpf/nlattr.h",
Connor O'Briend9236882021-12-16 19:24:05 -080054 "bpf/skel_internal.h",
55 "bpf/xsk.h",
56 ],
57}
58
Connor O'Brienbdac6aa2022-01-18 22:51:05 -080059cc_library_static {
Matthias Maennicheba15fd2020-06-23 10:50:41 +020060 name: "libbpf",
Connor O'Brienbdac6aa2022-01-18 22:51:05 -080061 host_supported: true,
Matthias Maennicheba15fd2020-06-23 10:50:41 +020062 srcs: [
63 "src/*.c",
64 ],
65 local_include_dirs: [
66 "android",
67 "include",
68 ],
69 export_include_dirs: [
70 "include/uapi",
71 ],
Connor O'Briend9236882021-12-16 19:24:05 -080072 generated_headers: ["libbpf_headers"],
73 export_generated_headers: ["libbpf_headers"],
Matthias Maennicheba15fd2020-06-23 10:50:41 +020074 cflags: [
75 "-DCOMPAT_NEED_REALLOCARRAY",
Connor O'Brienbdac6aa2022-01-18 22:51:05 -080076 "-include android/android.h",
77 "-Wno-constant-conversion",
Matthias Maennicheba15fd2020-06-23 10:50:41 +020078 "-Wno-missing-field-initializers",
Connor O'Brienc72a9492021-11-30 16:42:42 -080079 "-Wno-pointer-arith",
80 "-Wno-unused-parameter",
Matthias Maennicheba15fd2020-06-23 10:50:41 +020081 ],
82 static_libs: [
83 "libelf",
Connor O'Brienbdac6aa2022-01-18 22:51:05 -080084 "libz",
Matthias Maennicheba15fd2020-06-23 10:50:41 +020085 ],
86 visibility: [
Connor O'Brien616e3af2022-02-01 18:11:31 -080087 "//external/bpftool",
Connor O'Brienc6828c82022-02-01 13:07:16 -080088 "//external/bcc/libbpf-tools",
Matthias Maennicheba15fd2020-06-23 10:50:41 +020089 "//external/dwarves",
Matthias Maennich7a433092021-11-16 11:23:02 +000090 "//external/stg",
Matthias Maennicheba15fd2020-06-23 10:50:41 +020091 ],
Connor O'Brienbdac6aa2022-01-18 22:51:05 -080092 target: {
93 host: {
94 compile_multilib: "64",
95 }
96 }
Matthias Maennicheba15fd2020-06-23 10:50:41 +020097}
Connor O'Brien34bb0322022-01-14 21:46:07 -080098
99cc_library {
100 name: "libbpf_minimal",
Steven Moreland1ac6c692022-02-08 00:00:52 +0000101 vendor_available: true,
Connor O'Brien34bb0322022-01-14 21:46:07 -0800102 native_bridge_supported: true,
103 srcs: [
104 "android/bpf_stub.c",
105 "src/bpf.c",
106 "src/libbpf_errno.c",
107 "src/netlink.c",
108 "src/nlattr.c",
109 "src/ringbuf.c",
110 ],
111 local_include_dirs: [
112 "android",
113 "include"
114 ],
115 export_include_dirs: [
116 "include/uapi"
117 ],
118 generated_headers: ["libbpf_headers"],
119 export_generated_headers: ["libbpf_headers"],
120 cflags: [
121 "-include android/android.h",
122 "-Wno-pointer-arith",
123 "-Wno-unused-parameter",
124 ],
125}
Connor O'Brien2ca6f102022-01-18 22:53:05 -0800126
127cc_binary {
128 name: "btfloader",
129 srcs: ["android/btfloader.cpp"],
130 static_libs: [
131 "libbpf",
132 "libelf",
133 "libz"
134 ],
Connor O'Brien41100a62022-02-14 18:43:23 -0800135 cflags: [
136 "-Wno-deprecated-declarations",
137 ]
Connor O'Brien2ca6f102022-01-18 22:53:05 -0800138}