From f29f664a99086e336b40e02dda29d60a22f300e7 Mon Sep 17 00:00:00 2001 From: Jérôme Leclercq Date: Thu, 2 Dec 2021 11:55:12 +0100 Subject: Add -FC after depends check (fix #1824) --- xmake/modules/core/tools/cl.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index d84f4c7c1..14bc19544 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", { @@ -413,12 +407,19 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) -- generate includes file local compflags = flags + + -- 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 + compflags = table.join(compflags, "-FC") + end + if dependinfo then if _has_source_dependencies(self) then depfile = os.tmpfile() - compflags = table.join(flags, "/sourceDependencies", depfile) + compflags = table.join(compflags, "/sourceDependencies", depfile) else - compflags = table.join(flags, "-showIncludes") + compflags = table.join(compflags, "-showIncludes") end end @@ -504,4 +505,3 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) end end end - -- cgit v1.3.1 From 1772c8d130113aabc407f1824919c79e4a0b8488 Mon Sep 17 00:00:00 2001 From: Jérôme Leclercq Date: Thu, 2 Dec 2021 12:18:43 +0100 Subject: Cache XMAKE_IN_VSTUDIO --- xmake/modules/core/tools/cl.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 14bc19544..ba88a0d03 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -375,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") + _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) @@ -410,7 +419,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) -- 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 + if _is_in_vstudio() then compflags = table.join(compflags, "-FC") end -- cgit v1.3.1 From 5bd0628dace1c00671055e03d26b8de180e223ac Mon Sep 17 00:00:00 2001 From: Jérôme Leclercq Date: Thu, 2 Dec 2021 12:21:16 +0100 Subject: Don't copy table everytime --- xmake/modules/core/tools/cl.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index ba88a0d03..b8beceac1 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -417,18 +417,22 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) -- generate includes file local compflags = flags - -- 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 - compflags = table.join(compflags, "-FC") - end - if dependinfo then if _has_source_dependencies(self) then depfile = os.tmpfile() - compflags = table.join(compflags, "/sourceDependencies", depfile) + compflags = table.join(flags, "/sourceDependencies", depfile) + else + compflags = table.join(flags, "-showIncludes") + 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 - compflags = table.join(compflags, "-showIncludes") + table.join2(compflags, "-FC") end end -- cgit v1.3.1 From 10f997a414f875212d41964fdea503f89a95f87f Mon Sep 17 00:00:00 2001 From: Jérôme Leclercq Date: Thu, 2 Dec 2021 12:30:45 +0100 Subject: Fix _is_in_vstudio caching --- xmake/modules/core/tools/cl.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index b8beceac1..a519d1618 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -378,7 +378,7 @@ 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") + is_in_vstudio = os.getenv("XMAKE_IN_VSTUDIO") or false _g._IS_IN_VSTUDIO = is_in_vstudio end return is_in_vstudio -- cgit v1.3.1