summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-01 00:23:43 +0800
committerruki <[email protected]>2022-07-01 00:23:43 +0800
commit6766057844be6158cb96b712d8e3fe6512507682 (patch)
tree29eb581087448af805667f4dcd6e296a4c9c55f1
parent9c2b26364c39a5cc933f1d08670fe338c789bdb9 (diff)
improve to remove cppfile
-rw-r--r--xmake/modules/core/tools/cl.lua11
-rw-r--r--xmake/modules/core/tools/gcc.lua11
2 files changed, 20 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index e07ba783d..8d90e47a4 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -397,6 +397,11 @@ function _is_in_vstudio()
return is_in_vstudio
end
+-- get preprocess file path
+function _get_cppfile(sourcefile, objectfile)
+ return path.join(path.directory(objectfile), "__cpp_" .. path.basename(objectfile) .. path.extension(sourcefile))
+end
+
-- do preprocess
function _preprocess(program, argv, opt)
@@ -463,7 +468,7 @@ function _preprocess(program, argv, opt)
end
-- do preprocess
- local cppfile = path.join(path.directory(objectfile), "__cpp_" .. path.basename(objectfile) .. path.extension(sourcefile))
+ local cppfile = _get_cppfile(sourcefile, objectfile)
local cppfiledir = path.directory(cppfile)
if not os.isdir(cppfiledir) then
os.mkdir(cppfiledir)
@@ -586,6 +591,10 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
-- try removing the old object file for forcing to rebuild this source file
os.tryrm(objectfile)
+ -- remove preprocess file
+ local cppfile = _get_cppfile(sourcefile, objectfile)
+ os.tryrm(cppfile)
+
-- use cl/stdout as errors first from vstool.iorunv()
if type(errors) == "table" then
local errs = errors.stdout or ""
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 50c726a56..0a1bc08e8 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -396,6 +396,11 @@ function _has_color_diagnostics(self)
return colors_diagnostics
end
+-- get preprocess file path
+function _get_cppfile(sourcefile, objectfile)
+ return path.join(path.directory(objectfile), "__cpp_" .. path.basename(objectfile) .. path.extension(sourcefile))
+end
+
-- do preprocess
function _preprocess(program, argv, opt)
@@ -486,7 +491,7 @@ function _preprocess(program, argv, opt)
end
-- do preprocess
- local cppfile = path.join(path.directory(objectfile), "__cpp_" .. path.basename(objectfile) .. path.extension(sourcefile))
+ local cppfile = _get_cppfile(sourcefile, objectfile)
local cppfiledir = path.directory(cppfile)
if not os.isdir(cppfiledir) then
os.mkdir(cppfiledir)
@@ -636,6 +641,10 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
-- try removing the old object file for forcing to rebuild this source file
os.tryrm(objectfile)
+ -- remove preprocess file
+ local cppfile = _get_cppfile(sourcefile, objectfile)
+ os.tryrm(cppfile)
+
-- parse and strip errors
local lines = errors and tostring(errors):split('\n', {plain = true}) or {}
if not option.get("verbose") then