Skip to content

Commit a3818b0

Browse files
committed
xmake: add rule to get git description
Following CHERIoT-Platform/cheriot-rtos#527
1 parent e19c3b1 commit a3818b0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/xmake.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local netstackdir = os.scriptdir()
2+
13
option("IPv6")
24
set_default(true)
35
set_showmenu(true)
@@ -9,6 +11,25 @@ rule("cheriot.network-stack.ipv6")
911
target:add("defines", "CHERIOT_RTOS_OPTION_IPv6=" .. tostring(IPv6))
1012
end)
1113

14+
-- Rule for making network stack git revision information available to a build target.
15+
--
16+
-- See the RTOS's cheriot.define-rtos-git-description rule for details.
17+
local netstack_git_description = nil
18+
rule("cheriot.define-network-git-description")
19+
before_build_file(function(target, sourcefile, opt)
20+
netstack_git_description = netstack_git_description or try {
21+
function()
22+
return os.iorunv("git", {"-C", netstackdir, "describe", "--always", "--dirty"}):gsub("[\r\n]", "")
23+
end
24+
}
25+
netstack_git_description = netstack_git_description or "unknown"
26+
27+
local fileconfig = target:fileconfig(sourcefile) or {}
28+
fileconfig.defines = fileconfig.defines or {}
29+
table.insert(fileconfig.defines, ("CHERIOT_NETWORK_GIT_DESCRIPTION=%q"):format(netstack_git_description))
30+
target:fileconfig_set(sourcefile, fileconfig)
31+
end)
32+
1233
includes("tcpip",
1334
"netapi",
1435
"sntp",

0 commit comments

Comments
 (0)