summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-21 09:45:41 +0800
committerGitHub <[email protected]>2025-04-21 09:45:41 +0800
commit5d999522fe625c54a572fcdd28bc82f2850a3d5a (patch)
tree4d1d5852b9ab35542e12ee4cd534ae4d90116d02
parentb82b7f253f29154093f665ba5096834e8d31bbf8 (diff)
parenta1fefbea336ad2294b853059d32850877f54bb90 (diff)
Merge pull request #6338 from Arthapz/simplify-module-dir-tree
(c++ modules support) Simplify module support directory tree
-rw-r--r--xmake/modules/core/tools/gcc.lua4
-rw-r--r--xmake/plugins/project/cmake/cmakelists.lua4
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua6
-rw-r--r--xmake/rules/c++/modules/builder.lua (renamed from xmake/rules/c++/modules/modules_support/builder.lua)56
-rw-r--r--xmake/rules/c++/modules/clang/builder.lua (renamed from xmake/rules/c++/modules/modules_support/clang/builder.lua)48
-rw-r--r--xmake/rules/c++/modules/clang/scanner.lua (renamed from xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua)16
-rw-r--r--xmake/rules/c++/modules/clang/support.lua (renamed from xmake/rules/c++/modules/modules_support/clang/compiler_support.lua)4
-rw-r--r--xmake/rules/c++/modules/gcc/builder.lua (renamed from xmake/rules/c++/modules/modules_support/gcc/builder.lua)52
-rw-r--r--xmake/rules/c++/modules/gcc/scanner.lua (renamed from xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua)14
-rw-r--r--xmake/rules/c++/modules/gcc/support.lua (renamed from xmake/rules/c++/modules/modules_support/gcc/compiler_support.lua)4
-rw-r--r--xmake/rules/c++/modules/msvc/builder.lua (renamed from xmake/rules/c++/modules/modules_support/msvc/builder.lua)78
-rw-r--r--xmake/rules/c++/modules/msvc/scanner.lua (renamed from xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua)12
-rw-r--r--xmake/rules/c++/modules/msvc/support.lua (renamed from xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua)4
-rw-r--r--xmake/rules/c++/modules/scanner.lua (renamed from xmake/rules/c++/modules/modules_support/dependency_scanner.lua)64
-rw-r--r--xmake/rules/c++/modules/stlheaders.lua (renamed from xmake/rules/c++/modules/modules_support/stl_headers.lua)20
-rw-r--r--xmake/rules/c++/modules/support.lua (renamed from xmake/rules/c++/modules/modules_support/compiler_support.lua)28
-rw-r--r--xmake/rules/c++/modules/xmake.lua68
17 files changed, 241 insertions, 241 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 3de17be4a..ed6bbcf22 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -31,7 +31,7 @@ import("core.language.language")
import("utils.progress")
import("private.cache.build_cache")
import("private.service.distcc_build.client", {alias = "distcc_build_client"})
-import("rules.c++.modules.modules_support.compiler_support", {rootdir = os.programdir()})
+import("rules.c++.modules.support", {rootdir = os.programdir()})
function init(self)
@@ -923,7 +923,7 @@ function compargv(self, sourcefile, objectfile, flags, opt)
local extension = path.extension(sourcefile)
if (extension:startswith(".h") or extension == ".inl") then
flags = _translate_flags_for_pch(self, flags)
- elseif compiler_support.has_module_extension(sourcefile, {extension = extension}) then
+ elseif support.has_module_extension(sourcefile, {extension = extension}) then
flags = _translate_flags_for_mpp(self, flags)
end
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua
index 9d2fc453a..e65f89cee 100644
--- a/xmake/plugins/project/cmake/cmakelists.lua
+++ b/xmake/plugins/project/cmake/cmakelists.lua
@@ -31,7 +31,7 @@ import("lib.detect.find_tool")
import("private.utils.batchcmds")
import("private.utils.target", {alias = "target_utils"})
import("plugins.project.utils.target_cmds", {rootdir = os.programdir()})
-import("rules.c++.modules.modules_support.compiler_support", {alias = "module_compiler_support", rootdir = os.programdir()})
+import("rules.c++.modules.support", {alias = "module_support", rootdir = os.programdir()})
-- get cmake version
function _get_cmake_version()
@@ -49,7 +49,7 @@ end
-- has c++ modules sources
function _has_cxxmodules_sources()
for _, target in ipairs(project.ordertargets()) do
- if module_compiler_support.contains_modules(target) then
+ if module_support.contains_modules(target) then
return true
end
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
index 9b0846930..94e966653 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
@@ -30,7 +30,7 @@ import("detect.sdks.find_cuda")
import("vsfile")
import("vsutils")
import("private.utils.toolchain", {alias = "toolchain_utils"})
-import("rules.c++.modules.modules_support.compiler_support", {rootdir = os.programdir()})
+import("rules.c++.modules.support", {rootdir = os.programdir()})
function _make_dirs(dir, vcxprojdir)
dir = dir:trim()
@@ -1174,7 +1174,7 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
else
-- compile as c++ modules
- if compiler_support.has_module_extension(sourcefile) then
+ if support.has_module_extension(sourcefile) then
vcxprojfile:print("<CompileAs>CompileAsCppModule</CompileAs>")
end
@@ -1311,7 +1311,7 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
-- for *.c/cpp/cu files
else
-- compile as c++ modules
- if compiler_support.has_module_extension(sourcefile) then
+ if support.has_module_extension(sourcefile) then
vcxprojfile:print("<CompileAs>CompileAsCppModule</CompileAs>")
end
diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/builder.lua
index a02e1e7d3..1f3eec988 100644
--- a/xmake/rules/c++/modules/modules_support/builder.lua
+++ b/xmake/rules/c++/modules/builder.lua
@@ -28,8 +28,8 @@ import("core.tool.compiler")
import("core.project.config")
import("core.project.depend")
import("utils.progress")
-import("compiler_support")
-import("dependency_scanner")
+import("support")
+import("scanner")
-- build target modules
function _build_modules(target, sourcebatch, modules, opt)
@@ -40,7 +40,7 @@ function _build_modules(target, sourcebatch, modules, opt)
goto continue
end
- local name, _, cppfile = compiler_support.get_provided_module(module)
+ local name, _, cppfile = support.get_provided_module(module)
cppfile = cppfile or module.cppfile
local deps = {}
@@ -62,7 +62,7 @@ end
-- build target headerunits
function _build_headerunits(target, headerunits, opt)
- local outputdir = compiler_support.headerunits_cachedir(target, {mkdir = true})
+ local outputdir = support.headerunits_cachedir(target, {mkdir = true})
if opt.stl_headerunit then
outputdir = path.join(outputdir, "stl")
end
@@ -72,7 +72,7 @@ function _build_headerunits(target, headerunits, opt)
if opt.stl_headerunit and headerunit.name:startswith("experimental/") then
outputdir = path.join(outputdir, "experimental")
end
- local bmifile = path.join(outputdir, path.filename(headerunit.name) .. compiler_support.get_bmi_extension(target))
+ local bmifile = path.join(outputdir, path.filename(headerunit.name) .. support.get_bmi_extension(target))
local key = path.normalize(headerunit.path)
local build = should_build(target, headerunit.path, bmifile, {key = key, headerunit = true})
if build then
@@ -91,8 +91,8 @@ function _are_flags_compatible(target, other, cppfile)
local flags2 = compinst2:compflags({sourcefile = cppfile, target = other})
-- strip unrelevent flags
- flags1 = compiler_support.strip_flags(target, flags1)
- flags2 = compiler_support.strip_flags(target, flags2)
+ flags1 = support.strip_flags(target, flags1)
+ flags2 = support.strip_flags(target, flags2)
if #flags1 ~= #flags2 then
return false
@@ -112,7 +112,7 @@ end
-- try to reuse modules from other target
function _try_reuse_modules(target, modules)
for _, module in pairs(modules) do
- local name, provide, cppfile = compiler_support.get_provided_module(module)
+ local name, provide, cppfile = support.get_provided_module(module)
if not provide then
goto continue
end
@@ -131,7 +131,7 @@ function _try_reuse_modules(target, modules)
end
local mapped = get_from_target_mapper(dep, name)
if mapped then
- compiler_support.memcache():set2(target:fullname() .. name, "reuse", true)
+ support.memcache():set2(target:fullname() .. name, "reuse", true)
add_module_to_target_mapper(target, mapped.name, mapped.sourcefile, mapped.bmi, table.join(mapped.opt or {}, {target = dep}))
break
end
@@ -159,8 +159,8 @@ function should_build(target, sourcefile, bmifile, opt)
for required, _ in table.orderpairs(requires) do
local m = get_from_target_mapper(target, required)
if m then
- local rebuild = (m.opt and m.opt.target) and compiler_support.memcache():get2("should_build_in_" .. m.opt.target:fullname(), m.key)
- or compiler_support.memcache():get2("should_build_in_" .. target:fullname(), m.key)
+ local rebuild = (m.opt and m.opt.target) and support.memcache():get2("should_build_in_" .. m.opt.target:fullname(), m.key)
+ or support.memcache():get2("should_build_in_" .. target:fullname(), m.key)
if rebuild then
dependinfo.files = {}
table.insert(dependinfo.files, sourcefile)
@@ -175,7 +175,7 @@ function should_build(target, sourcefile, bmifile, opt)
if opt.name then
local m = get_from_target_mapper(target, opt.name)
if m and m.opt and m.opt.target then
- local rebuild = compiler_support.memcache():get2("should_build_in_" .. m.opt.target:fullname(), m.key)
+ local rebuild = support.memcache():get2("should_build_in_" .. m.opt.target:fullname(), m.key)
if rebuild then
dependinfo.files = {}
table.insert(dependinfo.files, sourcefile)
@@ -207,7 +207,7 @@ end
-- "file": "foo.cppm"
-- }
function _generate_meta_module_info(target, name, sourcefile, requires)
- local modulehash = compiler_support.get_modulehash(target, sourcefile)
+ local modulehash = support.get_modulehash(target, sourcefile)
local module_metadata = {name = name, file = path.join(modulehash, path.filename(sourcefile))}
-- add definitions
@@ -235,7 +235,7 @@ end
function _builder(target)
local cachekey = tostring(target)
- local builder = compiler_support.memcache():get2("builder", cachekey)
+ local builder = support.memcache():get2("builder", cachekey)
if builder == nil then
if target:has_tool("cxx", "clang", "clangxx", "clang_cl") then
builder = import("clang.builder", {anonymous = true})
@@ -247,13 +247,13 @@ function _builder(target)
local _, toolname = target:tool("cxx")
raise("compiler(%s): does not support c++ module!", toolname)
end
- compiler_support.memcache():set2("builder", cachekey, builder)
+ support.memcache():set2("builder", cachekey, builder)
end
return builder
end
function mark_build(target, name)
- compiler_support.memcache():set2("should_build_in_" .. target:fullname(), name, true)
+ support.memcache():set2("should_build_in_" .. target:fullname(), name, true)
end
-- build batchjobs for modules
@@ -342,7 +342,7 @@ end
-- build headerunits for batchjobs
function build_headerunits_for_batchjobs(target, batchjobs, sourcebatch, modules, opt)
- local user_headerunits, stl_headerunits = dependency_scanner.get_headerunits(target, sourcebatch, modules)
+ local user_headerunits, stl_headerunits = scanner.get_headerunits(target, sourcebatch, modules)
if not user_headerunits and not stl_headerunits then
return
end
@@ -379,7 +379,7 @@ end
-- build headerunits for jobgraph
function build_headerunits_for_jobgraph(target, jobgraph, sourcebatch, modules, opt)
- local user_headerunits, stl_headerunits = dependency_scanner.get_headerunits(target, sourcebatch, modules)
+ local user_headerunits, stl_headerunits = scanner.get_headerunits(target, sourcebatch, modules)
if not user_headerunits and not stl_headerunits then
return
end
@@ -417,7 +417,7 @@ end
-- build headerunits for batchcmds
function build_headerunits_for_batchcmds(target, batchcmds, sourcebatch, modules, opt)
- local user_headerunits, stl_headerunits = dependency_scanner.get_headerunits(target, sourcebatch, modules)
+ local user_headerunits, stl_headerunits = scanner.get_headerunits(target, sourcebatch, modules)
if not user_headerunits and not stl_headerunits then
return
end
@@ -471,7 +471,7 @@ end
function generate_metadata(target, modules)
local public_modules
for _, module in table.orderpairs(modules) do
- local _, _, cppfile = compiler_support.get_provided_module(module)
+ local _, _, cppfile = support.get_provided_module(module)
local fileconfig = target:fileconfig(cppfile)
local public = fileconfig and fileconfig.public
if public then
@@ -487,8 +487,8 @@ function generate_metadata(target, modules)
local jobs = option.get("jobs") or os.default_njob()
runjobs(target:fullname() .. "/module/install_modules", function(index, total, jobopt)
local module = public_modules[index]
- local name, _, cppfile = compiler_support.get_provided_module(module)
- local metafilepath = compiler_support.get_metafile(target, cppfile)
+ local name, _, cppfile = support.get_provided_module(module)
+ local metafilepath = support.get_metafile(target, cppfile)
progress.show(jobopt.progress, "${color.build.target}<%s> generating.module.metadata %s", target:fullname(), name)
local metadata = _generate_meta_module_info(target, name, cppfile, module.requires)
json.savefile(metafilepath, metadata)
@@ -497,13 +497,13 @@ end
-- flush target module mapper keys
function flush_target_module_mapper_keys(target)
- local memcache = compiler_support.memcache()
+ local memcache = support.memcache()
memcache:set2(target:fullname(), "module_mapper_keys", nil)
end
-- get or create a target module mapper
function get_target_module_mapper(target)
- local memcache = compiler_support.memcache()
+ local memcache = support.memcache()
local mapper = memcache:get2(target:fullname(), "module_mapper")
if not mapper then
mapper = {}
@@ -559,7 +559,7 @@ end
function is_dependencies_changed(target, module)
local cachekey = target:fullname() .. module.name
local requires = hashset.from(table.keys(module.requires or {}))
- local oldrequires = compiler_support.memcache():get2(cachekey, "oldrequires")
+ local oldrequires = support.memcache():get2(cachekey, "oldrequires")
local changed = false
if oldrequires then
if oldrequires ~= requires then
@@ -581,20 +581,20 @@ function patch_sourcebatch(target, sourcebatch, opt)
-- add target deps modules
if target:orderdeps() then
- local deps_sourcefiles = dependency_scanner.get_targetdeps_modules(target)
+ local deps_sourcefiles = scanner.get_targetdeps_modules(target)
if deps_sourcefiles then
table.join2(sourcebatch.sourcefiles, deps_sourcefiles)
end
end
-- append std module
- local std_modules = compiler_support.get_stdmodules(target)
+ local std_modules = support.get_stdmodules(target)
if std_modules then
table.join2(sourcebatch.sourcefiles, std_modules)
end
-- extract packages modules dependencies
- local package_modules_data = dependency_scanner.get_all_packages_modules(target, opt)
+ local package_modules_data = scanner.get_all_packages_modules(target, opt)
if package_modules_data then
-- append to sourcebatch
for _, package_module_data in table.orderpairs(package_modules_data) do
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/clang/builder.lua
index 420d1f0ee..2c558a798 100644
--- a/xmake/rules/c++/modules/modules_support/clang/builder.lua
+++ b/xmake/rules/c++/modules/clang/builder.lua
@@ -27,11 +27,11 @@ import("private.action.build.object", {alias = "objectbuilder"})
import("core.tool.compiler")
import("core.project.config")
import("core.project.depend")
-import("compiler_support")
+import("support")
import(".builder", {inherit = true})
function _compile_one_step(target, bmifile, sourcefile, objectfile, opt)
- local module_outputflag = compiler_support.get_moduleoutputflag(target)
+ local module_outputflag = support.get_moduleoutputflag(target)
if opt.is_mapped_bmi then
-- get flags
if module_outputflag then
@@ -81,7 +81,7 @@ end
-- get flags for building a headerunit
function _make_headerunitflags(target, headerunit, bmifile)
- local module_headerflag = compiler_support.get_moduleheaderflag(target)
+ local module_headerflag = support.get_moduleheaderflag(target)
assert(module_headerflag, "compiler(clang): does not support c++ header units!")
local local_directory = (headerunit.type == ":quote") and {"-I" .. path.directory(headerunit.path)} or {}
@@ -132,12 +132,12 @@ end
--
function _get_requiresflags(target, module, opt)
- local modulefileflag = compiler_support.get_modulefileflag(target)
+ local modulefileflag = support.get_modulefileflag(target)
local name = module.name
local cachekey = target:fullname() .. name
local requires, requires_changed = is_dependencies_changed(target, module)
- local requiresflags = compiler_support.memcache():get2(cachekey, "requiresflags")
+ local requiresflags = support.memcache():get2(cachekey, "requiresflags")
if not requiresflags or requires_changed then
requiresflags = {}
for required in requires:orderitems() do
@@ -160,8 +160,8 @@ function _get_requiresflags(target, module, opt)
end
end
requiresflags = table.unique(requiresflags)
- compiler_support.memcache():set2(cachekey, "requiresflags", requiresflags)
- compiler_support.memcache():set2(cachekey, "oldrequires", requires)
+ support.memcache():set2(cachekey, "requiresflags", requiresflags)
+ support.memcache():set2(cachekey, "oldrequires", requires)
end
return requiresflags
end
@@ -182,12 +182,12 @@ end
-- populate module map
function populate_module_map(target, modules)
- local clang_version = compiler_support.get_clang_version(target)
+ local clang_version = support.get_clang_version(target)
local support_namedmodule = semver.compare(clang_version, "16.0") >= 0
for _, module in pairs(modules) do
- local name, provide, cppfile = compiler_support.get_provided_module(module)
+ local name, provide, cppfile = support.get_provided_module(module)
if provide then
- local bmifile = compiler_support.get_bmi_path(provide.bmi)
+ local bmifile = support.get_bmi_path(provide.bmi)
add_module_to_target_mapper(target, name, cppfile, bmifile, {deps = module.requires, namedmodule = support_namedmodule})
end
end
@@ -210,8 +210,8 @@ end
-- build module file for batchjobs
function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
local dryrun = option.get("dry-run")
return {
@@ -220,13 +220,13 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
sourcefile = opt.cppfile,
job = batchjobs:newjob(target:fullname() .. "/module/" .. (name or opt.cppfile), function(index, total, jobopt)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
local build, dependinfo
local dependfile = target:dependfile(bmifile or opt.objectfile)
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})
-- needed to detect rebuild of dependencies
@@ -247,7 +247,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
if build then
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
if not dryrun then
local objectdir = path.directory(opt.objectfile)
if not os.isdir(objectdir) then
@@ -281,20 +281,20 @@ end
-- build module file for jobgraph
function make_module_jobgraph(target, jobgraph, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
local dryrun = option.get("dry-run")
local jobname = target:fullname() .. "/module/" .. (name or opt.cppfile)
jobgraph:add(jobname, function(index, total, jobopt)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
local build, dependinfo
local dependfile = target:dependfile(bmifile or opt.objectfile)
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})
-- needed to detect rebuild of dependencies
@@ -315,7 +315,7 @@ function make_module_jobgraph(target, jobgraph, opt)
if build then
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
if not dryrun then
local objectdir = path.directory(opt.objectfile)
if not os.isdir(objectdir) then
@@ -350,11 +350,11 @@ end
-- build module file for batchcmds
function make_module_buildcmds(target, batchcmds, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
@@ -364,7 +364,7 @@ function make_module_buildcmds(target, batchcmds, opt)
end
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
batchcmds:mkdir(path.directory(opt.objectfile))
local fileconfig = target:fileconfig(opt.cppfile)
diff --git a/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua b/xmake/rules/c++/modules/clang/scanner.lua
index 715e8a07d..5b7d10658 100644
--- a/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/clang/scanner.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file clang/dependency_scanner.lua
+-- @file clang/scanner.lua
--
-- imports
@@ -24,8 +24,8 @@ import("core.base.semver")
import("core.base.option")
import("core.project.depend")
import("utils.progress")
-import("compiler_support")
-import(".dependency_scanner", {inherit = true})
+import("support")
+import(".scanner", {inherit = true})
function generate_dependency_for(target, sourcefile, opt)
local compinst = target:compiler("cxx")
@@ -39,17 +39,17 @@ function generate_dependency_for(target, sourcefile, opt)
progress.show(opt.progress, "${color.build.target}<%s> generating.module.deps %s", target:fullname(), sourcefile)
end
- local outputdir = compiler_support.get_outputdir(target, sourcefile)
+ local outputdir = support.get_outputdir(target, sourcefile)
local jsonfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".json"))
- local has_clangscandepssupport = compiler_support.has_clangscandepssupport(target)
+ local has_clangscandepssupport = support.has_clangscandepssupport(target)
if has_clangscandepssupport and not target:policy("build.c++.clang.fallbackscanner") then
-- We need absolute path of clang to use clang-scan-deps
-- See https://clang.llvm.org/docs/StandardCPlusPlusModules.html#possible-issues-failed-to-find-system-headers
local clang_path = compinst:program()
if not path.is_absolute(clang_path) then
- clang_path = compiler_support.get_clang_path(target) or compinst:program()
+ clang_path = support.get_clang_path(target) or compinst:program()
end
- local clangscandeps = compiler_support.get_clang_scan_deps(target)
+ local clangscandeps = support.get_clang_scan_deps(target)
local dependency_flags = table.join({"--format=p1689", "--",
clang_path, "-x", "c++", "-c", sourcefile, "-o", target:objectfile(sourcefile)}, flags)
if option.get("verbose") then
@@ -64,7 +64,7 @@ function generate_dependency_for(target, sourcefile, opt)
wprint("No clang-scan-deps found ! using fallback scanner")
end
fallback_generate_dependencies(target, jsonfile, sourcefile, function(file)
- local keepsystemincludesflag = compiler_support.get_keepsystemincludesflag(target)
+ local keepsystemincludesflag = support.get_keepsystemincludesflag(target)
local compflags = table.clone(flags)
-- exclude -fmodule* and -std=c++/gnu++* flags because
-- when they are set clang try to find bmi of imported modules but they don't exists in this point of compilation
diff --git a/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua b/xmake/rules/c++/modules/clang/support.lua
index 6eb4f84b1..adfd5730c 100644
--- a/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua
+++ b/xmake/rules/c++/modules/clang/support.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file clang/compiler_support.lua
+-- @file clang/support.lua
--
-- imports
@@ -24,7 +24,7 @@ import("core.base.option")
import("core.base.json")
import("lib.detect.find_tool")
import("lib.detect.find_file")
-import(".compiler_support", {inherit = true})
+import(".support", {inherit = true})
-- get includedirs for stl headers
--
diff --git a/xmake/rules/c++/modules/modules_support/gcc/builder.lua b/xmake/rules/c++/modules/gcc/builder.lua
index 1f909623f..f3c0ba471 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua
+++ b/xmake/rules/c++/modules/gcc/builder.lua
@@ -27,14 +27,14 @@ import("private.action.build.object", {alias = "objectbuilder"})
import("core.tool.compiler")
import("core.project.config")
import("core.project.depend")
-import("compiler_support")
+import("support")
import(".builder", {inherit = true})
-- get flags for building a headerunit
function _make_headerunitflags(target, headerunit, headerunit_mapper)
- local module_headerflag = compiler_support.get_moduleheaderflag(target)
- local module_onlyflag = compiler_support.get_moduleonlyflag(target)
- local module_mapperflag = compiler_support.get_modulemapperflag(target)
+ local module_headerflag = support.get_moduleheaderflag(target)
+ local module_onlyflag = support.get_moduleonlyflag(target)
+ local module_mapperflag = support.get_modulemapperflag(target)
assert(module_headerflag and module_onlyflag, "compiler(gcc): does not support c++ header units!")
local local_directory = (headerunit.type == ":quote") and {"-I" .. path.directory(path.normalize(headerunit.path))} or {}
@@ -93,9 +93,9 @@ end
function _get_maplines(target, module)
local maplines = {}
- local m_name, m, _ = compiler_support.get_provided_module(module)
+ local m_name, m, _ = support.get_provided_module(module)
if m then
- table.insert(maplines, m_name .. " " .. compiler_support.get_bmi_path(m.bmi))
+ table.insert(maplines, m_name .. " " .. support.get_bmi_path(m.bmi))
end
for required, _ in table.orderpairs(module.requires) do
local dep_module = get_from_target_mapper(target, required)
@@ -151,9 +151,9 @@ end
-- populate module map
function populate_module_map(target, modules)
for _, module in pairs(modules) do
- local name, provide = compiler_support.get_provided_module(module)
+ local name, provide = support.get_provided_module(module)
if provide then
- local bmifile = compiler_support.get_bmi_path(provide.bmi)
+ local bmifile = support.get_bmi_path(provide.bmi)
add_module_to_target_mapper(target, name, provide.sourcefile, bmifile, {deps = module.requires})
end
end
@@ -176,9 +176,9 @@ end
-- build module file for batchjobs
function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
- local module_mapperflag = compiler_support.get_modulemapperflag(target)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
+ local module_mapperflag = support.get_modulemapperflag(target)
return {
name = job_name,
@@ -186,7 +186,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
sourcefile = opt.cppfile,
job = batchjobs:newjob(target:fullname() .. "/module/" .. (name or opt.cppfile), function(index, total, jobopt)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
@@ -207,7 +207,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
if build then
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
local fileconfig = target:fileconfig(opt.cppfile)
local public = fileconfig and fileconfig.public
local external = fileconfig and fileconfig.external
@@ -218,7 +218,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
if external and not from_moduleonly then
if not mapped_bmi then
progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:fullname(), name or opt.cppfile)
- local module_onlyflag = compiler_support.get_moduleonlyflag(target)
+ local module_onlyflag = support.get_moduleonlyflag(target)
table.insert(flags, module_onlyflag)
sourcefile = opt.cppfile
end
@@ -243,14 +243,14 @@ end
-- build module file for jobgraph
function make_module_jobgraph(target, jobgraph, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
- local module_mapperflag = compiler_support.get_modulemapperflag(target)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
+ local module_mapperflag = support.get_modulemapperflag(target)
local jobname = target:fullname() .. "/module/" .. (name or opt.cppfile)
jobgraph:add(jobname, function(index, total, jobopt)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
@@ -271,7 +271,7 @@ function make_module_jobgraph(target, jobgraph, opt)
if build then
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
local fileconfig = target:fileconfig(opt.cppfile)
local public = fileconfig and fileconfig.public
local external = fileconfig and fileconfig.external
@@ -282,7 +282,7 @@ function make_module_jobgraph(target, jobgraph, opt)
if external and not from_moduleonly then
if not mapped_bmi then
progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:fullname(), name or opt.cppfile)
- local module_onlyflag = compiler_support.get_moduleonlyflag(target)
+ local module_onlyflag = support.get_moduleonlyflag(target)
table.insert(flags, module_onlyflag)
sourcefile = opt.cppfile
end
@@ -308,12 +308,12 @@ end
-- build module file for batchcmds
function make_module_buildcmds(target, batchcmds, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
- local module_mapperflag = compiler_support.get_modulemapperflag(target)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
+ local module_mapperflag = support.get_modulemapperflag(target)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
@@ -325,7 +325,7 @@ function make_module_buildcmds(target, batchcmds, opt)
end
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or 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
@@ -337,7 +337,7 @@ function make_module_buildcmds(target, batchcmds, opt)
if external and not from_moduleonly then
if not mapped_bmi then
batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:fullname(), name or opt.cppfile)
- local module_onlyflag = compiler_support.get_moduleonlyflag(target)
+ local module_onlyflag = support.get_moduleonlyflag(target)
table.insert(flags, module_onlyflag)
sourcefile = opt.cppfile
end
diff --git a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua b/xmake/rules/c++/modules/gcc/scanner.lua
index e087c6d4e..1496d17dd 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/gcc/scanner.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file gcc/dependency_scanner.lua
+-- @file gcc/scanner.lua
--
-- imports
@@ -23,17 +23,17 @@ import("core.base.json")
import("core.base.semver")
import("core.project.depend")
import("utils.progress")
-import("compiler_support")
+import("support")
import("builder")
-import(".dependency_scanner", {inherit = true})
+import(".scanner", {inherit = true})
-- generate dependency files
function generate_dependency_for(target, sourcefile, opt)
local compinst = target:compiler("cxx")
local baselineflags = {"-E", "-x", "c++"}
- local depsformatflag = compiler_support.get_depsflag(target, "p1689r5")
- local depsfileflag = compiler_support.get_depsfileflag(target)
- local depstargetflag = compiler_support.get_depstargetflag(target)
+ local depsformatflag = support.get_depsflag(target, "p1689r5")
+ local depsfileflag = support.get_depsfileflag(target)
+ local depstargetflag = support.get_depstargetflag(target)
local dependfile = target:dependfile(sourcefile)
local flags = compinst:compflags({sourcefile = sourcefile, target = target}) or {}
local changed = false
@@ -43,7 +43,7 @@ function generate_dependency_for(target, sourcefile, opt)
progress.show(opt.progress, "${color.build.target}<%s> generating.module.deps %s", target:fullname(), sourcefile)
end
- local outputdir = compiler_support.get_outputdir(target, sourcefile)
+ local outputdir = support.get_outputdir(target, sourcefile)
local jsonfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".json"))
local has_depsflags = depsformatflag and depsfileflag and depstargetflag
if has_depsflags and not target:policy("build.c++.gcc.fallbackscanner") then
diff --git a/xmake/rules/c++/modules/modules_support/gcc/compiler_support.lua b/xmake/rules/c++/modules/gcc/support.lua
index 72de29081..264195874 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/compiler_support.lua
+++ b/xmake/rules/c++/modules/gcc/support.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file gcc/compiler_support.lua
+-- @file gcc/support.lua
--
-- imports
@@ -23,7 +23,7 @@ import("core.base.json")
import("core.base.semver")
import("core.project.config")
import("lib.detect.find_tool")
-import(".compiler_support", {inherit = true})
+import(".support", {inherit = true})
-- get includedirs for stl headers
--
diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/msvc/builder.lua
index 8f582438b..ceb3aa4bc 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua
+++ b/xmake/rules/c++/modules/msvc/builder.lua
@@ -28,15 +28,15 @@ import("core.tool.compiler")
import("core.project.config")
import("core.project.depend")
import("private.tools.vstool")
-import("compiler_support")
+import("support")
import(".builder", {inherit = true})
-- get flags for building a module
function _make_modulebuildflags(target, provide, bmifile, opt)
- local ifcoutputflag = compiler_support.get_ifcoutputflag(target)
- local ifconlyflag = compiler_support.get_ifconlyflag(target)
- local interfaceflag = compiler_support.get_interfaceflag(target)
- local internalpartitionflag = compiler_support.get_internalpartitionflag(target)
+ local ifcoutputflag = support.get_ifcoutputflag(target)
+ local ifconlyflag = support.get_ifconlyflag(target)
+ local interfaceflag = support.get_interfaceflag(target)
+ local internalpartitionflag = support.get_internalpartitionflag(target)
local ifconly = (not opt.build_objectfile and ifconlyflag)
local flags
@@ -48,9 +48,9 @@ function _make_modulebuildflags(target, provide, bmifile, opt)
return flags
end
function _compile_one_step(target, bmifile, sourcefile, objectfile, provide, opt)
- local ifcoutputflag = compiler_support.get_ifcoutputflag(target)
- local interfaceflag = compiler_support.get_interfaceflag(target)
- local internalpartitionflag = compiler_support.get_internalpartitionflag(target)
+ local ifcoutputflag = support.get_ifcoutputflag(target)
+ local interfaceflag = support.get_interfaceflag(target)
+ local internalpartitionflag = support.get_internalpartitionflag(target)
-- get flags
local flags = {"-TP"}
if provide then
@@ -64,9 +64,9 @@ function _compile_one_step(target, bmifile, sourcefile, objectfile, provide, opt
end
function _compile_bmi_step(target, bmifile, sourcefile, objectfile, provide, opt)
- local ifcoutputflag = compiler_support.get_ifcoutputflag(target)
- local interfaceflag = compiler_support.get_interfaceflag(target)
- local ifconlyflag = compiler_support.get_ifconlyflag(target)
+ local ifcoutputflag = support.get_ifcoutputflag(target)
+ local interfaceflag = support.get_interfaceflag(target)
+ local ifconlyflag = support.get_ifconlyflag(target)
if not ifconlyflag then
_compile_one_step(target, bmifile, sourcefile, objectfile, provide, opt)
@@ -81,9 +81,9 @@ function _compile_bmi_step(target, bmifile, sourcefile, objectfile, provide, opt
end
function _compile_objectfile_step(target, bmifile, sourcefile, objectfile, provide, opt)
- local ifconlyflag = compiler_support.get_ifconlyflag(target)
- local interfaceflag = compiler_support.get_interfaceflag(target)
- local internalpartitionflag = compiler_support.get_internalpartitionflag(target)
+ local ifconlyflag = support.get_ifconlyflag(target)
+ local interfaceflag = support.get_interfaceflag(target)
+ local internalpartitionflag = support.get_internalpartitionflag(target)
local flags = {"-TP", (provide and provide.interface) and interfaceflag or internalpartitionflag}
if not ifconlyflag then
@@ -102,10 +102,10 @@ end
function _make_headerunitflags(target, headerunit, bmifile)
-- get flags
- local exportheaderflag = compiler_support.get_exportheaderflag(target)
- local headernameflag = compiler_support.get_headernameflag(target)
- local ifcoutputflag = compiler_support.get_ifcoutputflag(target)
- local ifconlyflag = compiler_support.get_ifconlyflag(target)
+ local exportheaderflag = support.get_exportheaderflag(target)
+ local headernameflag = support.get_headernameflag(target)
+ local ifcoutputflag = support.get_ifcoutputflag(target)
+ local ifconlyflag = support.get_ifconlyflag(target)
assert(headernameflag and exportheaderflag, "compiler(msvc): does not support c++ header units!")
local local_directory = (headerunit.type == ":quote") and {"-I" .. path.directory(headerunit.path)} or {}
@@ -163,14 +163,14 @@ end
--
function _get_requiresflags(target, module, opt)
- local referenceflag = compiler_support.get_referenceflag(target)
- local headerunitflag = compiler_support.get_headerunitflag(target)
+ local referenceflag = support.get_referenceflag(target)
+ local headerunitflag = support.get_headerunitflag(target)
local name = module.name
local cachekey = target:fullname() .. name
local requires, requires_changed = is_dependencies_changed(target, module)
- local requiresflags = compiler_support.memcache():get2(cachekey, "requiresflags")
+ local requiresflags = support.memcache():get2(cachekey, "requiresflags")
if not requiresflags or requires_changed then
local deps_flags = {}
for required in requires:orderitems() do
@@ -210,8 +210,8 @@ function _get_requiresflags(target, module, opt)
contains[name] = true
end
end
- compiler_support.memcache():set2(cachekey, "requiresflags", requiresflags)
- compiler_support.memcache():set2(cachekey, "oldrequires", requires)
+ support.memcache():set2(cachekey, "requiresflags", requiresflags)
+ support.memcache():set2(cachekey, "oldrequires", requires)
end
return requiresflags
end
@@ -233,9 +233,9 @@ end
-- populate module map
function populate_module_map(target, modules)
for _, module in pairs(modules) do
- local name, provide, cppfile = compiler_support.get_provided_module(module)
+ local name, provide, cppfile = support.get_provided_module(module)
if provide then
- local bmifile = compiler_support.get_bmi_path(provide.bmi)
+ local bmifile = support.get_bmi_path(provide.bmi)
add_module_to_target_mapper(target, name, cppfile, bmifile, {deps = module.requires})
end
end
@@ -257,8 +257,8 @@ end
-- build module file for batchjobs
function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
local dryrun = option.get("dry-run")
return {
@@ -268,13 +268,13 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
job = batchjobs:newjob(target:fullname() .. "/module/" .. (name or opt.cppfile), function(index, total, jobopt)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
local build, dependinfo
local dependfile = target:dependfile(bmifile or opt.objectfile)
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})
-- needed to detect rebuild of dependencies
@@ -295,7 +295,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
if build then
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
if not dryrun then
local objectdir = path.directory(opt.objectfile)
if not os.isdir(objectdir) then
@@ -327,20 +327,20 @@ end
-- build module file for jobgraph
function make_module_jobgraph(target, jobgraph, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
local dryrun = option.get("dry-run")
local jobname = target:fullname() .. "/module/" .. (name or opt.cppfile)
jobgraph:add(jobname, function(index, total, jobopt)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
local build, dependinfo
local dependfile = target:dependfile(bmifile or opt.objectfile)
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
build, dependinfo = should_build(target, opt.cppfile, bmifile, {name = name, objectfile = opt.objectfile, requires = opt.module.requires})
-- needed to detect rebuild of dependencies
@@ -361,7 +361,7 @@ function make_module_jobgraph(target, jobgraph, opt)
if build then
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
if not dryrun then
local objectdir = path.directory(opt.objectfile)
if not os.isdir(objectdir) then
@@ -394,11 +394,11 @@ end
-- build module file for batchcmds
function make_module_buildcmds(target, batchcmds, opt)
- local name, provide, _ = compiler_support.get_provided_module(opt.module)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
+ local name, provide, _ = support.get_provided_module(opt.module)
+ local bmifile = provide and support.get_bmi_path(provide.bmi)
local mapped_bmi
- if provide and compiler_support.memcache():get2(target:fullname() .. name, "reuse") then
+ if provide and support.memcache():get2(target:fullname() .. name, "reuse") then
mapped_bmi = get_from_target_mapper(target, name).bmi
end
@@ -408,7 +408,7 @@ function make_module_buildcmds(target, batchcmds, opt)
end
-- compile if it's a named module
- if provide or compiler_support.has_module_extension(opt.cppfile) then
+ if provide or support.has_module_extension(opt.cppfile) then
batchcmds:mkdir(path.directory(opt.objectfile))
local fileconfig = target:fileconfig(opt.cppfile)
diff --git a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua b/xmake/rules/c++/modules/msvc/scanner.lua
index 044510fab..b4d68df37 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/msvc/scanner.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file msvc/dependency_scanner.lua
+-- @file msvc/scanner.lua
--
-- imports
@@ -24,15 +24,15 @@ import("core.base.semver")
import("core.project.depend")
import("private.tools.vstool")
import("utils.progress")
-import("compiler_support")
+import("support")
import("builder")
-import(".dependency_scanner", {inherit = true})
+import(".scanner", {inherit = true})
-- generate dependency files
function generate_dependency_for(target, sourcefile, opt)
local msvc = target:toolchain("msvc")
- local scandependenciesflag = compiler_support.get_scandependenciesflag(target)
- local ifcoutputflag = compiler_support.get_ifcoutputflag(target)
+ local scandependenciesflag = support.get_scandependenciesflag(target)
+ local ifcoutputflag = support.get_ifcoutputflag(target)
local common_flags = {"-TP", scandependenciesflag}
local dependfile = target:dependfile(sourcefile)
local compinst = target:compiler("cxx")
@@ -41,7 +41,7 @@ function generate_dependency_for(target, sourcefile, opt)
depend.on_changed(function ()
progress.show(opt.progress, "${color.build.target}<%s> generating.module.deps %s", target:fullname(), sourcefile)
- local outputdir = compiler_support.get_outputdir(target, sourcefile)
+ local outputdir = support.get_outputdir(target, sourcefile)
local jsonfile = path.join(outputdir, path.filename(sourcefile) .. ".module.json")
if scandependenciesflag and not target:policy("build.c++.msvc.fallbackscanner") then
diff --git a/xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua b/xmake/rules/c++/modules/msvc/support.lua
index ca9e8053d..f2b07b999 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua
+++ b/xmake/rules/c++/modules/msvc/support.lua
@@ -15,14 +15,14 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file msvc/compiler_support.lua
+-- @file msvc/support.lua
--
-- imports
import("core.base.semver")
import("core.project.config")
import("lib.detect.find_tool")
-import(".compiler_support", {inherit = true})
+import(".support", {inherit = true})
-- load module support for the current target
function load(target)
diff --git a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua b/xmake/rules/c++/modules/scanner.lua
index 94b8a4804..020f5a954 100644
--- a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/scanner.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file dependency_scanner.lua
+-- @file scanner.lua
--
-- imports
@@ -24,26 +24,26 @@ import("core.base.hashset")
import("core.base.graph")
import("core.base.option")
import("async.runjobs")
-import("compiler_support")
-import("stl_headers")
+import("support")
+import("stlheaders")
-function _dependency_scanner(target)
+function _scanner(target)
local cachekey = tostring(target)
- local dependency_scanner = compiler_support.memcache():get2("dependency_scanner", cachekey)
- if dependency_scanner == nil then
+ local scanner = support.memcache():get2("scanner", cachekey)
+ if scanner == nil then
if target:has_tool("cxx", "clang", "clangxx", "clang_cl") then
- dependency_scanner = import("clang.dependency_scanner", {anonymous = true})
+ scanner = import("clang.scanner", {anonymous = true})
elseif target:has_tool("cxx", "gcc", "gxx") then
- dependency_scanner = import("gcc.dependency_scanner", {anonymous = true})
+ scanner = import("gcc.scanner", {anonymous = true})
elseif target:has_tool("cxx", "cl") then
- dependency_scanner = import("msvc.dependency_scanner", {anonymous = true})
+ scanner = import("msvc.scanner", {anonymous = true})
else
local _, toolname = target:tool("cxx")
raise("compiler(%s): does not support c++ module!", toolname)
end
- compiler_support.memcache():set2("dependency_scanner", cachekey, dependency_scanner)
+ support.memcache():set2("scanner", cachekey, scanner)
end
- return dependency_scanner
+ return scanner
end
function _parse_meta_info(target, metafile)
@@ -118,7 +118,7 @@ function _parse_dependencies_data(target, moduleinfos)
-- try to find the compiled module path in outputs filed (MSVC doesn't generate compiled-module-path)
if not bmifile then
for _, output in ipairs(rule.outputs) do
- if output:endswith(compiler_support.get_bmi_extension(target)) then
+ if output:endswith(support.get_bmi_extension(target)) then
bmifile = output
break
end
@@ -126,11 +126,11 @@ function _parse_dependencies_data(target, moduleinfos)
-- we didn't found the compiled module path, so we assume it
if not bmifile then
- local name = provide["logical-name"] .. compiler_support.get_bmi_extension(target)
+ local name = provide["logical-name"] .. support.get_bmi_extension(target)
-- partition ":" character is invalid path character on windows
-- @see https://github.com/xmake-io/xmake/issues/2954
name = name:replace(":", "-")
- bmifile = path.join(compiler_support.get_outputdir(target, name), name)
+ bmifile = path.join(support.get_outputdir(target, name), name)
end
end
m.provides[provide["logical-name"]] = {
@@ -180,7 +180,7 @@ function _get_edges(nodes, modules)
local named_module_names = hashset.new()
for _, node in ipairs(table.unique(nodes)) do
local module = modules[node]
- local module_name, _, cppfile = compiler_support.get_provided_module(module)
+ local module_name, _, cppfile = support.get_provided_module(module)
if module_name then
if named_module_names:has(module_name) then
raise("duplicate module name detected \"" .. module_name .. "\"\n -> " .. cppfile .. "\n -> " .. name_filemap[module_name])
@@ -191,7 +191,7 @@ function _get_edges(nodes, modules)
if module.requires then
for required_name, _ in table.orderpairs(module.requires) do
for _, required_node in ipairs(nodes) do
- local name, _, _ = compiler_support.get_provided_module(modules[required_node])
+ local name, _, _ = support.get_provided_module(modules[required_node])
if name and name == required_name then
table.insert(edges, {required_node, node})
end
@@ -219,21 +219,21 @@ end
function generate_module_dependencies(target, jobgraph, sourcebatch, opt)
local parsejob = target:fullname() .. "/parse_module_dependencies"
jobgraph:add(parsejob, function (index, total, opt)
- local changed = compiler_support.memcache():get2("modules", "dependencies_changed")
+ local changed = support.memcache():get2("modules", "dependencies_changed")
if changed then
local cachekey = target:fullname() .. "/" .. sourcebatch.rulename
- local moduleinfos = compiler_support.load_moduleinfos(target, sourcebatch)
+ local moduleinfos = support.load_moduleinfos(target, sourcebatch)
local modules = _parse_dependencies_data(target, moduleinfos)
- compiler_support.localcache():set2("modules", cachekey, modules)
- compiler_support.localcache():save()
+ support.localcache():set2("modules", cachekey, modules)
+ support.localcache():save()
end
end)
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local jobname = target:fullname() .. "/generate_module_dependencies/" .. sourcefile
jobgraph:add(jobname, function (index, total, opt)
- local changed = _dependency_scanner(target).generate_dependency_for(target, sourcefile, opt)
+ local changed = _scanner(target).generate_dependency_for(target, sourcefile, opt)
if changed then
- compiler_support.memcache():set2("modules", "dependencies_changed", true)
+ support.memcache():set2("modules", "dependencies_changed", true)
end
end)
jobgraph:add_orders(jobname, parsejob)
@@ -243,7 +243,7 @@ end
-- get module dependencies
function get_module_dependencies(target, sourcebatch)
local cachekey = target:fullname() .. "/" .. sourcebatch.rulename
- local modules = compiler_support.localcache():get2("modules", cachekey)
+ local modules = support.localcache():get2("modules", cachekey)
assert(modules, "no module dependencies!")
return modules
end
@@ -258,7 +258,7 @@ function get_headerunits(target, sourcebatch, modules)
for name, r in pairs(m.requires) do
if r.method ~= "by-name" then
local unittype = r.method == "include-angle" and ":angle" or ":quote"
- if stl_headers.is_stl_header(name) then
+ if stlheaders.is_stlheader(name) then
stl_headerunits = stl_headerunits or {}
if not table.find_if(stl_headerunits, function(i, v) return v.name == name end) then
table.insert(stl_headerunits, {name = name, path = r.path, type = unittype, unique = r.unique})
@@ -334,7 +334,7 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess
local module_depname = line:match("import%s+(.+)%s*;")
-- we need to 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
- if not module_depname and not compiler_support.has_module_extension(sourcefile) then
+ if not module_depname and not support.has_module_extension(sourcefile) then
module_depname = module_name_private
end
if module_depname and not module_deps_set:has(module_depname) then
@@ -349,12 +349,12 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess
module_depname = module_depname:sub(2, -2)
module_dep["lookup-method"] = "include-quote"
module_dep["unique-on-source-path"] = true
- module_dep["source-path"] = compiler_support.find_quote_header_file(target, sourcefile, module_depname)
+ module_dep["source-path"] = support.find_quote_header_file(target, sourcefile, module_depname)
elseif module_depname:startswith("<") then
module_depname = module_depname:sub(2, -2)
module_dep["lookup-method"] = "include-angle"
module_dep["unique-on-source-path"] = true
- module_dep["source-path"] = compiler_support.find_angle_header_file(target, module_depname)
+ module_dep["source-path"] = support.find_angle_header_file(target, module_depname)
end
module_dep["logical-name"] = module_depname
table.insert(module_deps, module_dep)
@@ -364,13 +364,13 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess
end
if module_name_export or internal then
- local outputdir = compiler_support.get_outputdir(target, sourcefile)
+ local outputdir = support.get_outputdir(target, sourcefile)
local provide = {}
provide["logical-name"] = module_name_export or module_name_private
provide["source-path"] = sourcefile
provide["is-interface"] = not internal
- provide["compiled-module-path"] = path.join(outputdir, (module_name_export or module_name_private) .. compiler_support.get_bmi_extension(target))
+ provide["compiled-module-path"] = path.join(outputdir, (module_name_export or module_name_private) .. support.get_bmi_extension(target))
rule.provides = {}
table.insert(rule.provides, provide)
@@ -417,10 +417,10 @@ function sort_modules_by_dependencies(target, objectfiles, modules, opt)
if cycle then
local names = {}
for _, objectfile in ipairs(cycle) do
- local name, _, cppfile = compiler_support.get_provided_module(modules[objectfile])
+ local name, _, cppfile = support.get_provided_module(modules[objectfile])
table.insert(names, name or cppfile)
end
- local name, _, cppfile = compiler_support.get_provided_module(modules[cycle[1]])
+ local name, _, cppfile = support.get_provided_module(modules[cycle[1]])
table.insert(names, name or cppfile)
raise("circular modules dependency detected!\n%s", table.concat(names, "\n -> import "))
end
@@ -435,7 +435,7 @@ function sort_modules_by_dependencies(target, objectfiles, modules, opt)
end
local culleds
for _, objectfile in ipairs(objectfiles_sorted) do
- local name, provide, cppfile = compiler_support.get_provided_module(modules[objectfile])
+ local name, provide, cppfile = support.get_provided_module(modules[objectfile])
local fileconfig = target:fileconfig(cppfile)
local public
local external
diff --git a/xmake/rules/c++/modules/modules_support/stl_headers.lua b/xmake/rules/c++/modules/stlheaders.lua
index 4b2d6ed23..9ba3cbfdf 100644
--- a/xmake/rules/c++/modules/modules_support/stl_headers.lua
+++ b/xmake/rules/c++/modules/stlheaders.lua
@@ -15,14 +15,14 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file stl_headers.lua
+-- @file stlheaders.lua
--
-- imports
import("core.base.hashset")
-- the stl headers list
-function _stl_headers()
+function _stlheaders()
return {
"algorithm",
"forward_list",
@@ -136,20 +136,20 @@ function _stl_headers()
end
-- get all stl headers
-function get_stl_headers()
- local stl_headers = _g.stl_headers
- if stl_headers == nil then
- stl_headers = hashset.from(_stl_headers())
- _g.stl_headers = stl_headers or false
+function get_stlheaders()
+ local stlheaders = _g.stlheaders
+ if stlheaders == nil then
+ stlheaders = hashset.from(_stlheaders())
+ _g.stlheaders = stlheaders or false
end
- return stl_headers or nil
+ return stlheaders or nil
end
-- is stl header?
-function is_stl_header(header)
+function is_stlheader(header)
if header:startswith("experimental/") then
header = header:sub(14, -1)
end
- return get_stl_headers():has(header)
+ return get_stlheaders():has(header)
end
diff --git a/xmake/rules/c++/modules/modules_support/compiler_support.lua b/xmake/rules/c++/modules/support.lua
index fea294ad8..e1e244c08 100644
--- a/xmake/rules/c++/modules/modules_support/compiler_support.lua
+++ b/xmake/rules/c++/modules/support.lua
@@ -13,7 +13,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki, Arthapz
--- @file compiler_support.lua
+-- @file support.lua
--
-- imports
@@ -25,23 +25,23 @@ import("lib.detect.find_file")
import("core.project.project")
import("core.project.config")
-function _compiler_support(target)
+function _support(target)
local cachekey = tostring(target)
- local compiler_support = memcache():get2("compiler_support", cachekey)
- if compiler_support == nil then
+ local support = memcache():get2("support", cachekey)
+ if support == nil then
if target:has_tool("cxx", "clang", "clangxx", "clang_cl") then
- compiler_support = import("clang.compiler_support", {anonymous = true})
+ support = import("clang.support", {anonymous = true})
elseif target:has_tool("cxx", "gcc", "gxx") then
- compiler_support = import("gcc.compiler_support", {anonymous = true})
+ support = import("gcc.support", {anonymous = true})
elseif target:has_tool("cxx", "cl") then
- compiler_support = import("msvc.compiler_support", {anonymous = true})
+ support = import("msvc.support", {anonymous = true})
else
local _, toolname = target:tool("cxx")
raise("compiler(%s): does not support c++ module!", toolname)
end
- memcache():set2("compiler_support", cachekey, compiler_support)
+ memcache():set2("support", cachekey, support)
end
- return compiler_support
+ return support
end
-- load module support for the current target
@@ -61,17 +61,17 @@ function load(target)
end
-- load module support for the specific compiler
- _compiler_support(target).load(target)
+ _support(target).load(target)
end
-- strip flags not relevent for module reuse
function strip_flags(target, flags)
- return _compiler_support(target).strip_flags(target, flags)
+ return _support(target).strip_flags(target, flags)
end
-- get bmi extension
function get_bmi_extension(target)
- return _compiler_support(target).get_bmi_extension()
+ return _support(target).get_bmi_extension()
end
-- get bmi path
@@ -139,7 +139,7 @@ function find_quote_header_file(target, sourcefile, file)
end
function find_angle_header_file(target, file)
- local headerpaths = _compiler_support(target).toolchain_includedirs(target)
+ local headerpaths = _support(target).toolchain_includedirs(target)
for _, dep in ipairs(target:orderdeps()) do
local includedirs = table.join(dep:get("sysincludedirs") or {}, dep:get("includedirs") or {})
table.join2(headerpaths, includedirs)
@@ -156,7 +156,7 @@ end
-- get stdmodules
function get_stdmodules(target)
- return _compiler_support(target).get_stdmodules(target)
+ return _support(target).get_stdmodules(target)
end
-- get memcache
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index a27633182..2c7eaedff 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -28,11 +28,11 @@ rule("c++.build.modules")
add_deps("c++.build.modules.install")
on_config(function (target)
- import("modules_support.compiler_support")
+ import("support")
-- we disable to build across targets in parallel, because the source files may depend on other target modules
-- @see https://github.com/xmake-io/xmake/issues/1858
- if compiler_support.contains_modules(target) then
+ if support.contains_modules(target) then
-- @note this will cause cross-parallel builds to be disabled for all sub-dependent targets,
-- even if some sub-targets do not contain C++ modules.
--
@@ -48,7 +48,7 @@ rule("c++.build.modules")
target:set("policy", "build.ccache", false)
-- load compiler support
- compiler_support.load(target)
+ support.load(target)
-- mark this target with modules
target:data_set("cxx.has_modules", true)
@@ -73,29 +73,29 @@ rule("c++.build.modules.builder")
-- generate module dependencies
on_prepare_files(function (target, jobgraph, sourcebatch, opt)
if target:data("cxx.has_modules") then
- import("modules_support.builder")
- import("modules_support.dependency_scanner")
+ import("builder")
+ import("scanner")
-- patch sourcebatch
builder.patch_sourcebatch(target, sourcebatch)
-- generate module dependencies
- dependency_scanner.generate_module_dependencies(target, jobgraph, sourcebatch, opt)
+ scanner.generate_module_dependencies(target, jobgraph, sourcebatch, opt)
end
end, {jobgraph = true})
-- parallel build support to accelerate `xmake build` to build modules
before_build_files(function(target, jobgraph, sourcebatch, opt)
if target:data("cxx.has_modules") then
- import("modules_support.compiler_support")
- import("modules_support.dependency_scanner")
- import("modules_support.builder")
+ import("support")
+ import("scanner")
+ import("builder")
-- get module dependencies
- local modules = dependency_scanner.get_module_dependencies(target, sourcebatch)
+ local modules = scanner.get_module_dependencies(target, sourcebatch)
if not target:is_moduleonly() then
-- avoid building non referenced modules
- local build_objectfiles, link_objectfiles = dependency_scanner.sort_modules_by_dependencies(target, sourcebatch.objectfiles, modules)
+ local build_objectfiles, link_objectfiles = scanner.sort_modules_by_dependencies(target, sourcebatch.objectfiles, modules)
sourcebatch.objectfiles = build_objectfiles
-- build modules and headerunits
@@ -105,8 +105,8 @@ rule("c++.build.modules.builder")
sourcebatch.objectfiles = {}
end
- compiler_support.localcache():set2(target:fullname(), "c++.modules", modules)
- compiler_support.localcache():save()
+ support.localcache():set2(target:fullname(), "c++.modules", modules)
+ support.localcache():save()
else
-- avoid duplicate linking of object files of non-module programs
sourcebatch.objectfiles = {}
@@ -116,15 +116,15 @@ rule("c++.build.modules.builder")
-- serial compilation only, usually used to support project generator
before_buildcmd_files(function(target, batchcmds, sourcebatch, opt)
if target:data("cxx.has_modules") then
- import("modules_support.compiler_support")
- import("modules_support.dependency_scanner")
- import("modules_support.builder")
+ import("support")
+ import("scanner")
+ import("builder")
-- get module dependencies
- local modules = dependency_scanner.get_module_dependencies(target, sourcebatch)
+ local modules = scanner.get_module_dependencies(target, sourcebatch)
if not target:is_moduleonly() then
-- avoid building non referenced modules
- local build_objectfiles, link_objectfiles = dependency_scanner.sort_modules_by_dependencies(target, sourcebatch.objectfiles, modules)
+ local build_objectfiles, link_objectfiles = scanner.sort_modules_by_dependencies(target, sourcebatch.objectfiles, modules)
sourcebatch.objectfiles = build_objectfiles
-- build headerunits and modules
@@ -135,8 +135,8 @@ rule("c++.build.modules.builder")
sourcebatch.objectfiles = {}
end
- compiler_support.localcache():set2(target:fullname(), "c++.modules", modules)
- compiler_support.localcache():save()
+ support.localcache():set2(target:fullname(), "c++.modules", modules)
+ support.localcache():save()
else
sourcebatch.sourcefiles = {}
sourcebatch.objectfiles = {}
@@ -146,17 +146,17 @@ rule("c++.build.modules.builder")
after_clean(function (target)
import("core.base.option")
- import("modules_support.compiler_support")
+ import("support")
import("private.action.clean.remove_files")
-- we cannot use target:data("cxx.has_modules"),
-- because on_config will be not called when cleaning targets
- if compiler_support.contains_modules(target) then
- remove_files(compiler_support.modules_cachedir(target))
+ if support.contains_modules(target) then
+ remove_files(support.modules_cachedir(target))
if option.get("all") then
- remove_files(compiler_support.stlmodules_cachedir(target))
- compiler_support.localcache():clear()
- compiler_support.localcache():save()
+ remove_files(support.stlmodules_cachedir(target))
+ support.localcache():clear()
+ support.localcache():save()
end
end
end)
@@ -166,22 +166,22 @@ rule("c++.build.modules.install")
set_extensions(".mpp", ".mxx", ".cppm", ".ixx")
before_install(function (target)
- import("modules_support.compiler_support")
- import("modules_support.builder")
+ import("support")
+ import("builder")
-- we cannot use target:data("cxx.has_modules"),
-- because on_config will be not called when installing targets
- if compiler_support.contains_modules(target) then
- local modules = compiler_support.localcache():get2(target:fullname(), "c++.modules")
+ if support.contains_modules(target) then
+ local modules = support.localcache():get2(target:fullname(), "c++.modules")
builder.generate_metadata(target, modules)
- compiler_support.add_installfiles_for_modules(target)
+ support.add_installfiles_for_modules(target)
end
end)
before_uninstall(function (target)
- import("modules_support.compiler_support")
- if compiler_support.contains_modules(target) then
- compiler_support.add_installfiles_for_modules(target)
+ import("support")
+ if support.contains_modules(target) then
+ support.add_installfiles_for_modules(target)
end
end)