1SUMMARY = "bpftrace"
2HOMEPAGE = "https://github.com/iovisor/bpftrace"
3LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
5
6DEPENDS += "bison-native \
7            flex-native \
8            gzip-native \
9            elfutils \
10            bcc \
11            systemtap \
12            libcereal \
13            libbpf \
14            "
15
16PV .= "+git${SRCREV}"
17RDEPENDS:${PN} += "bash python3 xz"
18
19SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \
20           file://0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch \
21           file://0001-Fix-segfault-when-btf__type_by_id-returns-NULL.patch \
22           file://run-ptest \
23"
24SRCREV = "0a318e53343aa51f811183534916a4be65a1871e"
25
26S = "${WORKDIR}/git"
27
28inherit cmake ptest
29
30PACKAGECONFIG ?= "${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"
31
32# Clang-15.x crashes compiling some usdt tests
33# see https://github.com/llvm/llvm-project/issues/58477
34PACKAGECONFIG:remove:riscv64 = "tests"
35
36PACKAGECONFIG[tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF,gtest xxd-native"
37
38do_install_ptest() {
39    if [ -e ${B}/tests/bpftrace_test ]; then
40        install -Dm 755 ${B}/tests/bpftrace_test ${D}${PTEST_PATH}/tests/bpftrace_test
41        cp -rf ${B}/tests/runtime ${D}${PTEST_PATH}/tests
42        cp -rf ${B}/tests/test* ${D}${PTEST_PATH}/tests
43    fi
44}
45
46def llvm_major_version(d):
47    pvsplit = d.getVar('LLVMVERSION').split('.')
48    return pvsplit[0]
49
50LLVM_MAJOR_VERSION = "${@llvm_major_version(d)}"
51
52EXTRA_OECMAKE = " \
53    -DCMAKE_ENABLE_EXPORTS=1 \
54    -DCMAKE_BUILD_TYPE=Release \
55    -DLLVM_REQUESTED_VERSION=${LLVM_MAJOR_VERSION} \
56    -DENABLE_MAN=OFF \
57"
58
59COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux"
60COMPATIBLE_HOST:libc-musl = "null"
61