summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-01-30 17:04:35 +0100
committerArthur LAURENT <[email protected]>2024-01-30 17:10:18 +0100
commita2ccc580a274200d889d199094e7201076594f0d (patch)
tree46a6bbeb2c1cfafb9fbd36f7a627610d57ce49ed /xmake/rules/c++/modules/modules_support
parent7e1cf4ff6bfb9ba73dd7c99c3f1b5d4017bb057b (diff)
use try{} instead of assert to preserve iorunv error colors
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/builder.lua4
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua5
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc/builder.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua5
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/builder.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua6
6 files changed, 11 insertions, 13 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua
index 947a03bfc..184ebbdf5 100644
--- a/xmake/rules/c++/modules/modules_support/clang/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua
@@ -89,9 +89,9 @@ function _compile(target, flags, cppfile)
if not dryrun then
-- do compile
if msvc then
- assert(os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()}))
+ try{function() return os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()}) end}
else
- assert(os.iorunv(compinst:program(), flags))
+ try{function() return os.iorunv(compinst:program(), flags) end}
end
end
end
diff --git a/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua
index 6f78b3a41..c64d05dac 100644
--- a/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua
@@ -51,8 +51,7 @@ function generate_dependencies(target, sourcebatch, opt)
local flags = table.join({"--format=p1689", "--",
clang_path, "-x", "c++", runtime_flag, "-c", sourcefile, "-o", target:objectfile(sourcefile)}, compflags or {})
vprint(table.concat(table.join(clangscandeps, flags), " "))
- local outdata, errdata = os.iorunv(clangscandeps, flags)
- assert(errdata, errdata)
+ local outdata = try{function() return os.iorunv(clangscandeps, flags) end}
io.writefile(jsonfile, outdata)
else
@@ -66,7 +65,7 @@ function generate_dependencies(target, sourcebatch, opt)
end)
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
local flags = table.join(compflags or {}, keepsystemincludesflag or {}, {"-E", "-x", "c++", file, "-o", ifile})
- os.vrunv(compinst:program(), flags)
+ try{function() os.iorunv(compinst:program(), flags) end}
local content = io.readfile(ifile)
os.rm(ifile)
return content
diff --git a/xmake/rules/c++/modules/modules_support/gcc/builder.lua b/xmake/rules/c++/modules/modules_support/gcc/builder.lua
index 5776b7010..13755660d 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc/builder.lua
@@ -79,7 +79,7 @@ function _compile(target, flags, sourcefile, outputfile)
if not dryrun then
-- do compile
- assert(compinst:compile(sourcefile, outputfile, {compflags = flags}))
+ compinst:compile(sourcefile, outputfile, {compflags = flags})
end
end
diff --git a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua
index 1e89f0244..72e8b475f 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua
@@ -49,18 +49,17 @@ function generate_dependencies(target, sourcebatch, opt)
local dfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".d"))
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
local flags = table.join(compflags or {}, baselineflags, {sourcefile, "-MT", jsonfile, "-MD", "-MF", dfile, depsformatflag, depsfileflag .. jsonfile, depstargetflag .. target:objectfile(sourcefile), "-o", ifile})
- os.vrunv(path.translate(compinst:program()), flags)
+ try{function() return os.iorunv(path.translate(compinst:program()), flags) end}
os.rm(ifile)
os.rm(dfile)
else
fallback_generate_dependencies(target, jsonfile, sourcefile, function(file)
- local compinst = target:compiler("cxx")
local compflags = compinst:compflags({sourcefile = file, target = target})
-- exclude -fmodule* flags because, when they are set gcc try to find bmi of imported modules but they don't exists a this point of compilation
table.remove_if(compflags, function(_, flag) return flag:startswith("-fmodule") end)
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
local flags = table.join(baselineflags, compflags or {}, {file, "-o", ifile})
- os.vrunv(compinst:program(), flags)
+ try{function() return os.iorunv(compinst:program(), flags) end}
local content = io.readfile(ifile)
os.rm(ifile)
return content
diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
index 3b295ca6b..929b0cd5d 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua
@@ -86,7 +86,7 @@ function _compile(target, flags, sourcefile)
if not dryrun then
-- do compile
- assert(os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()}))
+ try{function() return os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()}) end}
end
end
diff --git a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua
index ed5027e22..6cf095a01 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua
@@ -48,14 +48,14 @@ function generate_dependencies(target, sourcebatch, opt)
local compinst = target:compiler("cxx")
local msvc = target:toolchain("msvc")
local compflags = table.join(compinst:compflags({sourcefile = sourcefile, target = target}) or {}, common_flags, flags)
- os.vrunv(compinst:program(), winos.cmdargv(compflags), {envs = msvc:runenvs()})
+ try{function() return os.iorunv(compinst:program(), winos.cmdargv(compflags), {envs = msvc:runenvs()}) end}
else
fallback_generate_dependencies(target, jsonfile, sourcefile, function(file)
local compinst = target:compiler("cxx")
local compflags = compinst:compflags({sourcefile = file, target = target})
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
- os.vrunv(compinst:program(), table.join(compflags,
- {"/P", "-TP", file, "/Fi" .. ifile}), {envs = msvc:runenvs()})
+ try{function() return os.vrunv(compinst:program(), table.join(compflags,
+ {"/P", "-TP", file, "/Fi" .. ifile}), {envs = msvc:runenvs()}) end}
local content = io.readfile(ifile)
os.rm(ifile)
return content