summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-01-29 00:46:37 +0800
committerruki <[email protected]>2022-01-29 00:46:37 +0800
commit0b8b054bcd07172fc2b84919d5a4181c8ab80ce6 (patch)
tree8c1c66316a29b6d27e0cb3dee20bb09a986092c4
parent1971c40e500cab7072426f64ac4501ccdd8ce15e (diff)
fix runenvs
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x.lua4
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua37
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua4
3 files changed, 33 insertions, 12 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua
index 4c5fc86f8..421c19b05 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x.lua
@@ -316,9 +316,9 @@ function _make_targetinfo(mode, arch, target, vcxprojdir)
end
for k, v in pairs(addrunenvs) do
if k:upper() == "PATH" then
- runenvs[k] = format("%s;$([System.Environment]::GetEnvironmentVariable('%s'))", _make_dirs(v, vcxprojdir), k)
+ runenvs[k] = _make_dirs(v, vcxprojdir) .. "$([System.Environment]::GetEnvironmentVariable('" .. k .. "'))"
else
- runenvs[k] = format("%s;$([System.Environment]::GetEnvironmentVariable('%s'))", path.joinenv(v), k)
+ runenvs[k] = path.joinenv(v) .. "$([System.Environment]::GetEnvironmentVariable('" .. k .."'))"
end
end
for k, v in pairs(setrunenvs) do
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
index 2cc84ff52..60cfbe05e 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
@@ -252,12 +252,13 @@ function _make_configurations(vcxprojfile, vsinfo, target)
end
vcxprojfile:leave("</PropertyGroup>")
end
-
+
-- make Debugger
for _, targetinfo in ipairs(target.info) do
vcxprojfile:enter("<PropertyGroup Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\" Label=\"Debugger\">", targetinfo.mode, targetinfo.arch)
vcxprojfile:print("<LocalDebuggerWorkingDirectory>%s</LocalDebuggerWorkingDirectory>", _make_dirs(targetinfo.rundir, target.project_dir))
- vcxprojfile:print("<LocalDebuggerEnvironment>%s;$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>", targetinfo.runenvs)
+ -- @note we use writef to avoid escape $() in runenvs, e.g. $([System.Environment]::Get ..)
+ vcxprojfile:writef("<LocalDebuggerEnvironment>%s;%%(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>\n", targetinfo.runenvs)
vcxprojfile:leave("</PropertyGroup>")
end
end
@@ -399,7 +400,7 @@ function _make_source_options(vcxprojfile, flags, condition)
-- make AdditionalOptions
local additional_flags = {}
local excludes = {
- "Od", "Os", "O0", "O1", "O2", "Ot", "Ox", "W0", "W1", "W2", "W3", "W4", "WX", "Wall", "Zi", "ZI", "Z7", "MT", "MTd", "MD", "MDd", "TP",
+ "Od", "Os", "O0", "O1", "O2", "Ot", "Ox", "W0", "W1", "W2", "W3", "W4", "WX", "Wall", "Zi", "ZI", "Z7", "MT", "MTd", "MD", "MDd", "TP",
"Fd", "fp", "I", "D", "Gm-", "Gm", "MP", "external:W0", "external:W1", "external:W2", "external:W3", "external:W4", "external:templates-?", "external:I",
"std:c11", "std:c17", "std:c%+%+11", "std:c%+%+14", "std:c%+%+17", "std:c%+%+20", "std:c%+%+latest", "nologo", "wd(%d+)"
}
@@ -482,7 +483,7 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo)
local flags = {}
local excludes = {
"nologo", "machine:%w+", "pdb:.+%.pdb", "debug"
- }
+ }
local libdirs = {}
local links = {}
for _, flag in ipairs(_make_linkflags(targetinfo, target.project_dir)) do
@@ -709,7 +710,7 @@ end
function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourceinfo)
-- get object file and source kind
- local sourcekind = nil
+ local sourcekind
for _, info in ipairs(sourceinfo) do
sourcekind = info.sourcekind
break
@@ -736,12 +737,22 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
elseif sourcekind == "mrc" then
for _, info in ipairs(sourceinfo) do
local objectfile = path.relative(path.absolute(info.objectfile), target.project_dir)
- vcxprojfile:print("<ResourceOutputFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ResourceOutputFileName>", info.mode, info.arch, objectfile)
+ vcxprojfile:print("<ResourceOutputFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ResourceOutputFileName>",
+ info.mode, info.arch, objectfile)
end
-- for *.c/cpp files
else
+ -- we need use different object directory
+ -- @see https://github.com/xmake-io/xmake/issues/2016
+ --[[
+ for _, info in ipairs(sourceinfo) do
+ local objectfile = path.relative(path.absolute(info.objectfile), target.project_dir)
+ vcxprojfile:print("<ObjectFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ObjectFileName>",
+ info.mode, info.arch, objectfile)
+ end]]
+
-- init items
local items =
{
@@ -827,10 +838,12 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
-- add source file
sourcefile = path.relative(path.absolute(sourcefile), target.project_dir)
for _, info in ipairs(sourceinfo) do
+ print("spec", info)
-- enter it
local nodename = (info.sourcekind == "as" and "CustomBuild" or (info.sourcekind == "mrc" and "ResourceCompile" or "ClCompile"))
- vcxprojfile:enter("<%s Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\" Include=\"%s\">", nodename, info.mode, info.arch, sourcefile)
+ vcxprojfile:enter("<%s Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\" Include=\"%s\">",
+ nodename, info.mode, info.arch, sourcefile)
-- for *.asm files
local objectfile = path.relative(path.absolute(info.objectfile), target.project_dir)
@@ -843,11 +856,19 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
-- for *.rc files
elseif sourcekind == "mrc" then
- vcxprojfile:print("<ResourceOutputFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ResourceOutputFileName>",info.mode,info.arch,objectfile)
+ vcxprojfile:print("<ResourceOutputFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ResourceOutputFileName>",
+ info.mode,info.arch,objectfile)
-- for *.c/cpp files
else
+ -- we need use different object directory
+ -- @see https://github.com/xmake-io/xmake/issues/2016
+ --[[
+ vcxprojfile:print("<ObjectFileName Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</ObjectFileName>",
+ info.mode, info.arch, objectfile)
+ ]]
+
-- disable the precompiled header if sourcekind ~= headerkind
local pcheader = target.pcxxheader or target.pcheader
if pcheader and language.sourcekind_of(sourcefile) ~= (target.pcxxheader and "cxx" or "cc") then
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index 965e55028..e9403cb35 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -190,9 +190,9 @@ function _make_targetinfo(mode, arch, target)
end
for k, v in pairs(addrunenvs) do
if k:upper() == "PATH" then
- runenvs[k] = format("%s;$([System.Environment]::GetEnvironmentVariable('%s'))", _make_dirs(v), k)
+ runenvs[k] = _make_dirs(v) .. "$([System.Environment]::GetEnvironmentVariable('" .. k .. "'))"
else
- runenvs[k] = format("%s;$([System.Environment]::GetEnvironmentVariable('%s'))", path.joinenv(v), k)
+ runenvs[k] = path.joinenv(v) .. "$([System.Environment]::GetEnvironmentVariable('" .. k .."'))"
end
end
for k, v in pairs(setrunenvs) do