diff options
| author | ruki <[email protected]> | 2024-03-19 21:00:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-19 21:00:06 +0800 |
| commit | 7eb40212dfffdaf693b2a78b87be3652861645bd (patch) | |
| tree | 6408980da50877def1f04350cea60e97d30e756a /xmake/rules/c++/modules/modules_support | |
| parent | 1eb61cd2e7723cb0614c2723379f3a7e3023dea5 (diff) | |
always should build modules for generator
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
3 files changed, 79 insertions, 122 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua index f0b853b87..b10a47e06 100644 --- a/xmake/rules/c++/modules/modules_support/clang/builder.lua +++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua @@ -290,56 +290,39 @@ function make_module_buildcmds(target, batchcmds, opt) end end - local build - if provide or compiler_support.has_module_extension(opt.cppfile) then - build = should_build(target, opt.cppfile, bmifile, {name = name, 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 - -- for cpp file we need to check after appendings the flags - if build == nil then - build = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires}) - end - - if build then - -- compile if it's a named module - if provide or compiler_support.has_module_extension(opt.cppfile) then - batchcmds:mkdir(path.directory(opt.objectfile)) + -- compile if it's a named module + if provide or compiler_support.has_module_extension(opt.cppfile) then + batchcmds:mkdir(path.directory(opt.objectfile)) - local fileconfig = target:fileconfig(opt.cppfile) - local public = fileconfig and fileconfig.public - local external = fileconfig and fileconfig.external - local private_dep = fileconfig and fileconfig.private_dep - local bmifile = mapped_bmi or bmifile - if target:is_binary() then - if mapped_bmi then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, {batchcmds = batchcmds}) - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) - end + local fileconfig = target:fileconfig(opt.cppfile) + local public = fileconfig and fileconfig.public + local external = fileconfig and fileconfig.external + local private_dep = fileconfig and fileconfig.private_dep + local bmifile = mapped_bmi or bmifile + if target:is_binary() then + if mapped_bmi then + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) + _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, {batchcmds = batchcmds}) else - if (not public and not external) or (external and private_dep) then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile) - _compile_bmi_step(target, bmifile, opt.cppfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) - end + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) end else - batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files + if (not public and not external) or (external and private_dep) then + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) + else + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile) + _compile_bmi_step(target, bmifile, opt.cppfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) + end end + else + batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files end batchcmds:add_depfiles(opt.cppfile) return os.mtime(opt.objectfile) diff --git a/xmake/rules/c++/modules/modules_support/gcc/builder.lua b/xmake/rules/c++/modules/modules_support/gcc/builder.lua index e2d6f95c5..ee7476097 100644 --- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/gcc/builder.lua @@ -273,51 +273,42 @@ function make_module_buildcmds(target, batchcmds, opt) target:fileconfig_add(opt.cppfile, {force = {cxxflags = {module_mapperflag .. module_mapper}}}) end - local build = should_build(target, opt.cppfile, bmifile, {name = name, 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:mkdir(path.directory(opt.objectfile)) - local fileconfig = target:fileconfig(opt.cppfile) - local public = fileconfig and fileconfig.public - local external = fileconfig and fileconfig.external - local private_dep = fileconfig and fileconfig.private_dep - local bmifile = mapped_bmi or bmifile - local flags = {"-x", "c++"} - local sourcefile - if target:is_binary() then - if mapped_bmi then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - sourcefile = bmifile - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - sourcefile = opt.cppfile - end + -- compile if it's a named module + if provide or compiler_support.has_module_extension(opt.cppfile) then + batchcmds:mkdir(path.directory(opt.objectfile)) + local fileconfig = target:fileconfig(opt.cppfile) + local public = fileconfig and fileconfig.public + local external = fileconfig and fileconfig.external + local private_dep = fileconfig and fileconfig.private_dep + local bmifile = mapped_bmi or bmifile + local flags = {"-x", "c++"} + local sourcefile + if target:is_binary() then + if mapped_bmi then + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) + sourcefile = bmifile else - if (not public and not external) or (external and private_dep) then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - sourcefile = opt.cppfile - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile) - local module_onlyflag = compiler_support.get_moduleonlyflag(target) - table.insert(flags, module_onlyflag) - sourcefile = opt.cppfile - end - end - if option.get("diagnosis") then - batchcmds:print("mapper file: %s", io.readfile(module_mapper)) + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + sourcefile = opt.cppfile end - _batchcmds_compile(batchcmds, target, flags, sourcefile, opt.objectfile) - batchcmds:rm(module_mapper) else - batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files + if (not public and not external) or (external and private_dep) then + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + sourcefile = opt.cppfile + else + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile) + local module_onlyflag = compiler_support.get_moduleonlyflag(target) + table.insert(flags, module_onlyflag) + sourcefile = opt.cppfile + end + end + if option.get("diagnosis") then + batchcmds:print("mapper file: %s", io.readfile(module_mapper)) end + _batchcmds_compile(batchcmds, target, flags, sourcefile, opt.objectfile) + batchcmds:rm(module_mapper) + else + batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files end batchcmds:add_depfiles(opt.cppfile) return os.mtime(opt.objectfile) diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua index 5a67df409..114103ea2 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua @@ -354,59 +354,42 @@ function make_module_buildcmds(target, batchcmds, opt) end end - local build - if provide or compiler_support.has_module_extension(opt.cppfile) then - build = should_build(target, opt.cppfile, bmifile, {name = name, 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 - -- for cpp file we need to check after appendings the flags - if build == nil then - build = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires}) - end - - if build then - -- compile if it's a named module - if provide or compiler_support.has_module_extension(opt.cppfile) then - batchcmds:mkdir(path.directory(opt.objectfile)) + -- compile if it's a named module + if provide or compiler_support.has_module_extension(opt.cppfile) then + batchcmds:mkdir(path.directory(opt.objectfile)) - local fileconfig = target:fileconfig(opt.cppfile) - local public = fileconfig and fileconfig.public - local external = fileconfig and fileconfig.external - local private_dep = fileconfig and fileconfig.private_dep - local bmifile = mapped_bmi or bmifile - if target:is_binary() then - if mapped_bmi then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds}) - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds}) - end + local fileconfig = target:fileconfig(opt.cppfile) + local public = fileconfig and fileconfig.public + local external = fileconfig and fileconfig.external + local private_dep = fileconfig and fileconfig.private_dep + local bmifile = mapped_bmi or bmifile + if target:is_binary() then + if mapped_bmi then + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) + _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds}) else - if (not public and not external) or (external and private_dep) then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide {batchcmds = batchcmds}) - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile) - _compile_bmi_step(target, bmifile, opt.cppfile, provide, {batchcmds = batchcmds}) - end + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds}) end else - batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files + if (not public and not external) or (external and private_dep) then + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide {batchcmds = batchcmds}) + else + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile) + _compile_bmi_step(target, bmifile, opt.cppfile, provide, {batchcmds = batchcmds}) + end end + else + batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files end batchcmds:add_depfiles(opt.cppfile) - return os.mtime(opt.objectfile) + return os.mtime(opt.objectfile) end -- build headerunit file for batchjobs |
