From 4463ddbfdf57b712a577c63a4e4276117e0cdc31 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 5 May 2024 19:05:25 +0800 Subject: improve to sort instances --- xmake/core/base/private/instance_deps.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/xmake/core/base/private/instance_deps.lua b/xmake/core/base/private/instance_deps.lua index 2f5c52a7c..02634695b 100644 --- a/xmake/core/base/private/instance_deps.lua +++ b/xmake/core/base/private/instance_deps.lua @@ -75,25 +75,25 @@ end -- sort the given instance with deps function instance_deps._sort_instance(instance, instances, orderinstances, instancerefs, depspath) - for _, depname in ipairs(table.wrap(instance:get("deps"))) do - local depinst = instances[depname] - if depinst 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, ", ")) + if not instancerefs[instance:name()] then + instancerefs[instance:name()] = true + for _, depname in ipairs(table.wrap(instance:get("deps"))) do + local depinst = instances[depname] + if depinst 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 - depspath_sub = table.join(depspath, depname) + instance_deps._sort_instance(depinst, instances, orderinstances, instancerefs, depspath_sub) end - instance_deps._sort_instance(depinst, instances, orderinstances, instancerefs, depspath_sub) end - end - if not instancerefs[instance:name()] then - instancerefs[instance:name()] = true table.insert(orderinstances, instance) end end -- cgit v1.3.1