Skip to content

Commit

Permalink
update msvc.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthapz committed Nov 30, 2022
1 parent 040172d commit 768bca9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion xmake/rules/c++/modules/modules_support/msvc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@ function generate_dependencies(target, sourcebatch, opt)
else
common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file)
local compinst = target:compiler("cxx")
local defines = {}
for _, define in ipairs(target:get("defines")) do
table.insert(defines, "/D" .. define)
end
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), {"/TP", "/P", file, "/Fi" .. ifile}))
os.vrunv(compinst:program(), table.join(defines, {"/nologo", get_cppversionflag(target), "/P", file, "/Fi" .. ifile}))
return io.readfile(ifile)
end)
end
Expand Down Expand Up @@ -700,3 +704,13 @@ function get_requiresflags(target, requires, opt)
return requireflags
end
end

function get_cppversionflag(target)
local cppversionflag = _g.cppversionflag
if cppversionflag == nil then
local compinst = target:compiler("cxx")
local flags = compinst:compflags({target = target})
cppversionflag = table.find_if(flags, function(v) string.startswith(v, "/std:c++") end) or "/std:c++latest")
end
return cppversionflag or nil
end

0 comments on commit 768bca9

Please sign in to comment.