Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 1 | // 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 Badour | e578be3 | 2022-01-27 14:09:11 -0800 | [diff] [blame] | 15 | package { |
| 16 | default_applicable_licenses: ["external_libbpf_license"], |
| 17 | } |
| 18 | |
| 19 | // See: http://go/android-license-faq |
| 20 | license { |
| 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'Brien | d923688 | 2021-12-16 19:24:05 -0800 | [diff] [blame] | 34 | genrule { |
| 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'Brien | 616e3af | 2022-02-01 18:11:31 -0800 | [diff] [blame] | 48 | "bpf/hashmap.h", |
Connor O'Brien | d923688 | 2021-12-16 19:24:05 -0800 | [diff] [blame] | 49 | "bpf/libbpf_common.h", |
| 50 | "bpf/libbpf.h", |
| 51 | "bpf/libbpf_legacy.h", |
| 52 | "bpf/libbpf_version.h", |
Connor O'Brien | 616e3af | 2022-02-01 18:11:31 -0800 | [diff] [blame] | 53 | "bpf/nlattr.h", |
Connor O'Brien | d923688 | 2021-12-16 19:24:05 -0800 | [diff] [blame] | 54 | "bpf/skel_internal.h", |
| 55 | "bpf/xsk.h", |
| 56 | ], |
| 57 | } |
| 58 | |
Connor O'Brien | bdac6aa | 2022-01-18 22:51:05 -0800 | [diff] [blame] | 59 | cc_library_static { |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 60 | name: "libbpf", |
Connor O'Brien | bdac6aa | 2022-01-18 22:51:05 -0800 | [diff] [blame] | 61 | host_supported: true, |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 62 | srcs: [ |
| 63 | "src/*.c", |
| 64 | ], |
| 65 | local_include_dirs: [ |
| 66 | "android", |
| 67 | "include", |
| 68 | ], |
| 69 | export_include_dirs: [ |
| 70 | "include/uapi", |
| 71 | ], |
Connor O'Brien | d923688 | 2021-12-16 19:24:05 -0800 | [diff] [blame] | 72 | generated_headers: ["libbpf_headers"], |
| 73 | export_generated_headers: ["libbpf_headers"], |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 74 | cflags: [ |
| 75 | "-DCOMPAT_NEED_REALLOCARRAY", |
Connor O'Brien | bdac6aa | 2022-01-18 22:51:05 -0800 | [diff] [blame] | 76 | "-include android/android.h", |
| 77 | "-Wno-constant-conversion", |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 78 | "-Wno-missing-field-initializers", |
Connor O'Brien | c72a949 | 2021-11-30 16:42:42 -0800 | [diff] [blame] | 79 | "-Wno-pointer-arith", |
| 80 | "-Wno-unused-parameter", |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 81 | ], |
| 82 | static_libs: [ |
| 83 | "libelf", |
Connor O'Brien | bdac6aa | 2022-01-18 22:51:05 -0800 | [diff] [blame] | 84 | "libz", |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 85 | ], |
| 86 | visibility: [ |
Connor O'Brien | 616e3af | 2022-02-01 18:11:31 -0800 | [diff] [blame] | 87 | "//external/bpftool", |
Connor O'Brien | c6828c8 | 2022-02-01 13:07:16 -0800 | [diff] [blame] | 88 | "//external/bcc/libbpf-tools", |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 89 | "//external/dwarves", |
Matthias Maennich | 7a43309 | 2021-11-16 11:23:02 +0000 | [diff] [blame] | 90 | "//external/stg", |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 91 | ], |
Connor O'Brien | bdac6aa | 2022-01-18 22:51:05 -0800 | [diff] [blame] | 92 | target: { |
| 93 | host: { |
| 94 | compile_multilib: "64", |
| 95 | } |
| 96 | } |
Matthias Maennich | eba15fd | 2020-06-23 10:50:41 +0200 | [diff] [blame] | 97 | } |
Connor O'Brien | 34bb032 | 2022-01-14 21:46:07 -0800 | [diff] [blame] | 98 | |
| 99 | cc_library { |
| 100 | name: "libbpf_minimal", |
Steven Moreland | 1ac6c69 | 2022-02-08 00:00:52 +0000 | [diff] [blame] | 101 | vendor_available: true, |
Connor O'Brien | 34bb032 | 2022-01-14 21:46:07 -0800 | [diff] [blame] | 102 | 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'Brien | 2ca6f10 | 2022-01-18 22:53:05 -0800 | [diff] [blame] | 126 | |
| 127 | cc_binary { |
| 128 | name: "btfloader", |
| 129 | srcs: ["android/btfloader.cpp"], |
| 130 | static_libs: [ |
| 131 | "libbpf", |
| 132 | "libelf", |
| 133 | "libz" |
| 134 | ], |
Connor O'Brien | 41100a6 | 2022-02-14 18:43:23 -0800 | [diff] [blame] | 135 | cflags: [ |
| 136 | "-Wno-deprecated-declarations", |
| 137 | ] |
Connor O'Brien | 2ca6f10 | 2022-01-18 22:53:05 -0800 | [diff] [blame] | 138 | } |