diff options
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 27 |
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 - |
