diff options
| author | ruki <[email protected]> | 2021-03-04 00:35:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-03-04 00:35:18 +0800 |
| commit | 9920f184b0bdb4e880a54d923eb39d8b2be0bd2f (patch) | |
| tree | 6bdaa7400be3f6bd3951ec7cb36f389f295ded56 | |
| parent | 5fc041587d6f683181ba754bb221336dc076e561 (diff) | |
improve def/manifest
| -rw-r--r-- | xmake/rules/platform/windows/def/xmake.lua | 10 | ||||
| -rw-r--r-- | xmake/rules/platform/windows/manifest/xmake.lua | 16 |
2 files changed, 21 insertions, 5 deletions
diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua index e89050a0f..b649377a5 100644 --- a/xmake/rules/platform/windows/def/xmake.lua +++ b/xmake/rules/platform/windows/def/xmake.lua @@ -21,10 +21,16 @@ -- add *.def for windows/dll rule("platform.windows.def") set_extensions(".def") - before_build_file("windows", function (target, sourcefile) + after_load("windows", function (target) local _, toolname = target:tool("ld") if toolname == "link" then - target:add("shflags", "/def:" .. path.translate(sourcefile), {force = true}) + for _, sourcebatch in pairs(target:sourcebatches()) do + if sourcebatch.rulename == "platform.windows.def" then + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + target:add("shflags", "/def:" .. path.translate(sourcefile), {force = true}) + end + end + end end end) diff --git a/xmake/rules/platform/windows/manifest/xmake.lua b/xmake/rules/platform/windows/manifest/xmake.lua index 36ddc2a0f..6d3e4c0d6 100644 --- a/xmake/rules/platform/windows/manifest/xmake.lua +++ b/xmake/rules/platform/windows/manifest/xmake.lua @@ -22,10 +22,20 @@ -- https://github.com/xmake-io/xmake/issues/1241 rule("platform.windows.manifest") set_extensions(".manifest") - before_build_file("windows", function (target, sourcefile) + after_load("windows", function (target) local _, toolname = target:tool("ld") if toolname == "link" then - target:add("ldflags", "/manifest", "/ManifestFile:" .. path.translate(sourcefile), {force = true}) + local manifest = false + for _, sourcebatch in pairs(target:sourcebatches()) do + if sourcebatch.rulename == "platform.windows.manifest" then + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + target:add("ldflags", "/ManifestFile:" .. path.translate(sourcefile), {force = true}) + manifest = true + end + end + end + if manifest then + target:add("ldflags", "/manifest", {force = true}) + end end end) - |
