|
@@ -13,67 +13,33 @@ package("linux-tools")
|
|
|
add_versions("5.0.8", "11908044e8cce1e093141f8da594708d45d05d0381676ae9aa3d8aeaf7c85435")
|
|
|
add_versions("5.9.16", "b0d7abae88e5f91893627c645e680a95c818defd1b4fcaf3e2afb4b2b6b4ab86")
|
|
|
|
|
|
- add_configs("bpf", { description = "Enable bpf tools and libraries.", default = true, type = "boolean"})
|
|
|
+ add_configs("bpftool", { description = "Enable bpftool.", default = true, type = "boolean"})
|
|
|
+ add_configs("libbpf", { description = "Enable libbpf library.", default = false, type = "boolean"})
|
|
|
+
|
|
|
+ local modules = {"bpftool", "libbpf"}
|
|
|
|
|
|
on_load(function (package)
|
|
|
- if package:config("bpf") then
|
|
|
- package:add("deps", "libcap", "libelf", "zlib")
|
|
|
- package:addenv("PATH", "sbin")
|
|
|
- if package:is_plat("linux") and package:is_arch("x86_64") then
|
|
|
- package:add("links", "bpf")
|
|
|
- package:add("linkdirs", "lib64")
|
|
|
- if package:config("shared") then
|
|
|
- package:addenv("LD_LIBRARY_PATH", "lib64")
|
|
|
- end
|
|
|
+ for _, name in ipairs(modules) do
|
|
|
+ if package:config(name) then
|
|
|
+ import("modules." .. name).load(package)
|
|
|
end
|
|
|
end
|
|
|
end)
|
|
|
|
|
|
on_install("linux", function (package)
|
|
|
- import("package.tools.make")
|
|
|
-
|
|
|
- local cflags = {}
|
|
|
- local ldflags = {}
|
|
|
- for _, dep in ipairs(package:orderdeps()) do
|
|
|
- local fetchinfo = dep:fetch()
|
|
|
- if fetchinfo then
|
|
|
- for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
|
|
|
- table.insert(cflags, "-isystem " .. includedir)
|
|
|
- end
|
|
|
- for _, linkdir in ipairs(fetchinfo.linkdirs) do
|
|
|
- table.insert(ldflags, "-L" .. linkdir)
|
|
|
- end
|
|
|
- for _, link in ipairs(fetchinfo.links) do
|
|
|
- table.insert(ldflags, "-l" .. link)
|
|
|
- end
|
|
|
+ for _, name in ipairs(modules) do
|
|
|
+ if package:config(name) then
|
|
|
+ local oldir = os.curdir()
|
|
|
+ import("modules." .. name).install(package)
|
|
|
+ os.cd(oldir)
|
|
|
end
|
|
|
end
|
|
|
-
|
|
|
- local configs = {}
|
|
|
- table.insert(configs, "EXTRA_CFLAGS=" .. table.concat(cflags, " "))
|
|
|
- table.insert(configs, "LDFLAGS=" .. table.concat(ldflags, " "))
|
|
|
-
|
|
|
- if package:config("bpf") then
|
|
|
- local oldir = os.cd("tools/bpf/bpftool")
|
|
|
- io.replace("Makefile", "prefix ?= /usr/local", "prefix ?= " .. package:installdir(), {plain = true})
|
|
|
- io.replace("Makefile", "bash_compdir ?= /usr/share", "bash_compdir ?= " .. package:installdir("share"), {plain = true})
|
|
|
- make.build(package, configs)
|
|
|
- os.vrunv("make", table.join("install", configs))
|
|
|
- os.cd("../../lib/bpf")
|
|
|
- io.replace("Makefile", "prefix ?= /usr/local", "prefix ?= " .. package:installdir(), {plain = true})
|
|
|
- if not package:config("shared") then
|
|
|
- io.replace("Makefile", "LIB_TARGET%s-=.-\n", "LIB_TARGET = libbpf.a\n")
|
|
|
- io.replace("Makefile", "LIB_FILE%s-=.-\n", "LIB_FILE = libbpf.a\n")
|
|
|
- io.replace("Makefile", "all_cmd: $(CMD_TARGETS) check", "all_cmd: $(CMD_TARGETS)", {plain = true})
|
|
|
- end
|
|
|
- os.vrunv("make", table.join("install", configs))
|
|
|
- os.cd(oldir)
|
|
|
- end
|
|
|
end)
|
|
|
|
|
|
on_test(function (package)
|
|
|
- if package:config("bpf") then
|
|
|
- assert(package:has_cfuncs("bpf_object__open", {includes = "bpf/libbpf.h"}))
|
|
|
- os.vrun("bpftool --version")
|
|
|
+ for _, name in ipairs(modules) do
|
|
|
+ if package:config(name) then
|
|
|
+ import("modules." .. name).test(package)
|
|
|
+ end
|
|
|
end
|
|
|
end)
|