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-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 34genrule { 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", 48 "bpf/hashmap.h", 49 "bpf/libbpf_common.h", 50 "bpf/libbpf.h", 51 "bpf/libbpf_legacy.h", 52 "bpf/libbpf_version.h", 53 "bpf/nlattr.h", 54 "bpf/skel_internal.h", 55 "bpf/xsk.h", 56 ], 57} 58 59cc_library_static { 60 name: "libbpf", 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 vendor_available: true, 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} 126 127cc_binary { 128 name: "btfloader", 129 srcs: ["android/btfloader.cpp"], 130 static_libs: [ 131 "libbpf", 132 "libelf", 133 "libz" 134 ], 135 cflags: [ 136 "-Wno-deprecated-declarations", 137 ] 138} 139