summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-02-04 20:24:24 +0100
committerArthur LAURENT <[email protected]>2024-02-05 13:58:27 +0100
commit2328ca4f94c6a7680c72fc92f43a39c4f753d7a3 (patch)
treeaa3584bc921b737b5e00830754075a46e67156b1 /xmake/rules/c++/modules/modules_support
parent4a6acafb07f5af250c51604c731dba7fafdd8547 (diff)
fix missing objectfiles for private modules
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
-rw-r--r--xmake/rules/c++/modules/modules_support/builder.lua5
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/builder.lua14
-rw-r--r--xmake/rules/c++/modules/modules_support/compiler_support.lua9
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/builder.lua10
4 files changed, 27 insertions, 11 deletions
diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua
index ca7a3cbb8..62b874bfb 100644
--- a/xmake/rules/c++/modules/modules_support/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/builder.lua
@@ -45,11 +45,6 @@ function _build_modules(target, sourcebatch, modules, opt)
cppfile = cppfile or module.cppfile
local fileconfig = target:fileconfig(cppfile)
- local bmifile = provide and compiler_support.get_bmi_path(provide.bmi)
- -- add objectfile if module is not from external dep
- if not (fileconfig and fileconfig.external) then
- target:add("objectfiles", objectfile)
- end
local deps = {}
for _, dep in ipairs(table.keys(module.requires or {})) do
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua
index 6a7237eb2..5050be7cf 100644
--- a/xmake/rules/c++/modules/modules_support/clang/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua
@@ -242,7 +242,10 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
end
end
- local build_objectfile = target:kind() == "binary"
+ local fileconfig = target:fileconfig(opt.cppfile)
+ local public = fileconfig and fileconfig.public
+ local external = fileconfig and fileconfig.external
+ local build_objectfile = target:kind() == "binary" or (not public and not external)
local precompile, first_step, second_step = _make_modulebuildflags(target, provide, bmifile, {sourcefile = opt.cppfile, build_objectfile = build_objectfile, name = name})
@@ -295,8 +298,13 @@ function make_module_buildcmds(target, batchcmds, opt)
batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
batchcmds:mkdir(path.directory(opt.objectfile))
- local precompile, first_step, second_step = _make_modulebuildflags(target, provide, bmifile, {batchcmds = true, sourcefile = opt.cppfile, build_objectfile = build_objectfile, name = name})
- _batchcmds_compile(batchcmds, target, first_step, opt.cppfile, precompile and bmifile or opt.objectfile)
+ local fileconfig = target:fileconfig(opt.cppfile)
+ local public = fileconfig and fileconfig.public
+ local external = fileconfig and fileconfig.external
+ local build_objectfile = target:kind() == "binary" or (not public and not external)
+
+ local precompile, first_step, second_step = _make_modulebuildflags(target, provide, bmifile, {batchcmds = true, sourcefile = opt.cppfile, build_objectfile = build_objectfile, name = name})
+ _batchcmds_compile(batchcmds, target, first_step, opt.cppfile, precompile and bmifile or opt.objectfile)
local precompile, first_step, second_step = _make_modulebuildflags(target, provide, bmifile, {batchcmds = true, sourcefile = opt.cppfile, external = external, name = name})
_batchcmds_compile(batchcmds, target, first_step, opt.cppfile, precompile and bmifile or opt.objectfile)
diff --git a/xmake/rules/c++/modules/modules_support/compiler_support.lua b/xmake/rules/c++/modules/modules_support/compiler_support.lua
index 8c03c9dba..d9d849454 100644
--- a/xmake/rules/c++/modules/modules_support/compiler_support.lua
+++ b/xmake/rules/c++/modules/modules_support/compiler_support.lua
@@ -77,7 +77,14 @@ function cull_objectfiles(target, modules, sourcebatch)
local module = modules[objectfile]
local _, provide, _ = get_provided_module(module)
- if not provide then
+ if provide then
+ local fileconfig = target:fileconfig(sourcefile)
+ local public = fileconfig and fileconfig.public
+ local external = fileconfig and fileconfig.external
+ if not public and not external then
+ table.insert(sourcebatch.objectfiles, objectfile)
+ end
+ else
table.insert(sourcebatch.objectfiles, objectfile)
end
end
diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
index e7b2c8543..702f3f2f2 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
@@ -259,7 +259,10 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt)
end
end
- local build_objectfile = target:kind() == "binary"
+ local fileconfig = target:fileconfig(opt.cppfile)
+ local public = fileconfig and fileconfig.public
+ local external = fileconfig and fileconfig.external
+ local build_objectfile = target:kind() == "binary" or (not public and not external)
local flags = _make_modulebuildflags(target, provide, bmifile, {build_objectfile = build_objectfile})
_compile(target, flags, opt.cppfile, opt.objectfile)
@@ -306,7 +309,10 @@ function make_module_buildcmds(target, batchcmds, should_build, mark_build, opt)
batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile)
batchcmds:mkdir(path.directory(opt.objectfile))
- local build_objectfile = target:kind() == "binary"
+ local fileconfig = target:fileconfig(opt.cppfile)
+ local public = fileconfig and fileconfig.public
+ local external = fileconfig and fileconfig.external
+ local build_objectfile = target:kind() == "binary" or (not public and not external)
local flags = _make_modulebuildflags(target, provide, bmifile, opt.cppfile, {batchcmds = true, build_objectfile = build_objectfile})
_batchcmds_compile(batchcmds, target, flags, opt.cppfile, opt.objectfile)
else