summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-06-09 22:21:20 +0800
committerGitHub <[email protected]>2025-06-09 22:21:20 +0800
commit773407f7df280a5fc50d2aa6419875297e711bb2 (patch)
treee1ecea6ef05595034d33665f11831088165b7251
parentca1d8f7cf03d0e7e4cb58ac23e5b56a5c334494c (diff)
parent487397fd5424b482af1c4711e97658d8409c91d3 (diff)
Merge pull request #6533 from xmake-io/nasm
Improve sourcekind for add_files
-rw-r--r--xmake/core/project/project.lua3
-rw-r--r--xmake/core/project/target.lua6
2 files changed, 6 insertions, 3 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 5a069f644..043ff3cfa 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -417,7 +417,8 @@ function project._load_targets()
for _, sourcefile in ipairs(table.wrap(t:get("files"))) do
local extension = path.extension((sourcefile:gsub("|.*$", "")))
if not extensions[extension] then
- local lang = language.load_ex(extension)
+ local sourcekind = t:extraconf("files", sourcefile, "sourcekind")
+ local lang = sourcekind and language.load_sk(sourcekind) or language.load_ex(extension)
if lang and lang:rules() then
table.join2(rulenames, lang:rules())
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 6f4ad4d89..eb29ed952 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -201,7 +201,8 @@ function _instance:_update_filerules()
for _, sourcefile in ipairs(table.wrap(self:get("files"))) do
local extension = path.extension((sourcefile:gsub("|.*$", "")))
if not extensions[extension] then
- local lang = language.load_ex(extension)
+ local sourcekind = self:extraconf("files", sourcefile, "sourcekind")
+ local lang = sourcekind and language.load_sk(sourcekind) or language.load_ex(extension)
if lang and lang:rules() then
table.join2(rulenames, lang:rules())
end
@@ -1859,7 +1860,8 @@ function _instance:filerules(sourcefile)
local filename = path.filename(sourcefile):lower()
for _, r in ipairs(table.wrap(key2rules[path.extension(filename, 2)] or
key2rules[path.extension(filename)] or
- key2rules[self:sourcekind_of(filename)])) do
+ key2rules[self:sourcekind_of(filename)] or
+ key2rules[fileconfig and fileconfig.sourcekind])) do -- add_files("*.nasm", {sourcekind = "asm"})
if self:extraconf("rules", r:name(), "override") then
table.insert(rules_override, r)
else