diff options
| author | ruki <[email protected]> | 2025-11-10 09:14:53 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-10 09:14:53 +0800 |
| commit | a88e94ae38116fc6d3ebd8c29b4da99b904ca699 (patch) | |
| tree | fb94ad68d29ae66a96253f0df5042a1c4cf4e21f | |
| parent | 7aba463e126cac47359e97fb885f6d42ce98182c (diff) | |
| parent | dc0296c27bfd695f21670f7231e06def546e91c9 (diff) | |
Merge pull request #7004 from Arthapz/dont-rebuild-packages-and-std
feat(modules) Dont rebuild packages and std when using -r flag
| -rw-r--r-- | xmake/rules/c++/modules/builder.lua | 6 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/clang/scanner.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/gcc/scanner.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/msvc/scanner.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/scanner.lua | 6 |
5 files changed, 16 insertions, 8 deletions
diff --git a/xmake/rules/c++/modules/builder.lua b/xmake/rules/c++/modules/builder.lua index 87cd143f0..ae25d3063 100644 --- a/xmake/rules/c++/modules/builder.lua +++ b/xmake/rules/c++/modules/builder.lua @@ -179,7 +179,11 @@ function should_build(target, module) local objectfile_exists = (module.headerunit or support.is_bmionly(target, module.sourcefile)) and true or os.isfile(module.objectfile) dependinfo.lastmtime = (os.isfile(module.bmifile or module.objectfile) and objectfile_exists) and os.mtime(dependfile) or 0 - local old_dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {}) + local fileconfig = target:fileconfig(module.sourcefile) + local from_package = fileconfig and fileconfig.from_package + local is_std = path.basename(module.sourcefile) == "std" or path.basename(module.sourcefile) == "std.compat" + local rebuild = target:is_rebuilt() and not from_package and not is_std + local old_dependinfo = rebuild and {} or (depend.load(dependfile) or {}) old_dependinfo.files = {module.sourcefile} -- need build this object? diff --git a/xmake/rules/c++/modules/clang/scanner.lua b/xmake/rules/c++/modules/clang/scanner.lua index b7988806c..96aa6a7e2 100644 --- a/xmake/rules/c++/modules/clang/scanner.lua +++ b/xmake/rules/c++/modules/clang/scanner.lua @@ -28,7 +28,7 @@ import("support") import(".scanner", {inherit = true}) -- scan module dependencies -function scan_dependency_for(target, sourcefile, opt) +function scan_dependency_for(target, sourcefile, rescan, opt) local compinst = target:compiler("cxx") local changed = false @@ -87,7 +87,7 @@ function scan_dependency_for(target, sourcefile, opt) local rawdependinfo = io.readfile(jsonfile) return {moduleinfo = rawdependinfo} - end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt(), values = compflags}) + end, {dependfile = dependfile, files = {sourcefile}, changed = rescan, values = compflags}) return changed end diff --git a/xmake/rules/c++/modules/gcc/scanner.lua b/xmake/rules/c++/modules/gcc/scanner.lua index 862df3c43..b0cdda7af 100644 --- a/xmake/rules/c++/modules/gcc/scanner.lua +++ b/xmake/rules/c++/modules/gcc/scanner.lua @@ -28,7 +28,7 @@ import("builder") import(".scanner", {inherit = true}) -- scan module dependencies -function scan_dependency_for(target, sourcefile, opt) +function scan_dependency_for(target, sourcefile, rescan, opt) local compinst = target:compiler("cxx") local baselineflags = {"-E", "-x", "c++"} @@ -77,7 +77,7 @@ function scan_dependency_for(target, sourcefile, opt) local dependinfo = io.readfile(jsonfile) return { moduleinfo = dependinfo } - end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt(), values = compflags}) + end, {dependfile = dependfile, files = {sourcefile}, changed = rescan, values = compflags}) return changed end diff --git a/xmake/rules/c++/modules/msvc/scanner.lua b/xmake/rules/c++/modules/msvc/scanner.lua index 912e643ab..07f7de41e 100644 --- a/xmake/rules/c++/modules/msvc/scanner.lua +++ b/xmake/rules/c++/modules/msvc/scanner.lua @@ -29,7 +29,7 @@ import("builder") import(".scanner", {inherit = true}) -- scan module dependencies -function scan_dependency_for(target, sourcefile, opt) +function scan_dependency_for(target, sourcefile, rescan, opt) local msvc = target:toolchain("msvc") local compinst = target:compiler("cxx") @@ -68,7 +68,7 @@ function scan_dependency_for(target, sourcefile, opt) local dependinfo = io.readfile(jsonfile) return { moduleinfo = dependinfo } - end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt(), values = compflags}) + end, {dependfile = dependfile, files = {sourcefile}, changed = rescan, values = compflags}) return changed end diff --git a/xmake/rules/c++/modules/scanner.lua b/xmake/rules/c++/modules/scanner.lua index 3c7a04aa4..12c85e73e 100644 --- a/xmake/rules/c++/modules/scanner.lua +++ b/xmake/rules/c++/modules/scanner.lua @@ -510,7 +510,11 @@ end function _do_scan(target, sourcefile, opt) profiler.enter(target:fullname(), "c++ modules", "scanner", "scan dependencies for", sourcefile) - local changed = _scanner(target).scan_dependency_for(target, sourcefile, opt) + local fileconfig = target:fileconfig(sourcefile) + local from_package = fileconfig and fileconfig.from_package + local is_std = path.basename(sourcefile) == "std" or path.basename(sourcefile) == "std.compat" + local rescan = target:is_rebuilt() and not from_package and not is_std + local changed = _scanner(target).scan_dependency_for(target, sourcefile, rescan, opt) if changed or not support.localcache():get2(target:fullname(), "module_mapper") then support.memcache():set2(target:fullname(), "modules.changed", true) end |
