diff options
| author | Arthur LAURENT <[email protected]> | 2024-02-03 23:59:46 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2024-02-03 23:59:46 +0100 |
| commit | ca775e5acba55f26f4d33aae784e4d6b809e2339 (patch) | |
| tree | 56bc3f76f0534028c822973e60b8d37297b471df /xmake/rules/c++/modules/modules_support | |
| parent | ce79b0d86208463a6a6fded2131baf72247526d1 (diff) | |
fix unnecessary recompilation of modules
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang/builder.lua | 34 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc/builder.lua | 35 |
2 files changed, 48 insertions, 21 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua index 8b1cdf827..9643fe84e 100644 --- a/xmake/rules/c++/modules/modules_support/clang/builder.lua +++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua @@ -205,16 +205,23 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, should_build, local compinst = compiler.load("cxx", {target = target}) local compflags = compinst:compflags({sourcefile = opt.cppfile, target = target}) + if provide or compiler_support.has_module_extension(opt.cppfile) then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) + + -- needed to detect rebuild of dependencies + if provide and build then + mark_build(target, name) + end + end + -- append requires flags if opt.module.requires then _append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, opt) end - local build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) - - -- needed to detect rebuild of dependencies - if provide and build then - mark_build(target, name) + -- for cpp file we need to check after appendings the flags + if build == nil then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) end local dependfile = target:dependfile(bmifile or opt.objectfile) @@ -261,16 +268,23 @@ function make_module_buildcmds(target, batchcmds, should_build, mark_build, opt) local name, provide, _ = compiler_support.get_provided_module(opt.module) local bmifile = provide and compiler_support.get_bmi_path(provide.bmi) + if provide or compiler_support.has_module_extension(opt.cppfile) then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) + + -- needed to detect rebuild of dependencies + if provide and build then + mark_build(target, name) + end + end + -- append requires flags if opt.module.requires then _append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, opt) end - local build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) - - -- needed to detect rebuild of dependencies - if provide and build then - mark_build(target, name) + -- for cpp file we need to check after appendings the flags + if build == nil then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) end if build then diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua index 925f0fa35..3a4b14b68 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua @@ -222,19 +222,25 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, should_build, local compinst = compiler.load("cxx", {target = target}) local compflags = compinst:compflags({sourcefile = opt.cppfile, target = target}) + if provide or compiler_support.has_module_extension(opt.cppfile) then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) + + -- needed to detect rebuild of dependencies + if provide and build then + mark_build(target, name) + end + end + -- append requires flags if opt.module.requires then _append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, opt) end - local build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) - - -- needed to detect rebuild of dependencies - if provide and build then - mark_build(target, name) + -- for cpp file we need to check after appendings the flags + if build == nil then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) end - local dependfile = target:dependfile(bmifile or opt.objectfile) local dependinfo = depend.load(dependfile) or {} dependinfo.files = {} @@ -274,16 +280,23 @@ function make_module_buildcmds(target, batchcmds, should_build, mark_build, opt) local name, provide, _ = compiler_support.get_provided_module(opt.module) local bmifile = provide and compiler_support.get_bmi_path(provide.bmi) + if provide or compiler_support.has_module_extension(opt.cppfile) then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) + + -- needed to detect rebuild of dependencies + if provide and build then + mark_build(target, name) + end + end + -- append requires flags if opt.module.requires then _append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, opt) end - local build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) - - -- needed to detect rebuild of dependencies - if provide and build then - mark_build(target, name) + -- for cpp file we need to check after appendings the flags + if build == nil then + build = should_build(target, opt.cppfile, bmifile, {objectfile = opt.objectfile, requires = opt.module.requires}) end if build then |
