summaryrefslogtreecommitdiff
path: root/xmake/rules/platform
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-10 22:43:54 +0800
committerruki <[email protected]>2025-10-10 22:43:54 +0800
commit264268baebd5a138734798e0f6e2afd171f9adae (patch)
tree40c93927765514ed36b167b13d7c1e3aa55306c8 /xmake/rules/platform
parent3a2c66848cab8f59b9c96b777ceadde7064cd38d (diff)
improve to export def rules for binary
Diffstat (limited to 'xmake/rules/platform')
-rw-r--r--xmake/rules/platform/windows/def/xmake.lua39
1 files changed, 19 insertions, 20 deletions
diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua
index 08279d90a..f7bd66ab2 100644
--- a/xmake/rules/platform/windows/def/xmake.lua
+++ b/xmake/rules/platform/windows/def/xmake.lua
@@ -22,28 +22,27 @@
rule("platform.windows.def")
set_extensions(".def")
on_config("windows", "mingw", function (target)
- if not target:is_shared() then
- return
- end
-
- if target:is_plat("windows") and (not target:has_tool("sh", "link", "clangxx")) then
- return
- end
-
- local sourcebatch = target:sourcebatches()["platform.windows.def"]
- if sourcebatch then
- for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- local flag = path.translate(sourcefile)
- if target:is_plat("windows") then
- flag = "/def:" .. flag
- if target:has_tool("sh", "clangxx") then
- flag = "-Wl," .. flag
+ if target:is_plat("windows") and (target:is_shared() or target:is_binary()) then
+ local sourcebatch = target:sourcebatches()["platform.windows.def"]
+ if sourcebatch then
+ -- https://github.com/xmake-io/xmake/pull/4901
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ local matched = false
+ local flag = path.translate(sourcefile)
+ if target:has_tool("ld", "link") then
+ flag = "/def:" .. flag
+ matched = true
+ elseif target:has_tool("ld", "clangxx") then
+ flag = "-Wl,/def:" .. flag
+ matched = true
+ end
+ if matched then
+ target:add("shflags", flag, {force = true})
+ target:add("ldflags", flag, {force = true})
+ target:data_add("linkdepfiles", sourcefile)
end
+ break
end
- -- https://github.com/xmake-io/xmake/pull/4901
- target:add("shflags", flag, {force = true})
- target:data_add("linkdepfiles", sourcefile)
- break;
end
end
end)