summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-07-22 19:03:17 +0200
committerArthur LAURENT <[email protected]>2024-07-22 19:03:17 +0200
commit261185f6819174884debb649cf7f7678b8130b2a (patch)
tree98d67a79f0c41ce0faaf5a90d4248fcffe3c6166
parentddf9c7253f9597d2fb96ec24f4f974df8070cbb0 (diff)
fix module handling for batchcmds and some cleanups
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/builder.lua18
-rw-r--r--xmake/rules/c++/modules/modules_support/compiler_support.lua6
-rw-r--r--xmake/rules/c++/modules/modules_support/dependency_scanner.lua3
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc/builder.lua25
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/builder.lua18
5 files changed, 27 insertions, 43 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua
index eda23566c..174599229 100644
--- a/xmake/rules/c++/modules/modules_support/clang/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua
@@ -299,24 +299,20 @@ 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 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:name(), name or opt.cppfile)
+ _compile_bmi_step(target, bmifile, opt.cppfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds})
+ end
+ else
if mapped_bmi then
batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
- _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, {batchcmds = batchcmds})
+ _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds})
else
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})
end
- else
- 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
- batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
- _compile_bmi_step(target, bmifile, opt.cppfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds})
- end
end
else
batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files
diff --git a/xmake/rules/c++/modules/modules_support/compiler_support.lua b/xmake/rules/c++/modules/modules_support/compiler_support.lua
index 2e4d1f5ef..ecc085358 100644
--- a/xmake/rules/c++/modules/modules_support/compiler_support.lua
+++ b/xmake/rules/c++/modules/modules_support/compiler_support.lua
@@ -86,11 +86,6 @@ end
-- cull sourcebatch objectfiles
function cull_objectfiles(target, modules, sourcebatch)
- -- don't cull for executables
- -- if target:is_binary() then
- -- return
- -- end
-
sourcebatch.objectfiles = {}
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local objectfile = target:objectfile(sourcefile)
@@ -101,7 +96,6 @@ function cull_objectfiles(target, modules, sourcebatch)
local public = fileconfig and fileconfig.public
local external = fileconfig and fileconfig.external
local from_moduleonly = external and external.moduleonly
- local private_dep = fileconfig and fileconfig.private_dep
if not external or from_moduleonly then
table.insert(sourcebatch.objectfiles, objectfile)
end
diff --git a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua
index 68b25c077..fe6e0fc9f 100644
--- a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua
@@ -450,7 +450,6 @@ 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)
@@ -458,7 +457,7 @@ function get_targetdeps_modules(target)
if public then
sourcefiles = sourcefiles or {}
table.insert(sourcefiles, sourcefile)
- target:fileconfig_add(sourcefile, {external = {moduleonly = dep:is_moduleonly()}, private_dep = private_dep})
+ target:fileconfig_add(sourcefile, {external = {moduleonly = dep:is_moduleonly()}})
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 cbb8472a0..5866ad044 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc/builder.lua
@@ -279,11 +279,18 @@ 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 from_moduleonly = external and external.moduleonly
local bmifile = mapped_bmi or bmifile
local flags = {"-x", "c++"}
local sourcefile
- if target:is_binary() then
+ 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:name(), name or opt.cppfile)
+ local module_onlyflag = compiler_support.get_moduleonlyflag(target)
+ table.insert(flags, module_onlyflag)
+ sourcefile = opt.cppfile
+ end
+ else
if mapped_bmi then
batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
sourcefile = bmifile
@@ -291,21 +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)
sourcefile = opt.cppfile
end
- else
- 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
- batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
- local module_onlyflag = compiler_support.get_moduleonlyflag(target)
- table.insert(flags, module_onlyflag)
- sourcefile = opt.cppfile
- end
end
if option.get("diagnosis") then
batchcmds:print("mapper file: %s", io.readfile(module_mapper))
end
- _batchcmds_compile(batchcmds, target, flags, sourcefile, opt.objectfile)
+ if sourcefile then
+ _batchcmds_compile(batchcmds, target, flags, sourcefile, opt.objectfile)
+ end
batchcmds:rm(module_mapper)
else
batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files
diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
index 2d79e48ac..737721bcd 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
@@ -312,7 +312,6 @@ 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 from_moduleonly = external and external.moduleonly
local bmifile = mapped_bmi or bmifile
if external and not from_moduleonly then
@@ -364,9 +363,14 @@ 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 from_moduleonly = external and external.moduleonly
local bmifile = mapped_bmi or bmifile
- if target:is_binary() then
+ 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:name(), name or opt.cppfile)
+ _compile_bmi_step(target, bmifile, opt.cppfile, provide, {batchcmds = batchcmds})
+ end
+ else
if mapped_bmi then
batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile)
_compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds})
@@ -374,14 +378,6 @@ 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)
_compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds})
end
- else
- 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
- batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.bmi.$(mode) %s", target:name(), name or opt.cppfile)
- _compile_bmi_step(target, bmifile, opt.cppfile, provide, {batchcmds = batchcmds})
- end
end
else
batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files