Skip to content

Commit

Permalink
revert last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthapz committed Jan 30, 2024
1 parent a2ccc58 commit 8e10652
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
6 changes: 4 additions & 2 deletions xmake/rules/c++/modules/modules_support/clang/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ function _compile(target, flags, cppfile)
if not dryrun then
-- do compile
if msvc then
try{function() return os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()}) end}
local _, err = os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()})
assert(err, err)
else
try{function() return os.iorunv(compinst:program(), flags) end}
local _, err = os.iorunv(compinst:program(), flags)
assert(err, err)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ function generate_dependencies(target, sourcebatch, opt)
local clangscandeps = compiler_support.get_clang_scan_deps(target)
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
local flags = table.join({"--format=p1689", "--",
clang_path, "-x", "c++", runtime_flag, "-c", sourcefile, "-o", target:objectfile(sourcefile)}, compflags or {})
clang_path, "-x", "c++", "-c", sourcefile, "-o", target:objectfile(sourcefile)}, compflags or {})
vprint(table.concat(table.join(clangscandeps, flags), " "))
local outdata = try{function() return os.iorunv(clangscandeps, flags) end}
local outdata, err = os.iorunv(clangscandeps, flags)
assert(err, err)

io.writefile(jsonfile, outdata)
else
Expand All @@ -65,7 +66,8 @@ 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})
try{function() os.iorunv(compinst:program(), flags) end}
local _, err = os.iorunv(compinst:program(), flags)
assert(err, err)
local content = io.readfile(ifile)
os.rm(ifile)
return content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ 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})
try{function() return os.iorunv(path.translate(compinst:program()), flags) end}
local _, err = os.iorunv(path.translate(compinst:program()), flags)
assert(err, err)
os.rm(ifile)
os.rm(dfile)
else
Expand All @@ -59,7 +60,8 @@ function generate_dependencies(target, sourcebatch, opt)
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})
try{function() return os.iorunv(compinst:program(), flags) end}
local _, err = os.iorunv(compinst:program(), flags)
assert(err, err)
local content = io.readfile(ifile)
os.rm(ifile)
return content
Expand Down
3 changes: 2 additions & 1 deletion xmake/rules/c++/modules/modules_support/msvc/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function _compile(target, flags, sourcefile)

if not dryrun then
-- do compile
try{function() return os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()}) end}
local _, err = os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()})
assert(err, err)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ 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)
try{function() return os.iorunv(compinst:program(), winos.cmdargv(compflags), {envs = msvc:runenvs()}) end}
local _, err = os.iorunv(compinst:program(), winos.cmdargv(compflags), {envs = msvc:runenvs()})
assert(err, err)
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"))
try{function() return os.vrunv(compinst:program(), table.join(compflags,
{"/P", "-TP", file, "/Fi" .. ifile}), {envs = msvc:runenvs()}) end}
local _, err = os.iorunv(compinst:program(), table.join(compflags,
{"/P", "-TP", file, "/Fi" .. ifile}), {envs = msvc:runenvs()})
assert(err, err)
local content = io.readfile(ifile)
os.rm(ifile)
return content
Expand Down

0 comments on commit 8e10652

Please sign in to comment.