summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-04 12:11:00 +0800
committerruki <[email protected]>2025-10-04 12:11:00 +0800
commit3f746c3fe8c36431d2fca3ca11cce6c1b8ce116b (patch)
treef78dc7b8b4db27a46d57aa67f346a0ebb445a124
parent6fd014681461a19290d66ae5a3b97332baf2f841 (diff)
decrease rule jobs in jobgraph
-rw-r--r--xmake/core/project/rule.lua6
-rw-r--r--xmake/core/project/target.lua10
-rw-r--r--xmake/modules/private/action/build/target.lua5
-rw-r--r--xmake/rules/c++/modules/config.lua3
-rw-r--r--xmake/rules/linker/soname/xmake.lua8
-rw-r--r--xmake/rules/utils/merge_archive/xmake.lua2
-rw-r--r--xmake/rules/utils/symbols/extract/xmake.lua5
7 files changed, 33 insertions, 6 deletions
diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua
index c11c6e246..a99a7c503 100644
--- a/xmake/core/project/rule.lua
+++ b/xmake/core/project/rule.lua
@@ -147,6 +147,11 @@ 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()
@@ -288,6 +293,7 @@ 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 3839eb01f..4ffa971e6 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1184,6 +1184,16 @@ function _instance:rule_add(r)
self._ORDERULES = nil
end
+-- enable or disable rule
+function _instance:rule_enable(name, enabled)
+ local ruleinst = self:rule(name)
+ if ruleinst then
+ ruleinst:set("enabled", enabled)
+ else
+ utils.warning("target(%s): rule(%s) not found", self:name(), name)
+ end
+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 6c651b68e..81153204c 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 not ignored_rules or not ignored_rules:has(ruleinst:name()) then
+ if ruleinst:is_enabled() and (not ignored_rules or not ignored_rules:has(ruleinst:name())) then
table.insert(instances, ruleinst)
end
end
@@ -262,6 +262,7 @@ function add_targetjobs_with_stage(jobgraph, target, stage, opt)
has_script = true
end
end)
+
-- if custom target.on_build/prepare exists, we need to ignore all scripts in rules
if has_script and instance == target and stage == "" then
break
@@ -571,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 not ignored_rules or not ignored_rules:has(ruleinst:name()) then
+ if ruleinst:is_enabled() 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
diff --git a/xmake/rules/c++/modules/config.lua b/xmake/rules/c++/modules/config.lua
index 30f2f2680..25d85bf0e 100644
--- a/xmake/rules/c++/modules/config.lua
+++ b/xmake/rules/c++/modules/config.lua
@@ -86,6 +86,9 @@ function main(target)
end
end
end
+ else
+ target:rule_enable("c++.build.modules.scanner", false)
+ target:rule_enable("c++.build.modules.builder", false)
end
end
diff --git a/xmake/rules/linker/soname/xmake.lua b/xmake/rules/linker/soname/xmake.lua
index 9f4da3e6a..16cc4271d 100644
--- a/xmake/rules/linker/soname/xmake.lua
+++ b/xmake/rules/linker/soname/xmake.lua
@@ -20,6 +20,7 @@
rule("linker.soname")
on_config(function (target)
+ local enabled = false
local soname = target:soname()
if target:is_shared() and soname then
if target:has_tool("sh", "gcc", "gxx", "clang", "clangxx") then
@@ -28,15 +29,18 @@ rule("linker.soname")
else
target:add("shflags", "-Wl,-soname," .. soname, {force = true})
end
- target:data_set("soname.enabled", true)
+ enabled = true
end
end
+ if not enabled then
+ target:rule_enable("linker.soname", false)
+ end
end)
after_link(function (target)
import("core.project.depend")
local soname = target:soname()
- if target:is_shared() and soname and target:data("soname.enabled") then
+ if target:is_shared() and soname then
local version = target:version()
local filename = target:filename()
local extension = path.extension(filename)
diff --git a/xmake/rules/utils/merge_archive/xmake.lua b/xmake/rules/utils/merge_archive/xmake.lua
index 20ef3c264..e6469d5cd 100644
--- a/xmake/rules/utils/merge_archive/xmake.lua
+++ b/xmake/rules/utils/merge_archive/xmake.lua
@@ -31,6 +31,8 @@ rule("utils.merge.archive")
dep:data_set("inherit.links.deplink", false)
end
end
+ else
+ target:rule_enable("utils.merge.archive", false)
end
end)
on_build_files(function (target, sourcebatch, opt)
diff --git a/xmake/rules/utils/symbols/extract/xmake.lua b/xmake/rules/utils/symbols/extract/xmake.lua
index 0cc8c9c97..b9fd816eb 100644
--- a/xmake/rules/utils/symbols/extract/xmake.lua
+++ b/xmake/rules/utils/symbols/extract/xmake.lua
@@ -20,8 +20,7 @@
-- define rule: utils.symbols.extract
rule("utils.symbols.extract")
- before_link(function(target)
- import("core.platform.platform")
+ after_config(function(target)
-- need generate symbols?
local strip = target:get("strip")
@@ -32,6 +31,8 @@ rule("utils.symbols.extract")
target:data_set("utils.symbols.extract", true)
target:set("strip", "none") -- disable strip in link stage, because we need to run separate strip commands
target:data_set("strip.origin", strip)
+ else
+ target:rule_enable("utils.symbols.extract", false)
end
end)
after_link(function (target, opt)