-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Leonardo Di Donato <[email protected]>
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
set_xmakever("2.6.1") -- Minimum version to compile BPF source correctly | ||
|
||
-- options | ||
option("require-bpftool", {showmenu = true, default = false, description = "require bpftool package"}) | ||
|
||
--- run `xmake f --require-bpftool=y` to pull bpftool from xmake-repo repo rather than using the system one | ||
if has_config("require-bpftool") then | ||
add_requires("linux-tools", {configs = {bpftool = true}}) | ||
add_packages("linux-tools") | ||
end | ||
|
||
-- bpftool | ||
local bpftool = path.join("tools", "bpftool") | ||
target("bpftool") | ||
set_kind("phony") | ||
on_config(function (target) | ||
if os.tryrm(bpftool) then | ||
if has_config("require-bpftool") then | ||
local target = path.join(target:pkg("linux-tools"):installdir(), "sbin", "bpftool") | ||
os.ln(target, bpftool) | ||
else | ||
import("lib.detect.find_program") | ||
local sys_bpftool = find_program("bpftool") | ||
if sys_bpftool == nil then | ||
os.raise("cannot find bpftool in system") | ||
end | ||
os.ln(sys_bpftool, bpftool) | ||
end | ||
import("core.base.option") | ||
if option.get("verbose") then | ||
import("core.base.json") | ||
local vers = os.iorunv(bpftool, {"version", "-j"}) | ||
print(json.decode(vers)) | ||
end | ||
end | ||
end) | ||
before_build(function(target) | ||
import("utils.progress") | ||
progress.show(10, "${color.build.object}providing.bpftool %s", bpftool) | ||
end) | ||
on_clean(function (target) | ||
os.tryrm(bpftool) | ||
end) |