summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-07 16:50:25 +0800
committerGitHub <[email protected]>2023-11-07 16:50:25 +0800
commitf374224ff3a1641c86e0e0ca8bfcd906b4931bc3 (patch)
tree5be215ac8e9d260389cc11f158d9e27358eef6b2 /xmake/rules
parent0dfe01c36d154fdf6fd0b9db51763d59d6037638 (diff)
parent00500d01dc3457d2531aeda985089f941ed468a1 (diff)
Merge pull request #4369 from xmake-io/manifest
improve manifest
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/platform/windows/manifest/xmake.lua35
1 files changed, 32 insertions, 3 deletions
diff --git a/xmake/rules/platform/windows/manifest/xmake.lua b/xmake/rules/platform/windows/manifest/xmake.lua
index e791d9398..cb9979342 100644
--- a/xmake/rules/platform/windows/manifest/xmake.lua
+++ b/xmake/rules/platform/windows/manifest/xmake.lua
@@ -23,21 +23,50 @@
rule("platform.windows.manifest")
set_extensions(".manifest")
on_config("windows", function (target)
- if not target:is_binary() then
+ if not target:is_binary() and not target:is_shared() then
return
end
- if target:has_tool("ld", "link") then
+ if target:has_tool("ld", "link") or target:has_tool("sh", "link") then
local manifest = false
+ local uac = false
local sourcebatch = target:sourcebatches()["platform.windows.manifest"]
if sourcebatch then
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- target:add("ldflags", "/ManifestInput:" .. path.translate(sourcefile), {force = true})
+ target:add("ldflags", "/manifestinput:" .. path.translate(sourcefile), {force = true})
+ target:add("shflags", "/manifestinput:" .. path.translate(sourcefile), {force = true})
manifest = true
+ local content = io.readfile(sourcefile)
+ if content then
+ content = content:gsub("<!%-%-.-%-%->", "")
+ if content:find("requestedPrivileges", 1, true) then
+ uac = true
+ end
+ end
break
end
end
if manifest then
+ -- if manifest file is provided, we need disable default UAC manifest
+ -- @see https://github.com/xmake-io/xmake/pull/4362
+ if uac then
+ target:add("ldflags", "/manifestuac:no", {force = true})
+ end
+ target:add("shflags", "/manifestuac:no", {force = true})
+
target:add("ldflags", "/manifest:embed", {force = true})
+ target:add("shflags", "/manifest:embed", {force = true})
+ else
+ local level = target:policy("windows.manifest.uac")
+ if level then
+ local level_maps = {
+ invoker = "asInvoker",
+ admin = "requireAdministrator",
+ highest = "highestAvailable"
+ }
+ assert(level_maps[level], "unknown uac level %s, please set invoker, admin or highest", level)
+ local ui = target:policy("windows.manifest.uac.ui") or false
+ target:add("ldflags", "/manifest:embed", {("/manifestuac:Level='%s' uiAccess='%s'"):format(level_maps[level], ui)}, {force = true, expand = false})
+ end
end
end
end)