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_static { 59 name: "libbpf", 60 defaults: ["elfutils_transitive_defaults"], 61 host_supported: true, 62 srcs: [ 63 "src/*.c", 64 ], 65 local_include_dirs: [ 66 "android", 67 "include", 68 ], 69 export_include_dirs: [ 70 "include/uapi", 71 ], 72 generated_headers: ["libbpf_headers"], 73 export_generated_headers: ["libbpf_headers"], 74 cflags: [ 75 "-DCOMPAT_NEED_REALLOCARRAY", 76 "-include android/android.h", 77 "-Wno-constant-conversion", 78 "-Wno-missing-field-initializers", 79 "-Wno-pointer-arith", 80 "-Wno-unused-parameter", 81 ], 82 static_libs: [ 83 "libelf", 84 "libz", 85 ], 86 visibility: [ 87 "//external/bpftool", 88 "//external/bcc/libbpf-tools", 89 "//external/dwarves", 90 "//external/stg", 91 ], 92 target: { 93 host: { 94 compile_multilib: "64", 95 } 96 } 97} 98 99cc_library { 100 name: "libbpf_minimal", 101 defaults: ["elfutils_transitive_defaults"], 102 vendor_available: true, 103 native_bridge_supported: true, 104 srcs: [ 105 "android/bpf_stub.c", 106 "src/bpf.c", 107 "src/libbpf_errno.c", 108 "src/netlink.c", 109 "src/nlattr.c", 110 "src/ringbuf.c", 111 ], 112 local_include_dirs: [ 113 "android", 114 "include" 115 ], 116 export_include_dirs: [ 117 "include/uapi" 118 ], 119 static_libs: [ 120 "libelf", 121 ], 122 generated_headers: ["libbpf_headers"], 123 export_generated_headers: ["libbpf_headers"], 124 cflags: [ 125 "-include android/android.h", 126 "-Wno-pointer-arith", 127 "-Wno-unused-parameter", 128 ], 129} 130