summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-04 17:12:54 +0800
committerruki <[email protected]>2025-10-04 17:12:54 +0800
commitb884a432cad83ad43c8ecf130efa467533698bab (patch)
treea0186bac2e60a08d88aad209bea56c2e1ee55278
parent96b9f75afe79991717782142dd79d1e6d96a18c4 (diff)
fix rule enabled/disabled
-rw-r--r--xmake/core/project/rule.lua6
-rw-r--r--xmake/core/project/target.lua8
-rw-r--r--xmake/modules/private/action/build/target.lua4
3 files changed, 9 insertions, 9 deletions
diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua
index a99a7c503..c11c6e246 100644
--- a/xmake/core/project/rule.lua
+++ b/xmake/core/project/rule.lua
@@ -147,11 +147,6 @@ function _instance:kind()
return self:get("kind") or "target"
end
--- is enabled?
-function _instance:is_enabled()
- return self:get("enabled") ~= false
-end
-
-- get the given dependent rule
function _instance:dep(name)
local deps = self:deps()
@@ -293,7 +288,6 @@ function rule.apis()
"rule.set_extensions"
, "rule.set_sourcekinds"
, "rule.set_kind"
- , "rule.set_enabled"
-- rule.add_xxx
, "rule.add_deps"
, "rule.add_imports"
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 4ffa971e6..2f69abdd8 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1188,12 +1188,18 @@ end
function _instance:rule_enable(name, enabled)
local ruleinst = self:rule(name)
if ruleinst then
- ruleinst:set("enabled", enabled)
+ self:data_set("__rule_enabled." .. name, enabled)
else
utils.warning("target(%s): rule(%s) not found", self:name(), name)
end
end
+-- the given rule is enabled or disabled?
+function _instance:rule_is_enabled(name)
+ local enabled = self:data("__rule_enabled." .. name)
+ return enabled ~= false
+end
+
-- is phony target?
function _instance:is_phony()
local targetkind = self:kind()
diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua
index 81153204c..c8a7987d5 100644
--- a/xmake/modules/private/action/build/target.lua
+++ b/xmake/modules/private/action/build/target.lua
@@ -235,7 +235,7 @@ function add_targetjobs_with_stage(jobgraph, target, stage, opt)
local instances = {target}
for _, ruleinst in ipairs(target:orderules()) do
-- we only ignore some builtin rules, so we need not to use fullname.
- if ruleinst:is_enabled() and (not ignored_rules or not ignored_rules:has(ruleinst:name())) then
+ if target:rule_is_enabled(ruleinst:fullname()) and (not ignored_rules or not ignored_rules:has(ruleinst:name())) then
table.insert(instances, ruleinst)
end
end
@@ -572,7 +572,7 @@ function add_filejobs_with_stage(jobgraph, target, sourcebatches, stage, opt)
if rulename then
-- we only ignore some builtin rules, so we need not to use fullname.
local ruleinst = rule_utils.get_rule(target, rulename)
- if ruleinst:is_enabled() and (not ignored_rules or not ignored_rules:has(ruleinst:name())) then
+ if target:rule_is_enabled(ruleinst:fullname()) and (not ignored_rules or not ignored_rules:has(ruleinst:name())) then
sourcebatches_map[ruleinst] = sourcebatch
-- avoid duplicate scripts being called twice in the target,
-- we just build sourcebatch with on_build_files scripts