summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2022-12-01 12:01:45 +0100
committerArthur LAURENT <[email protected]>2022-12-01 12:01:45 +0100
commit944c55ad89e0ee78d70451097f37ae11651e82b8 (patch)
treee7ccdbc6dd60da8238dbf36f194eddc96d2fd19a
parent97c36a86e182c2fcac292275badf2cd231eb8640 (diff)
update msvc.lua
update msvc.lua update msvc.lua update clang.lua update msvc.lua
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc.lua19
2 files changed, 18 insertions, 3 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index 6e6a7cb89..437582ac2 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -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
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua
index 8138d6af1..6305f7933 100644
--- a/xmake/rules/c++/modules/modules_support/msvc.lua
+++ b/xmake/rules/c++/modules/modules_support/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