From 825ab605b940bcb7be693552112c6be68106e9d0 Mon Sep 17 00:00:00 2001 From: Shiffted Date: Sun, 29 Mar 2026 11:33:11 +0200 Subject: handle missing moduleinfo --- xmake/rules/c++/modules/support.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'xmake/rules/c++/modules/support.lua') diff --git a/xmake/rules/c++/modules/support.lua b/xmake/rules/c++/modules/support.lua index 0767c88af..1dd7625bb 100644 --- a/xmake/rules/c++/modules/support.lua +++ b/xmake/rules/c++/modules/support.lua @@ -281,15 +281,26 @@ end function load_moduleinfo(target, sourcefile) local reused, from = is_reused(target, sourcefile) local dependfile = reused and from:dependfile(sourcefile) or target:dependfile(sourcefile) - local moduleinfo - if os.isfile(dependfile) then + + local is_file = os.isfile(dependfile) + if is_file then local data = io.load(dependfile) if data then - moduleinfo = json.decode(data.moduleinfo) + local moduleinfo = json.decode(data.moduleinfo) moduleinfo.sourcefile = sourcefile + return moduleinfo end end - return moduleinfo + + local targets = memcache():get("targets") + local target_fullname = reused and from:fullname() or target:fullname() + if not (targets and targets[target_fullname]) then + return nil, string.format("module scanner did not run for target(%s), maybe a custom `on_prepare()` script overrides the modules one", target_fullname) + end + if not is_file then + return nil, string.format("target(%s): dependfile for '%s' not found at '%s'", target_fullname, sourcefile, dependfile) + end + return nil, string.format("target(%s): failed to load moduleinfo for '%s'", target_fullname, sourcefile) end function find_quote_header_file(sourcefile, file) -- cgit v1.3.1