summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/gcc.lua
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 /xmake/modules/core/tools/gcc.lua
parent9c2b26364c39a5cc933f1d08670fe338c789bdb9 (diff)
improve to remove cppfile
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
-rw-r--r--xmake/modules/core/tools/gcc.lua11
1 files changed, 10 insertions, 1 deletions
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