blob: 18b6d305c0567c0edf11b61797d36c530d21ddf2 [file] [edit]
package {
default_applicable_licenses: ["external_libpcap_license"],
}
license {
name: "external_libpcap_license",
visibility: [":__subpackages__"],
license_kinds: [
"SPDX-license-identifier-Apache-2.0",
"SPDX-license-identifier-BSD",
"SPDX-license-identifier-ISC",
"SPDX-license-identifier-MIT",
],
license_text: [
"LICENSE",
"NOTICE",
],
}
cc_defaults {
name: "libpcap_defaults",
cflags: [
"-DHAVE_CONFIG_H",
"-D_BSD_SOURCE",
"-D_U_=__attribute__((__unused__))",
"-Dlint",
"-Wall",
"-Werror",
"-Wno-implicit-function-declaration",
"-Wno-int-conversion",
"-Wno-macro-redefined",
"-Wno-pointer-arith",
"-Wno-sign-compare",
"-Wno-tautological-compare",
"-Wno-unused-parameter",
"-Wno-unused-result",
],
multilib: {
lib32: {
cflags: [
"-DSIZEOF_TIME_T=4",
],
},
lib64: {
cflags: [
"-DSIZEOF_TIME_T=8",
],
},
},
}
genrule {
name: "grammar.y",
cmd: "sed 's/@REENTRANT_PARSER@/%define api.pure/' $(in) > $(out)",
out: ["grammar.y"],
srcs: ["grammar.y.in"],
}
genrule {
name: "grammar.c",
cmd: "M4=$(location m4) $(location bison) -p pcap_ --no-lines --output=$(genDir)/grammar.c $(in)",
out: ["grammar.c"],
srcs: [":grammar.y"],
tools: [
"bison",
"m4",
],
}
genrule {
name: "grammar.h",
// bison --defines outputs an extra file in addition to outputting the parser,
// so we still use --output to ensure the unused file is still in genDir.
cmd: "M4=$(location m4) $(location bison) -p pcap_ --no-lines --defines=$(genDir)/grammar.h --output=$(genDir)/unused $(in)",
out: ["grammar.h"],
srcs: [":grammar.y"],
tools: [
"bison",
"m4",
],
}
genrule {
name: "scanner.c",
cmd: "M4=$(location m4) $(location flex) -P pcap_ -o $(genDir)/scanner.c $(in)",
out: ["scanner.c"],
srcs: ["scanner.l"],
tools: [
"flex",
"m4",
],
}
genrule {
name: "scanner.h",
cmd: "M4=$(location m4) $(location flex) -P pcap_ --header-file=$(genDir)/scanner.h $(in)",
out: ["scanner.h"],
srcs: ["scanner.l"],
tools: [
"flex",
"m4",
],
}
cc_library {
name: "libpcap",
host_supported: true,
vendor_available: true,
// Build against the NDK 29 because it's used by the network stack mainline module tests, which
// need to support Q.
// TODO(b/148792341): stop hardcoding sdk_version integers in libraries all over the tree and
// define a min_apex_sdk_version property that all module code can use.
sdk_version: "29",
defaults: ["libpcap_defaults"],
generated_headers: [
"grammar.h",
"scanner.h",
],
srcs: [
":grammar.c",
":scanner.c",
"bpf_dump.c",
"bpf_filter.c",
"bpf_image.c",
"etherent.c",
"fad-getad.c",
"fmtutils.c",
"gencode.c",
"nametoaddr.c",
"optimize.c",
"pcap-common.c",
"pcap-linux.c",
"pcap-netfilter-linux-android.c",
"pcap-usb-linux.c",
"pcap-util.c",
"pcap.c",
"savefile.c",
"sf-pcap.c",
"sf-pcapng.c",
],
target: {
linux: {
srcs: [
"missing/strlcpy.c",
],
},
darwin: {
enabled: false,
},
},
export_include_dirs: ["."],
}
//
// Tests (but not _unit_ tests).
//
// It's unlikely anyone's running these manually, but at least compiling them
// shows we can compile libpcap callers...
//
cc_test {
name: "libpcap_can_set_rfmon_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/can_set_rfmon_test.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_capture_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/capturetest.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_filter_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/filtertest.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_findalldevs_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/findalldevstest.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_open_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/opentest.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_reactivate_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/reactivatetest.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_selpoll_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/selpolltest.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_threadsignal_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/threadsignaltest.c"],
static_libs: ["libpcap"],
}
cc_test {
name: "libpcap_valgrind_test",
defaults: ["libpcap_defaults"],
gtest: false,
srcs: ["testprogs/valgrindtest.c"],
static_libs: ["libpcap"],
}