diff options
| author | Arthur LAURENT <[email protected]> | 2022-12-05 14:48:44 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2022-12-05 15:45:54 +0100 |
| commit | 718cccc5df0b1fe28cb80256dd325b57f3e44063 (patch) | |
| tree | 2564b10d32df38604d5dfb4cb316b105d620571d /xmake/rules/c++/modules/modules_support | |
| parent | 54d1c3ba54069b36337e6ba269f33a3bf148b476 (diff) | |
try to detect internal partition automatically on fallback generation
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/common.lua | 17 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 20 |
2 files changed, 10 insertions, 27 deletions
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 4314fd4a5..ac555f778 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -443,8 +443,7 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess local module_deps = {} local module_deps_set = hashset.new() local sourcecode = preprocess_file(sourcefile) or io.readfile(sourcefile) - local fileconfig = target:fileconfig(sourcefile) - local internalpartition = (fileconfig and fileconfig.values) and fileconfig.values["internalpartition"] or false + local internal = false sourcecode = sourcecode:gsub("//.-\n", "\n") sourcecode = sourcecode:gsub("/%*.-%*/", "") for _, line in ipairs(sourcecode:split("\n", {plain = true})) do @@ -453,9 +452,9 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess end if not module_name_private then module_name_private = line:match("module%s+(.+)%s*;") or line:match("__preprocessed_module%s+(.+)%s*;") - end - if internalpartition then - module_name_export = module_name_private + if module_name_private then + internal = module_name_private:find(":") + end end local module_depname = line:match("import%s+(.+)%s*;") -- we need parse module interface dep in cxx/impl_unit.cpp, e.g. hello.mpp and hello_impl.cpp @@ -487,13 +486,13 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess end end - if module_name_export then - table.insert(rule.outputs, module_name_export .. bmi_extension(target)) + if module_name_export or internal then + table.insert(rule.outputs, (module_name_export or module_name_private) .. bmi_extension(target)) local provide = {} - provide["logical-name"] = module_name_export + provide["logical-name"] = module_name_export or module_name_private provide["source-path"] = path.absolute(sourcefile, project.directory()) - provide["is-interface"] = not internalpartition + provide["is-interface"] = not internal rule.provides = {} table.insert(rule.provides, provide) diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 484076521..0004c138c 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -466,16 +466,8 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op local dependfile = target:dependfile(objectfile) if provide then - table.join2(flags, {ifcoutputflag, provide.bmi}) + table.join2(flags, {ifcoutputflag, path(provide.bmi), provide.interface and interfaceflag or internalpartitionflag}) dependfile = target:dependfile(provide.bmi) - - local fileconfig = target:fileconfig(provide.sourcefile) - if not provide.interface then - assert(internalpartitionflag, "/internalPartition not supported !") - table.insert(flags, internalpartitionflag) - elseif provide.interface then - table.insert(flags, interfaceflag) - end end table.join2(moduleinfo, { @@ -556,15 +548,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op local flags = table.join({"-TP", "-c", path(cppfile), path(objectfile, function (p) return "-Fo" .. p end)}) if provide or common.has_module_extension(cppfile) then if provide then - table.join2(flags, {ifcoutputflag, path(provide.bmi)}) - - local fileconfig = target:fileconfig(cppfile) - if not provide.interface then - assert(internalpartitionflag, "/internalPartition not supported !") - table.insert(flags, internalpartitionflag) - elseif provide.interface then - table.insert(flags, interfaceflag) - end + table.join2(flags, {ifcoutputflag, path(provide.bmi), provide.interface and interfaceflag or internalpartitionflag}) end batchcmds:show_progress(opt.progress, "${color.build.object}compiling.module.$(mode) %s", name or cppfile) |
