update msvc.lua
update msvc.lua
update msvc.lua
update clang.lua
update msvc.lua
@@ -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
@@ -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
@@ -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
