summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-11 10:32:32 +0800
committerruki <[email protected]>2021-12-11 10:32:32 +0800
commit990712a20eb2f54d01113e85ae7ce0ef13bf0363 (patch)
treea0b89a4b86a67f0f9310c9e2d32e9afca42940e3
parent93f860b16f91d46b703840d81fb1fc57904b4ead (diff)
fix basename for kbuild
-rw-r--r--xmake/core/project/target.lua11
-rw-r--r--xmake/rules/platform/linux/driver/driver_modules.lua5
2 files changed, 9 insertions, 7 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index cb470a3c8..07327362d 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -398,6 +398,11 @@ function _instance:extraconf(name, item, key)
return self._INFO:extraconf(name, item, key)
end
+-- set the extra configuration
+function _instance:extraconf_set(name, item, key, value)
+ self._INFO:extraconf_set(name, item, key, value)
+end
+
-- get user private data
function _instance:data(name)
return self._DATA and self._DATA[name]
@@ -1239,14 +1244,8 @@ end
-- set the config info to the given source file
function _instance:fileconfig_set(sourcefile, info)
-
- -- get files config
local filesconfig = self._FILESCONFIG or {}
-
- -- set config info
filesconfig[sourcefile] = info
-
- -- update files config
self._FILESCONFIG = filesconfig
end
diff --git a/xmake/rules/platform/linux/driver/driver_modules.lua b/xmake/rules/platform/linux/driver/driver_modules.lua
index e3aef8c55..230a190b3 100644
--- a/xmake/rules/platform/linux/driver/driver_modules.lua
+++ b/xmake/rules/platform/linux/driver/driver_modules.lua
@@ -133,7 +133,10 @@ function load(target)
-- add compilation flags
target:set("policy", "check.auto_ignore_flags", false)
target:add("defines", "__KERNEL__", "MODULE", "CC_USING_FENTRY")
- target:add("defines", "KBUILD_BASENAME=\"" .. target:name() .. "\"", "KBUILD_MODNAME=\"" .. target:name() .. "\"") -- TODO
+ target:add("defines", "KBUILD_MODNAME=\"" .. target:name() .. "\"")
+ for _, sourcefile in ipairs(target:sourcefiles()) do
+ target:fileconfig_set(sourcefile, {defines = "KBUILD_BASENAME=\"" .. path.basename(sourcefile) .. "\""})
+ end
if target:is_arch("x86_64", "i386") then
target:add("defines", "CONFIG_X86_X32_ABI")
end