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 static_libs: [ 92 "libelf", 93 "libz", 94 ], 95 visibility: [ 96 "//external/bpftool", 97 "//external/bcc/libbpf-tools", 98 "//external/dwarves", 99 "//external/rust/android-crates-io/crates/libbpf-rs", 100 "//external/rust/android-crates-io/crates/libbpf-sys", 101 "//external/stg", 102 "//hardware/interfaces/health/utils/libhealthloop", // For use in tests only. 103 ], 104 target: { 105 host: { 106 compile_multilib: "64", 107 }, 108 }, 109} 110 111cc_library { 112 name: "libbpf_minimal", 113 defaults: ["elfutils_transitive_defaults"], 114 vendor_available: true, 115 native_bridge_supported: true, 116 srcs: [ 117 "android/bpf_stub.c", 118 "src/bpf.c", 119 "src/libbpf_errno.c", 120 "src/netlink.c", 121 "src/nlattr.c", 122 "src/ringbuf.c", 123 ], 124 local_include_dirs: [ 125 "android", 126 "include", 127 ], 128 export_include_dirs: [ 129 "include/uapi", 130 ], 131 static_libs: [ 132 "libelf", 133 ], 134 generated_headers: ["libbpf_headers"], 135 export_generated_headers: ["libbpf_headers"], 136 cflags: [ 137 "-include android/android.h", 138 "-Wno-pointer-arith", 139 "-Wno-unused-parameter", 140 ], 141} 142