summaryrefslogtreecommitdiff
path: root/xmake/core/project/project.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-03 00:55:01 +0800
committerruki <[email protected]>2025-12-03 00:55:01 +0800
commit80a93765f31748434537a5a91fb10e8338ed4565 (patch)
tree26cb6dd452c5a107d7b3714a1536a8a8bb2d2c3e /xmake/core/project/project.lua
parentd326ec3fd56a0c13c7828ff70fa3cc6f88929123 (diff)
add project.policy_set
Diffstat (limited to 'xmake/core/project/project.lua')
-rw-r--r--xmake/core/project/project.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index f10cdc894..43b825583 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -964,6 +964,24 @@ function project.policy(name)
return policy.check(name, policies and policies[name])
end
+-- set the project policy in memory
+function project.policy_set(name, value)
+ -- get current policies from cache or initialize
+ local policies = project._memcache():get("policies")
+ if not policies then
+ -- force initialization by calling policy() once
+ project.policy(name)
+ policies = project._memcache():get("policies")
+ end
+ policies = policies or {}
+
+ -- set the policy value
+ policies[name] = value
+
+ -- update cache
+ project._memcache():set("policies", policies)
+end
+
-- project has been loaded?
function project.is_loaded()
return project._memcache():get("targets_loaded")