summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/clang/builder.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-08-25 12:48:58 +0200
committerArthur LAURENT <[email protected]>2025-08-25 12:48:58 +0200
commit0f3fd89593450c21b2fb75e89950f47f9a85202e (patch)
treeb1c3081753ea4e814a45812c24a284b34a04b30e /xmake/rules/c++/modules/clang/builder.lua
parent57a0f0e067544e6d4767a4fa37102ce949d465e3 (diff)
feat(C++ modules support) use a file for requires files when --verbose or --diagnosis is supplied
Diffstat (limited to 'xmake/rules/c++/modules/clang/builder.lua')
-rw-r--r--xmake/rules/c++/modules/clang/builder.lua47
1 files changed, 39 insertions, 8 deletions
diff --git a/xmake/rules/c++/modules/clang/builder.lua b/xmake/rules/c++/modules/clang/builder.lua
index df65bb213..2a5b85fc6 100644
--- a/xmake/rules/c++/modules/clang/builder.lua
+++ b/xmake/rules/c++/modules/clang/builder.lua
@@ -104,6 +104,24 @@ function _make_headerunitflags(target, headerunit)
return flags
end
+
+function _get_mapper_str(target, module, opt)
+ local mapper_str
+ if target:policy("build.c++.modules.hide_dependencies") and option.get("diagnosis") then
+ if not opt.headerunit then
+ local requires_flagsfile = target:autogenfile(module.sourcefile .. ".requiresflags.txt")
+ if os.isfile(requires_flagsfile) then
+ if module.name then
+ mapper_str = format("\n${dim color.warning}mapper file for %s (%s) --------\n%s\n--------", module.name, module.sourcefile, io.readfile(requires_flagsfile):trim())
+ else
+ mapper_str = format("\n${dim color.warning}mapper file for %s --------\n%s\n--------", module.sourcefile, io.readfile(requires_flagsfile):trim())
+ end
+ end
+ end
+ end
+ return mapper_str
+end
+
-- do compile
function _compile(target, flags, module, opt)
@@ -119,7 +137,7 @@ function _compile(target, flags, module, opt)
if option.get("verbose") then
cmd = "\n" .. compinst:compcmd(sourcefile, outputfile, {target = target, compflags = flags, sourcekind = "cxx", rawargs = true})
end
- show_progress(target, module, table.join(opt, {cmd = cmd}))
+ show_progress(target, module, table.join(opt, {cmd = cmd, suffix = _get_mapper_str(target, module, opt)}))
-- do compile
if not dryrun then
@@ -142,7 +160,7 @@ function _batchcmds_compile(batchcmds, target, flags, module, opt)
if option.get("verbose") then
cmd = "\n" .. compinst:compcmd(sourcefile, outputfile, {target = target, compflags = flags, sourcekind = "cxx", rawargs = true})
end
- show_progress(target, module, table.join(opt, {cmd = cmd, batchcmds = batchcmds}))
+ show_progress(target, module, table.join(opt, {cmd = cmd, batchcmds = batchcmds, suffix = _get_mapper_str(target, module, opt)}))
-- do compile
batchcmds:compilev(flags, {compiler = compinst, sourcekind = "cxx", verbose = false})
@@ -194,15 +212,28 @@ end
function _append_requires_flags(target, module)
local cxxflags = {}
local requiresflags = _get_requiresflags(target, module)
- for _, flag in ipairs(requiresflags) do
- -- we need to wrap flag to support flag with space
- if type(flag) == "string" and flag:find(" ", 1, true) then
- table.insert(cxxflags, {flag})
+ local hide_dependencies = target:policy("build.c++.modules.hide_dependencies")
+ if #requiresflags> 0 then
+ for _, flag in ipairs(requiresflags) do
+ -- we need to wrap flag to support flag with space
+ if type(flag) == "string" and flag:find(" ", 1, true) and not hide_dependencies then
+ table.insert(cxxflags, {flag})
+ else
+ if hide_dependencies then
+ table.insert(cxxflags, '"' .. path.unix(flag) .. '"')
+ else
+ table.insert(cxxflags, flag)
+ end
+ end
+ end
+ if hide_dependencies then
+ local requires_flagsfile = target:autogenfile(module.sourcefile .. ".requiresflags.txt")
+ io.writefile(requires_flagsfile, path.unix(table.concat(cxxflags, "\n")))
+ target:fileconfig_add(module.sourcefile, {force = {cxxflags = {{"@" .. requires_flagsfile}}}})
else
- table.insert(cxxflags, flag)
+ target:fileconfig_add(module.sourcefile, {force = {cxxflags = cxxflags}})
end
end
- target:fileconfig_add(module.sourcefile, {force = {cxxflags = cxxflags}})
end
function append_requires_flags(target, built_modules)