diff options
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/msvc')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc/builder.lua | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua index 019235837..925f0fa35 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua @@ -207,7 +207,7 @@ function get_module_required_defines(target, sourcefile) end -- build module file for batchjobs -function make_module_buildjobs(target, batchjobs, job_name, deps, opt) +function make_module_buildjobs(target, batchjobs, job_name, deps, 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) @@ -227,27 +227,39 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) _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) + end + + local dependfile = target:dependfile(bmifile or opt.objectfile) local dependinfo = depend.load(dependfile) or {} dependinfo.files = {} local depvalues = {compinst:program(), compflags} - -- compile if it's a named module - if opt.build and (provide or compiler_support.has_module_extension(opt.cppfile)) then - progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + if build then + -- compile if it's a named module + if provide or compiler_support.has_module_extension(opt.cppfile) then + progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - if not dryrun then - local objectdir = path.directory(opt.objectfile) - if not os.isdir(objectdir) then - os.mkdir(objectdir) + if not dryrun then + local objectdir = path.directory(opt.objectfile) + if not os.isdir(objectdir) then + os.mkdir(objectdir) + end end - end - local fileconfig = target:fileconfig(opt.cppfile) - local external = fileconfig and fileconfig.external - local flags = _make_modulebuildflags(target, provide, bmifile, {external = external}) + local fileconfig = target:fileconfig(opt.cppfile) + local external = fileconfig and fileconfig.external + local flags = _make_modulebuildflags(target, provide, bmifile, {external = external}) - _compile(target, flags, opt.cppfile, opt.objectfile) + _compile(target, flags, opt.cppfile, opt.objectfile) + else + os.tryrm(opt.objectfile) -- force rebuild for .cpp files + end end table.insert(dependinfo.files, opt.cppfile) @@ -257,7 +269,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) end -- build module file for batchcmds -function make_module_buildcmds(target, batchcmds, opt) +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) @@ -267,7 +279,15 @@ function make_module_buildcmds(target, batchcmds, opt) _append_requires_flags(target, opt.module, name, opt.cppfile, bmifile, opt) end - if opt.build then + 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) + end + + if build then + -- compile if it's a named module if provide or compiler_support.has_module_extension(opt.cppfile) then batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) batchcmds:mkdir(path.directory(opt.objectfile)) @@ -276,6 +296,8 @@ function make_module_buildcmds(target, batchcmds, opt) local external = fileconfig and fileconfig.external local flags = _make_modulebuildflags(target, provide, bmifile, opt.cppfile, opt.objectfile, {batchcmds = true, external = external}) _batchcmds_compile(batchcmds, target, flags, opt.cppfile, objectfile) + else + batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files end end batchcmds:add_depfiles(opt.cppfile) |
