diff options
| author | ruki <[email protected]> | 2023-04-09 22:44:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-04-09 22:44:37 +0800 |
| commit | 5b68e4d38230e0f89a97047ab916b6a9c2bbe942 (patch) | |
| tree | d62572e1c59a464ac7a0ed9d923c52da11e75731 /xmake/core | |
| parent | dde674a22790c9a055782baa59550b5824bccb79 (diff) | |
load targets to fix qt/env #3614
Diffstat (limited to 'xmake/core')
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index e90423ca2..f43590bb3 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -124,6 +124,78 @@ function sandbox_core_project.check_options() end end +-- config target +function sandbox_core_project._config_target(target) + for _, rule in ipairs(table.wrap(target:orderules())) do + local on_config = rule:script("config") + if on_config then + on_config(target) + end + end + local on_config = target:script("config") + if on_config then + on_config(target) + end +end + +-- config targets +function sandbox_core_project._config_targets() + for _, target in ipairs(table.wrap(project.ordertargets())) do + if target:is_enabled() then + sandbox_core_project._config_target(target) + end + end +end + +-- load rules in the required packages for target +function sandbox_core_project._load_package_rules_for_target(target) + for _, rulename in ipairs(table.wrap(target:get("rules"))) do + local packagename = rulename:match("@(.-)/") + if packagename then + local pkginfo = project.required_package(packagename) + if pkginfo then + local r = pkginfo:rule(rulename) + if r then + target:rule_add(r) + for _, dep in pairs(table.wrap(r:deps())) do + target:rule_add(dep) + end + end + end + end + end +end + +-- load rules in the required packages for targets +-- @see https://github.com/xmake-io/xmake/issues/2374 +-- +-- @code +-- add_requires("zlib", {system = false}) +-- target("test") +-- set_kind("binary") +-- add_files("src/*.cpp") +-- add_packages("zlib") +-- add_rules("@zlib/test") +-- @endcode +-- +function sandbox_core_project._load_package_rules_for_targets() + for _, target in ipairs(table.wrap(project.ordertargets())) do + if target:is_enabled() then + sandbox_core_project._load_package_rules_for_target(target) + end + end +end + +-- load project targets +function sandbox_core_project.load_targets() + + -- load package rules for targets + sandbox_core_project._load_package_rules_for_targets() + + -- config targets + sandbox_core_project._config_targets() +end + -- get the filelock of the whole project directory function sandbox_core_project.filelock() local filelock, errors = project.filelock() |
