summaryrefslogtreecommitdiff
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
parent4a6acafb07f5af250c51604c731dba7fafdd8547 (diff)
fix missing objectfiles for private modules
-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
-rw-r--r--xmake/rules/c++/modules/xmake.lua18
5 files changed, 41 insertions, 15 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
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index d9e26e41f..96446e2ec 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -76,7 +76,12 @@ rule("c++.build.modules.builder")
end
-- append std module
- table.join2(sourcebatch.sourcefiles, compiler_support.get_stdmodules(target) or {})
+ local std_modules = compiler_support.get_stdmodules(target)
+ if std_modules then
+ table.join2(sourcebatch.sourcefiles, std_modules)
+ target:fileconfig_set(std_modules[1], {external = true})
+ target:fileconfig_set(std_modules[2], {external = true})
+ end
-- extract packages modules dependencies
local package_modules_data = dependency_scanner.get_all_packages_modules(target, opt)
@@ -84,7 +89,7 @@ rule("c++.build.modules.builder")
-- append to sourcebatch
for _, package_module_data in table.orderpairs(package_modules_data) do
table.insert(sourcebatch.sourcefiles, package_module_data.file)
- target:fileconfig_add(package_module_data.file, {external = true, defines = package_module_data.metadata.defines})
+ target:fileconfig_set(package_module_data.file, {external = true, defines = package_module_data.metadata.defines})
end
end
@@ -123,7 +128,12 @@ rule("c++.build.modules.builder")
end
-- append std module
- table.join2(sourcebatch.sourcefiles, compiler_support.get_stdmodules(target) or {})
+ local std_modules = compiler_support.get_stdmodules(target)
+ if std_modules then
+ table.join2(sourcebatch.sourcefiles, std_modules)
+ target:fileconfig_set(std_modules[1], {external = true})
+ target:fileconfig_set(std_modules[2], {external = true})
+ end
-- extract packages modules dependencies
local package_modules_data = dependency_scanner.get_all_packages_modules(target, opt)
@@ -131,7 +141,7 @@ rule("c++.build.modules.builder")
-- append to sourcebatch
for _, package_module_data in table.orderpairs(package_modules_data) do
table.insert(sourcebatch.sourcefiles, package_module_data.file)
- target:fileconfig_add(package_module_data.file, {external = true, defines = package_module_data.metadata.defines})
+ target:fileconfig_set(package_module_data.file, {external = true, defines = package_module_data.metadata.defines})
end
end