diff options
| author | ruki <[email protected]> | 2024-05-05 20:35:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-05-05 20:35:45 +0800 |
| commit | fe2b2cd36b20ec41fd0569ff387c58e822fa1b56 (patch) | |
| tree | 3e664178191e783ce820e624d45eaf320d27b472 | |
| parent | 4463ddbfdf57b712a577c63a4e4276117e0cdc31 (diff) | |
improve to check targets
| -rw-r--r-- | xmake/actions/config/main.lua | 18 | ||||
| -rw-r--r-- | xmake/core/base/private/instance_deps.lua | 24 |
2 files changed, 23 insertions, 19 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index b35bd08e6..327094039 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -101,20 +101,24 @@ function _need_check(changed) end -- check target -function _check_target(target) - for _, depname in ipairs(target:get("deps")) do - assert(depname ~= target:name(), "the target(%s) cannot depend self!", depname) - local deptarget = project.target(depname) - assert(deptarget, "unknown target(%s) for %s.deps!", depname, target:name()) - _check_target(deptarget) +function _check_target(target, checked_targets) + if not checked_targets[target:name()] then + checked_targets[target:name()] = target + for _, depname in ipairs(target:get("deps")) do + assert(depname ~= target:name(), "the target(%s) cannot depend self!", depname) + local deptarget = project.target(depname) + assert(deptarget, "unknown target(%s) for %s.deps!", depname, target:name()) + _check_target(deptarget, checked_targets) + end end end -- check targets function _check_targets() assert(not project.is_loaded(), "project and targets may have been loaded early!") + local checked_targets = {} for _, target in pairs(project.targets()) do - _check_target(target) + _check_target(target, checked_targets) end end diff --git a/xmake/core/base/private/instance_deps.lua b/xmake/core/base/private/instance_deps.lua index 02634695b..17145ac6f 100644 --- a/xmake/core/base/private/instance_deps.lua +++ b/xmake/core/base/private/instance_deps.lua @@ -52,20 +52,20 @@ function instance_deps.load_deps(instance, instances, deps, orderdeps, depspath, continue_walk = walkdep(instance, depinst) end if continue_walk then - local depspath_sub - if depspath then - for idx, name in ipairs(depspath) do - if name == depname then - local circular_deps = table.slice(depspath, idx) - table.insert(circular_deps, depname) - os.raise("circular dependency(%s) detected!", table.concat(circular_deps, ", ")) - end - end - depspath_sub = table.join(depspath, depname) - end - instance_deps.load_deps(depinst, instances, deps, orderdeps, depspath_sub, walkdep) if not deps[depname] then deps[depname] = depinst + local depspath_sub + if depspath then + for idx, name in ipairs(depspath) do + if name == depname then + local circular_deps = table.slice(depspath, idx) + table.insert(circular_deps, depname) + os.raise("circular dependency(%s) detected!", table.concat(circular_deps, ", ")) + end + end + depspath_sub = table.join(depspath, depname) + end + instance_deps.load_deps(depinst, instances, deps, orderdeps, depspath_sub, walkdep) table.insert(orderdeps, depinst) end end |
