diff options
| author | Arthur LAURENT <[email protected]> | 2022-12-04 17:23:08 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2022-12-04 21:39:49 +0100 |
| commit | 63205720fb137871070629ef6e562877de134638 (patch) | |
| tree | 37f22186d7162bad53943b726bfdae128bf8aba7 | |
| parent | 624490c743ac474ddca3c3cdb93a9fbff8e26dc5 (diff) | |
add support of msvc specific /internalPartition
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/common.lua | 7 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 26 |
2 files changed, 30 insertions, 3 deletions
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 6401f1f5b..ad8f94549 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -443,6 +443,8 @@ 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["msvc.internalpartition"] or false sourcecode = sourcecode:gsub("//.-\n", "\n") sourcecode = sourcecode:gsub("/%*.-%*/", "") for _, line in ipairs(sourcecode:split("\n", {plain = true})) do @@ -452,6 +454,9 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess 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 + 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 -- @see https://github.com/xmake-io/xmake/pull/2664#issuecomment-1213167314 @@ -488,7 +493,7 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess local provide = {} provide["logical-name"] = module_name_export provide["source-path"] = path.absolute(sourcefile, project.directory()) - provide["is-interface"] = true + provide["is-interface"] = not internalpartition 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 616a2d082..c1c0e76cf 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -434,6 +434,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op local ifcoutputflag = get_ifcoutputflag(target) local interfaceflag = get_interfaceflag(target) local referenceflag = get_referenceflag(target) + local internalpartitionflag = get_internalpartitionflag(target) -- flush job local flushjob = batchjobs:addjob(target:name() .. "_modules", function(index, total) @@ -468,7 +469,11 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op table.join2(flags, {ifcoutputflag, provide.bmi}) dependfile = target:dependfile(provide.bmi) - if provide.interface then + local fileconfig = target:fileconfig(provide.sourcefile) + if fileconfig and fileconfig.values and fileconfig.values["msvc.internalpartition"] then + assert(internalpartitionflag, "/internalPartition not supported !") + table.insert(flags, internalpartitionflag) + elseif provide.interface then table.insert(flags, interfaceflag) end end @@ -520,6 +525,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op local ifcoutputflag = get_ifcoutputflag(target) local interfaceflag = get_interfaceflag(target) local referenceflag = get_referenceflag(target) + local internalpartitionflag = get_internalpartitionflag(target) -- build modules local depmtime = 0 @@ -552,7 +558,11 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op if provide then table.join2(flags, {ifcoutputflag, path(provide.bmi)}) - if provide.interface then + local fileconfig = target:fileconfig(cppfile) + if fileconfig and fileconfig.values and fileconfig.values["msvc.internalpartition"] then + assert(internalpartitionflag, "/internalPartition not supported !") + table.insert(flags, internalpartitionflag) + elseif provide.interface then table.insert(flags, interfaceflag) end end @@ -776,3 +786,15 @@ function get_cppversionflag(target) end return cppversionflag or nil end + +function get_internalpartitionflag(target) + local internalpartitionflag = _g.internalpartitionflag + if internalpartitionflag == nil then + local compinst = target:compiler("cxx") + if compinst:has_flags("-internalPartition", "cxxflags", {flagskey = "cl_internal_partition"}) then + internalpartitionflag = "-internalPartition" + end + _g.internalpartitionflag = internalpartitionflag or false + end + return internalpartitionflag or nil +end
\ No newline at end of file |
