From e581f5c19ad1feeed70e26d294c114c48ade00da Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 5 Aug 2022 00:40:16 +0800 Subject: optimize to get headerunits info --- xmake/rules/c++/modules/xmake.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'xmake/rules/c++/modules/xmake.lua') diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index 9a7599358..a1d6fdca4 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -89,20 +89,18 @@ rule("c++.build.modules.builder") sourcebatch.dependfiles = {} common.patch_sourcebatch(target, sourcebatch, opt) - -- get headerunits info, TODO maybe need optimize it + -- get headerunits info local headerunits local modules = target:data("cxx.modules") for _, objectfile in ipairs(sourcebatch.objectfiles) do - for obj, m in pairs(modules) do - if obj == objectfile then - for name, r in pairs(m.requires) do - if r.method ~= "by-name" then - headerunits = headerunits or {} - local unittype = r.method == "include-angle" and ":angle" or ":quote" - table.append(headerunits, {name = name, path = r.path, type = unittype, stl = stl_headers.is_stl_header(name)}) - end + local m = modules[objectfile] + if m then + for name, r in pairs(m.requires) do + if r.method ~= "by-name" then + headerunits = headerunits or {} + local unittype = r.method == "include-angle" and ":angle" or ":quote" + table.insert(headerunits, {name = name, path = r.path, type = unittype, stl = stl_headers.is_stl_header(name)}) end - break end end end -- cgit v1.3.1