summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-03-09 18:59:42 +0100
committerArthur LAURENT <[email protected]>2024-03-09 19:00:03 +0100
commit326e26a5268233f3573b6104f69122b1ef5148eb (patch)
treeaee999abce8127cf0f1e08cdedd10fcde28d1e88 /xmake/rules/c++/modules/modules_support
parentf0448d703f5288adc3190810573ca9165c1a49db (diff)
fix private dependency C++ modules objectfile handling
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/builder.lua6
-rw-r--r--xmake/rules/c++/modules/modules_support/compiler_support.lua3
-rw-r--r--xmake/rules/c++/modules/modules_support/dependency_scanner.lua3
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc/builder.lua6
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/builder.lua6
5 files changed, 16 insertions, 8 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua
index 6a912bed4..6c36feff6 100644
--- a/xmake/rules/c++/modules/modules_support/clang/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua
@@ -248,6 +248,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
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
@@ -258,7 +259,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat")})
end
else
- if not public and not external then
+ if (not public and not external) or (external and private_dep) then
progress.show((index * 100) / total, "${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")})
else
@@ -317,6 +318,7 @@ function make_module_buildcmds(target, batchcmds, opt)
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
@@ -327,7 +329,7 @@ function make_module_buildcmds(target, batchcmds, opt)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds})
end
else
- if not public and not external then
+ 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
diff --git a/xmake/rules/c++/modules/modules_support/compiler_support.lua b/xmake/rules/c++/modules/modules_support/compiler_support.lua
index 9d3d4fadf..d7cf0b262 100644
--- a/xmake/rules/c++/modules/modules_support/compiler_support.lua
+++ b/xmake/rules/c++/modules/modules_support/compiler_support.lua
@@ -85,7 +85,8 @@ function cull_objectfiles(target, modules, sourcebatch)
local fileconfig = target:fileconfig(sourcefile)
local public = fileconfig and fileconfig.public
local external = fileconfig and fileconfig.external
- if not public and not external then
+ local private_dep = fileconfig and fileconfig.private_dep
+ if (not public and not external) or (external and private_dep) then
table.insert(sourcebatch.objectfiles, objectfile)
end
else
diff --git a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua
index ef0e66cc6..d59a4436a 100644
--- a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua
@@ -439,6 +439,7 @@ function get_targetdeps_modules(target)
local sourcefiles
for _, dep in ipairs(target:orderdeps()) do
local sourcebatch = dep:sourcebatches()["c++.build.modules.builder"]
+ local private_dep = target:extraconf("deps", dep:name(), "private") or not target:extraconf("deps", dep:name(), "public")
if sourcebatch and sourcebatch.sourcefiles then
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local fileconfig = dep:fileconfig(sourcefile)
@@ -446,7 +447,7 @@ function get_targetdeps_modules(target)
if public then
sourcefiles = sourcefiles or {}
table.insert(sourcefiles, sourcefile)
- target:fileconfig_add(sourcefile, {external = true})
+ target:fileconfig_add(sourcefile, {external = true, private_dep = private_dep})
end
end
end
diff --git a/xmake/rules/c++/modules/modules_support/gcc/builder.lua b/xmake/rules/c++/modules/modules_support/gcc/builder.lua
index f290ed262..0c9b8c1b1 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc/builder.lua
@@ -214,6 +214,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
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
@@ -226,7 +227,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
sourcefile = opt.cppfile
end
else
- if not public and not external then
+ if (not public and not external) or (external and private_dep) then
progress.show((index * 100) / total, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
sourcefile = opt.cppfile
else
@@ -286,6 +287,7 @@ function make_module_buildcmds(target, batchcmds, opt)
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
@@ -298,7 +300,7 @@ function make_module_buildcmds(target, batchcmds, opt)
sourcefile = opt.cppfile
end
else
- if not public and not external then
+ 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
diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
index 5bb9fc4d8..a46dae34a 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
@@ -312,6 +312,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
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
@@ -322,7 +323,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide)
end
else
- if not public and not external then
+ if (not public and not external) or (external and private_dep) then
progress.show((index * 100) / total, "${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)
else
@@ -381,6 +382,7 @@ function make_module_buildcmds(target, batchcmds, opt)
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
@@ -391,7 +393,7 @@ function make_module_buildcmds(target, batchcmds, opt)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds})
end
else
- if not public and not external then
+ 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