summaryrefslogtreecommitdiff
path: root/xmake/rules/platform/linux/driver/driver_modules.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-11 00:41:41 +0800
committerruki <[email protected]>2021-12-11 00:41:41 +0800
commit349a22942e600821aa72424bbfa58f021357b1cf (patch)
tree5df337d32f9e4dd8464becb82771dc762a04a8a2 /xmake/rules/platform/linux/driver/driver_modules.lua
parent7908560287910061c942125db6f76884aa2e51b2 (diff)
improve module tests
Diffstat (limited to 'xmake/rules/platform/linux/driver/driver_modules.lua')
-rw-r--r--xmake/rules/platform/linux/driver/driver_modules.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/xmake/rules/platform/linux/driver/driver_modules.lua b/xmake/rules/platform/linux/driver/driver_modules.lua
index a94319e8e..a4a4f8691 100644
--- a/xmake/rules/platform/linux/driver/driver_modules.lua
+++ b/xmake/rules/platform/linux/driver/driver_modules.lua
@@ -18,6 +18,12 @@
-- @file driver_modules.lua
--
+-- imports
+import("core.base.option")
+import("core.project.depend")
+import("utils.progress")
+import("private.tools.ccache")
+
-- get linux-headers sdk
function _get_linux_headers_sdk(target)
local linux_headers = assert(target:pkg("linux-headers"), "please add `add_requires(\"linux-headers\", {configs = {driver_modules = true}})` and `add_packages(\"linux-headers\")` to the given target!")
@@ -96,5 +102,32 @@ function load(target)
target:add("cflags", "--param asan-globals=1", "--param asan-instrumentation-with-call-threshold=0", "--param asan-stack=1", "--param asan-instrument-allocas=1")
end
+--[[
+function after_build_file(target, sourcefile, opt)
+
+ -- get modepost
+ local modpost
+ local linux_headers = target:data("linux.driver.linux_headers")
+ if linux_headers then
+ modpost = path.join(linux_headers.sdkdir, "scripts", "mod", "modpost")
+ end
+ assert(modpost and os.isfile(modpost), "modpost not found!")
+
+ -- compile .mod.c file
+ local objectfile = target:objectfile(sourcefile)
+ local modfile = objectfile:gsub("%.o$", ".mod")
+ local modfile_c = objectfile:gsub("%.o$", ".mod.c")
+ local modfile_o = objectfile:gsub("%.o$", ".mod.o")
+ local dependfile = target:dependfile(modfile_o)
+ local exists_ccache = ccache.exists()
+ depend.on_changed(function ()
+ progress.show(opt.progress, "${color.build.object}%scompiling.mod.$(mode) %s", exists_ccache and "ccache " or "", modfile_c)
+ os.vrunv(modpost, {"-m", "-a", "-o", })
+ end, {dependfile = dependfile, files = {sourcefile}})
+
+ -- echo build/.objs/hello/linux/x86_64/release/src/hello.c.o |
+ -- scripts/mod/modpost -m -a -o /tmp/Module.symvers -e -N -T -
+end]]
+
function link(target, opt)
end