summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-07 23:37:48 +0800
committerruki <[email protected]>2023-11-07 23:37:48 +0800
commit15fbe183b3508313ec28e23006db5cf6f2088da6 (patch)
tree202004e6f5e4cae3a650dd4af226972d8313c9be
parentcbdfb8581392eb426dd7abce07b16308d6ba5a25 (diff)
add uac policy
-rw-r--r--xmake/core/project/policy.lua4
-rw-r--r--xmake/rules/platform/windows/manifest/xmake.lua12
2 files changed, 16 insertions, 0 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index aa8e9ef9d..c0bf0e4e1 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -78,6 +78,10 @@ function policy.policies()
["build.c++.gcc.modules.cxx11abi"] = {description = "Force to enable new cxx11 abi in C++ modules for gcc.", type = "boolean"},
-- Enable cuda device link
["build.cuda.devlink"] = {description = "Enable Cuda devlink.", type = "boolean"},
+ -- Enable windows UAC and set level, e.g. invoker, admin, highest
+ ["windows.manifest.uac"] = {description = "Enable windows manifest UAC.", type = "string"},
+ -- Enable ui access for windows UAC
+ ["windows.manifest.uac.ui"] = {description = "Enable windows manifest UAC.", type = "boolean"},
-- Automatically build before running
["run.autobuild"] = {description = "Automatically build before running.", type = "boolean"},
-- Preprocessor configuration for ccache/distcc, we can disable linemarkers to speed up preprocess
diff --git a/xmake/rules/platform/windows/manifest/xmake.lua b/xmake/rules/platform/windows/manifest/xmake.lua
index 112a93841..40c99fc67 100644
--- a/xmake/rules/platform/windows/manifest/xmake.lua
+++ b/xmake/rules/platform/windows/manifest/xmake.lua
@@ -48,6 +48,18 @@ rule("platform.windows.manifest")
target:add("ldflags", "/manifestuac:no", {force = true})
end
target:add("ldflags", "/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", {("/manifestuac:Level='%s' uiAccess='%s'"):format(level_maps[level], ui)}, {force = true, expand = false})
+ end
end
end
end)