Skip to content

Commit

Permalink
update msvc.lua
Browse files Browse the repository at this point in the history
update msvc.lua


update msvc.lua


update clang.lua


update msvc.lua
  • Loading branch information
Arthapz committed Dec 1, 2022
1 parent 97c36a8 commit 944c55a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion xmake/rules/c++/modules/modules_support/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function generate_dependencies(target, sourcebatch, opt)
table.insert(defines, "-D" .. define)
end
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
os.vrunv(compinst:program(), table.join(defines, {"-E", "-x", "c++", file, "-o", ifile}))
os.vrunv(compinst:program(), table.join(defines, {"-E", "-x", "c++", file, "-o", ifile}))
return io.readfile(ifile)
end)
changed = true
Expand Down
19 changes: 17 additions & 2 deletions xmake/rules/c++/modules/modules_support/msvc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function generate_dependencies(target, sourcebatch, opt)
local compinst = target:compiler("cxx")
local toolchain = target:toolchain("msvc")
local vcvars = toolchain:config("vcvars")
local scandependenciesflag = get_scandependenciesflag(target)
local scandependenciesflag = nil -- get_scandependenciesflag(target)
local common_flags = {"-TP", scandependenciesflag}
local cachedir = common.modules_cachedir(target)
local changed = false
Expand All @@ -142,8 +142,13 @@ function generate_dependencies(target, sourcebatch, opt)
os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, flags), {envs = vcvars})
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}), {envs = vcvars})
return io.readfile(ifile)
end)
end
Expand Down Expand Up @@ -699,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 944c55a

Please sign in to comment.