From 59052f6aa1f980e1ae7b2da4b930250382fa25f9 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 31 Dec 2023 01:20:18 +0800 Subject: support .def on mingw --- xmake/rules/platform/windows/def/xmake.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua index 545d61fd1..d796402cd 100644 --- a/xmake/rules/platform/windows/def/xmake.lua +++ b/xmake/rules/platform/windows/def/xmake.lua @@ -21,16 +21,20 @@ -- add *.def for windows/dll rule("platform.windows.def") set_extensions(".def") - on_config("windows", function (target) + on_config("windows", "mingw", function (target) if not target:is_shared() then return end - if target:has_tool("sh", "link") then - local sourcebatch = target:sourcebatches()["platform.windows.def"] - if sourcebatch then - for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + + local sourcebatch = target:sourcebatches()["platform.windows.def"] + if sourcebatch then + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + if target:is_plat("windows") then target:add("shflags", "/def:" .. path.translate(sourcefile), {force = true}) break; + elseif target:is_plat("mingw") then + target:add("shflags", path.translate(sourcefile), {force = true}) + break; end end end -- cgit v1.3.1 From 21729b8a9abd072d992e2cb1d046ea0c50534673 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 31 Dec 2023 16:08:32 +0800 Subject: improve xmake.lua --- xmake/rules/platform/windows/def/xmake.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua index d796402cd..3ff6415ed 100644 --- a/xmake/rules/platform/windows/def/xmake.lua +++ b/xmake/rules/platform/windows/def/xmake.lua @@ -26,13 +26,18 @@ rule("platform.windows.def") return end - local sourcebatch = target:sourcebatches()["platform.windows.def"] - if sourcebatch then - for _, sourcefile in ipairs(sourcebatch.sourcefiles) do - if target:is_plat("windows") then + if target:is_plat("windows") and target:has_tool("sh", "link") then + local sourcebatch = target:sourcebatches()["platform.windows.def"] + if sourcebatch then + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do target:add("shflags", "/def:" .. path.translate(sourcefile), {force = true}) break; - elseif target:is_plat("mingw") then + end + end + elseif target:is_plat("mingw") then + local sourcebatch = target:sourcebatches()["platform.windows.def"] + if sourcebatch then + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do target:add("shflags", path.translate(sourcefile), {force = true}) break; end -- cgit v1.3.1 From 7295f8ff7f8b4df195f64155cd0ba2aa39793090 Mon Sep 17 00:00:00 2001 From: star9029 Date: Mon, 1 Jan 2024 23:42:36 +0800 Subject: improve xmake.lua --- xmake/rules/platform/windows/def/xmake.lua | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua index 3ff6415ed..8aaac52d6 100644 --- a/xmake/rules/platform/windows/def/xmake.lua +++ b/xmake/rules/platform/windows/def/xmake.lua @@ -26,21 +26,19 @@ rule("platform.windows.def") return end - if target:is_plat("windows") and target:has_tool("sh", "link") then - local sourcebatch = target:sourcebatches()["platform.windows.def"] - if sourcebatch then - for _, sourcefile in ipairs(sourcebatch.sourcefiles) do - target:add("shflags", "/def:" .. path.translate(sourcefile), {force = true}) - break; - end - end - elseif target:is_plat("mingw") then - local sourcebatch = target:sourcebatches()["platform.windows.def"] - if sourcebatch then - for _, sourcefile in ipairs(sourcebatch.sourcefiles) do - target:add("shflags", path.translate(sourcefile), {force = true}) - break; + if target:is_plat("windows") and (not target:has_tool("sh", "link")) 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 end + target:add("shflags", flag, {force = true}) + break; end end end) -- cgit v1.3.1