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 15package { 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-Linux-syscall-note", 26 ], 27 license_text: [ 28 "LICENSE.BSD-2-Clause", 29 ], 30} 31 32genrule { 33 name: "libbpf_headers", 34 srcs: [ 35 "src/*.h", 36 ], 37 cmd: "mkdir -p $(genDir)/bpf && cp $(in) $(genDir)/bpf/", 38 out: [ 39 "bpf/bpf_core_read.h", 40 "bpf/bpf_endian.h", 41 "bpf/bpf.h", 42 "bpf/bpf_helper_defs.h", 43 "bpf/bpf_helpers.h", 44 "bpf/bpf_tracing.h", 45 "bpf/btf.h", 46 "bpf/hashmap.h", 47 "bpf/libbpf_common.h", 48 "bpf/libbpf.h", 49 "bpf/libbpf_internal.h", 50 "bpf/libbpf_legacy.h", 51 "bpf/libbpf_version.h", 52 "bpf/nlattr.h", 53 "bpf/skel_internal.h", 54 "bpf/relo_core.h", 55 ], 56} 57 58cc_library_headers { 59 name: "libbpf_build_headers", 60 export_include_dirs: ["include"], 61 visibility: [ 62 "//external/rust/android-crates-io/crates/libbpf-sys", 63 ], 64} 65 66cc_library { 67 name: "libbpf", 68 defaults: ["elfutils_transitive_defaults"], 69 host_supported: true, 70 srcs: [ 71 "src/*.c", 72 ], 73 local_include_dirs: [ 74 "android", 75 "include", 76 ], 77 export_include_dirs: [ 78 "include/uapi", 79 ], 80 generated_headers: ["libbpf_headers"], 81 export_generated_headers: ["libbpf_headers"], 82 cflags: [ 83 "-DCOMPAT_NEED_REALLOCARRAY", 84 "-include android/android.h", 85 "-Wno-constant-conversion", 86 "-Wno-missing-field-initializers", 87 "-Wno-pointer-arith", 88 "-Wno-unused-parameter", 89 "-Wno-user-defined-warnings", 90 ], 91 visibility: [ 92 "//external/bpftool", 93 "//external/bcc/libbpf-tools", 94 "//external/dwarves", 95 "//external/rust/android-crates-io/crates/libbpf-rs", 96 "//external/rust/android-crates-io/crates/libbpf-sys", 97 "//external/stg", 98 "//hardware/interfaces/health/utils/libhealthloop", // For use in tests only. 99 // Because libbpf depends on the GPL-licensed libelf, its use should be restricted to the 100 // standalone bpf loader binary. This visibility must not be widened. 101 "//packages/modules/Connectivity/bpf/loader", 102 ], 103 apex_available: [ 104 "//apex_available:platform", 105 "com.android.tethering", 106 ], 107 min_sdk_version: "apex_inherit", 108 target: { 109 android: { 110 static_libs: [ 111 "libelf", 112 ], 113 shared_libs: [ 114 "libz", 115 ], 116 }, 117 host: { 118 compile_multilib: "64", 119 static_libs: [ 120 "libelf", 121 "libz", 122 ], 123 }, 124 }, 125} 126 127cc_library { 128 name: "libbpf_minimal", 129 defaults: ["elfutils_transitive_defaults"], 130 vendor_available: true, 131 native_bridge_supported: true, 132 srcs: [ 133 "android/bpf_stub.c", 134 "src/bpf.c", 135 "src/libbpf_errno.c", 136 "src/netlink.c", 137 "src/nlattr.c", 138 "src/ringbuf.c", 139 ], 140 local_include_dirs: [ 141 "android", 142 "include", 143 ], 144 export_include_dirs: [ 145 "include/uapi", 146 ], 147 static_libs: [ 148 "libelf", 149 ], 150 generated_headers: ["libbpf_headers"], 151 export_generated_headers: ["libbpf_headers"], 152 cflags: [ 153 "-include android/android.h", 154 "-Wno-pointer-arith", 155 "-Wno-unused-parameter", 156 ], 157} 158