summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-02 20:21:04 +0800
committerGitHub <[email protected]>2021-12-02 20:21:04 +0800
commitadc1bc698e298e4f4118fdc5da5223fb9ae3f0ba (patch)
tree58039798002fcea79ba65fed2f0ac8ffa26430f5
parent690d8ae73adb4e568d62c3b082f4b2d079a20bb6 (diff)
parent10f997a414f875212d41964fdea503f89a95f87f (diff)
Merge pull request #1878 from SirLynix/patch-7
Add -FC after depends check (fix #1824)
-rw-r--r--xmake/modules/core/tools/cl.lua27
1 files changed, 20 insertions, 7 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index d84f4c7c1..a519d1618 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -34,12 +34,6 @@ function init(self)
-- init cxflags
self:set("cxflags", "-nologo")
- -- we need show full file path to goto error position if xmake is called in vstudio
- -- https://github.com/xmake-io/xmake/issues/1049
- if os.getenv("XMAKE_IN_VSTUDIO") then
- self:add("cxflags", "-FC")
- end
-
-- init flags map
self:set("mapflags",
{
@@ -381,6 +375,15 @@ function _has_source_dependencies(self)
return has_source_dependencies
end
+function _is_in_vstudio()
+ local is_in_vstudio = _g._IS_IN_VSTUDIO
+ if is_in_vstudio == nil then
+ is_in_vstudio = os.getenv("XMAKE_IN_VSTUDIO") or false
+ _g._IS_IN_VSTUDIO = is_in_vstudio
+ end
+ return is_in_vstudio
+end
+
-- make the compile arguments list
function compargv(self, sourcefile, objectfile, flags, opt)
@@ -413,6 +416,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
-- generate includes file
local compflags = flags
+
if dependinfo then
if _has_source_dependencies(self) then
depfile = os.tmpfile()
@@ -422,6 +426,16 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
end
end
+ -- we need show full file path to goto error position if xmake is called in vstudio
+ -- https://github.com/xmake-io/xmake/issues/1049
+ if _is_in_vstudio() then
+ if compflags == flags then
+ compflags = table.join(flags, "-FC")
+ else
+ table.join2(compflags, "-FC")
+ end
+ end
+
-- use vstool to compile and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528
local program, argv = compargv(self, sourcefile, objectfile, compflags, opt)
return vstool.iorunv(program, argv, {envs = self:runenvs()})
@@ -504,4 +518,3 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
end
end
end
-