summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-06-12 05:55:33 +0800
committerGitHub <[email protected]>2022-06-12 05:55:33 +0800
commit5cd6e992b5364bc7581141f195f411c3964f6fe8 (patch)
tree3db9f0011b9b79281a313971b2f7840974e5fd22
parenta987d7613776ab1ba251058c1874dfb5076a29df (diff)
parentbee991075dae779da9c41e0358e6cd2938b9e3eb (diff)
Merge pull request #2449 from xmake-io/cache
improve cl/ccache
m---------core/src/tbox/tbox0
-rw-r--r--xmake/modules/core/tools/cl.lua23
2 files changed, 17 insertions, 6 deletions
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox
-Subproject 0c7f7ae9595a6f7c3defc173f91a8c0a9e1494c
+Subproject 0cdd892038242128bbefa4f00dcb4cc451c751d
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index fdcce6d45..1e7556808 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -467,15 +467,26 @@ function _preprocess(program, argv, opt)
if not os.isdir(cppfiledir) then
os.mkdir(cppfiledir)
end
- table.insert(cppflags, "-P")
if linemarkers == false then
table.insert(cppflags, "-EP")
+ else
+ -- we cannot use `/P`, @see https://github.com/xmake-io/xmake/issues/2445
+ table.insert(cppflags, "-E")
end
- table.insert(cppflags, "-Fi" .. cppfile)
table.insert(cppflags, sourcefile)
return try{ function()
- local outdata, errdata = vstool.iorunv(program, winos.cmdargv(cppflags), opt)
- return {outdata = outdata, errdata = errdata,
+ local outfile = os.tmpfile() .. ".i.out"
+ local errfile = os.tmpfile() .. ".i.err"
+ os.execv(program, winos.cmdargv(cppflags), table.join(opt, {stdout = outfile, stderr = errfile}))
+ local errdata
+ if os.isfile(errfile) then
+ errdata = io.readfile(errfile)
+ end
+ os.cp(outfile, cppfile)
+ os.tryrm(errfile)
+ os.tryrm(outfile)
+ -- includes information will be output to stderr instead of stdout now
+ return {outdata = errdata, errdata = errdata,
sourcefile = sourcefile, objectfile = objectfile, cppfile = cppfile, cppflags = flags,
pdbfile = pdbfile}
end}
@@ -538,10 +549,9 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
-- generate includes file
local compflags = flags
-
if dependinfo then
if _has_source_dependencies(self) then
- depfile = os.tmpfile()
+ depfile = os.tmpfile() .. ".json"
compflags = table.join(flags, "/sourceDependencies", depfile)
else
compflags = table.join(flags, "-showIncludes")
@@ -637,3 +647,4 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
end
end
end
+