summaryrefslogtreecommitdiff
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
parentd326ec3fd56a0c13c7828ff70fa3cc6f88929123 (diff)
add project.policy_set
-rw-r--r--xmake/core/project/project.lua18
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua1
-rw-r--r--xmake/modules/private/check/checkers/syntax.lua9
3 files changed, 23 insertions, 5 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")
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua
index 4a191576c..8a808e7da 100644
--- a/xmake/core/sandbox/modules/import/core/project/project.lua
+++ b/xmake/core/sandbox/modules/import/core/project/project.lua
@@ -67,6 +67,7 @@ sandbox_core_project.requireconfs_str = project.requireconfs_str
sandbox_core_project.requireslock = project.requireslock
sandbox_core_project.requireslock_version = project.requireslock_version
sandbox_core_project.policy = project.policy
+sandbox_core_project.policy_set = project.policy_set
sandbox_core_project.tmpdir = project.tmpdir
sandbox_core_project.tmpfile = project.tmpfile
sandbox_core_project.is_loaded = project.is_loaded
diff --git a/xmake/modules/private/check/checkers/syntax.lua b/xmake/modules/private/check/checkers/syntax.lua
index 8696ac3ae..35ae9da3d 100644
--- a/xmake/modules/private/check/checkers/syntax.lua
+++ b/xmake/modules/private/check/checkers/syntax.lua
@@ -21,7 +21,6 @@
-- imports
import("core.base.option")
import("core.base.task")
-import("core.project.config")
import("core.project.project")
import("actions.build.build_files", {rootdir = os.programdir(), alias = "build_files"})
import("actions.build.build", {rootdir = os.programdir(), alias = "build"})
@@ -129,18 +128,18 @@ function main(argv)
-- lock the whole project
project.lock()
- -- enable syntax-only policy and disable ccache via config
- config.set("policies", "build.c++.syntax_only,build.ccache:n")
-
-- config it first
task.run("config", {}, {disable_dump = true})
+ -- enable syntax-only policy and disable ccache
+ project.policy_set("build.c++.syntax_only", true)
+ project.policy_set("build.ccache", false)
+
-- enter project directory
local oldir = os.cd(project.directory())
-- validate targets before checking
if _validate_targets(args) then
- -- do check
_check(args)
end