From 0a771e41e5057d2f6dc9dce3cbe2078cbc19aa83 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 08:48:11 +0800 Subject: add path.splitenv --- xmake/core/base/os.lua | 35 ++++++++++++++++++++++++-------- xmake/core/base/path.lua | 27 ++++++++++++++++++++++++ xmake/core/tool/builder.lua | 4 ++-- xmake/modules/package/tools/autoconf.lua | 4 ++-- xmake/modules/package/tools/cmake.lua | 6 +++--- xmake/modules/package/tools/make.lua | 4 ++-- xmake/modules/package/tools/meson.lua | 4 ++-- 7 files changed, 65 insertions(+), 19 deletions(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index ee5979b2e..fe88c65bb 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -943,34 +943,53 @@ function os.getenvs() return envs end --- set values to environment variable +-- set values to environment variable function os.setenv(name, ...) - return os._setenv(name, table.concat({...}, path.envsep())) + local values = {...} + if #values <= 1 then + -- keep compatible with original implementation + os._setenv(name, values[1] or "") + else + os._setenv(path.joinenv(values)) + end end --- add values to environment variable +-- add values to environment variable function os.addenv(name, ...) - local sep = path.envsep() local values = {...} if #values > 0 then - return os._setenv(name, table.concat(values, sep) .. sep .. (os.getenv(name) or "")) + local oldenv = os.getenv(name) + local appendenv = path.joinenv(values) + if oldenv == "" or oldenv == nil then + return os._setenv(name, appendenv) + else + return os._setenv(name, appendenv .. path.envsep() .. oldenv) + end else return true end end --- set values to environment variable with the given seperator +-- set values to environment variable with the given seperator function os.setenvp(name, values, sep) sep = sep or path.envsep() return os._setenv(name, table.concat(table.wrap(values), sep)) end --- add values to environment variable with the given seperator +-- add values to environment variable with the given seperator function os.addenvp(name, values, sep) sep = sep or path.envsep() values = table.wrap(values) if #values > 0 then - return os._setenv(name, table.concat(values, sep) .. sep .. (os.getenv(name) or "")) + local oldenv = os.getenv(name) + local appendenv = table.concat(values, sep) + local newenv + if oldenv == "" or oldenv == nil then + newenv = appendenv + else + newenv = appendenv .. sep .. oldenv + end + return os._setenv(name, newenv) else return true end diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua index c1222ffc6..d15c42fc4 100644 --- a/xmake/core/base/path.lua +++ b/xmake/core/base/path.lua @@ -158,6 +158,33 @@ function path.splitenv(env_path) return result end +-- concat environment variable with `path.envsep()`, +-- also handles more speical cases such as posix flags and windows quoted pathes +function path.joinenv(env_table) + + -- check + env_table = env_table or {} + + local envsep = path.envsep() + + if xmake._HOST == "windows" then + local tab = {} + for _, v in ipairs(env_table) do + if v ~= "" then + if v:find(envsep, 1, true) then + v = '"' .. v .. '"' + end + table.insert(tab, v) + end + end + return table.concat(tab, envsep) + else + return table.concat(env_table, envsep) + end + + return result +end + -- the last character is the path seperator? function path.islastsep(p) diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index 472d5be76..51e284ad5 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -380,8 +380,8 @@ function builder:_add_flags_from_language(flags, target, getters) { config = function (name) local values = config.get(name) - if values and name:endswith("dirs") then - values = values:split(path.envsep(), {plain = true}) + if values and name:endswith("dirs") then + values = path.splitenv(values) end return values end diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index 7705c3bca..349b2c5b5 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -106,8 +106,8 @@ function buildenvs(package) table.insert(ACLOCAL_PATH, aclocal) end end - envs.ACLOCAL_PATH = table.concat(ACLOCAL_PATH, path.envsep()) - envs.PKG_CONFIG_PATH = table.concat(PKG_CONFIG_PATH, path.envsep()) + envs.ACLOCAL_PATH = path.joinenv(ACLOCAL_PATH) + envs.PKG_CONFIG_PATH = path.joinenv(PKG_CONFIG_PATH) return envs end diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 7c21947d1..75b38eaf1 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -71,9 +71,9 @@ function buildenvs(package) table.join2(CMAKE_PREFIX_PATH, dep:installdir()) end end - envs.CMAKE_LIBRARY_PATH = table.concat(CMAKE_LIBRARY_PATH, path.envsep()) - envs.CMAKE_INCLUDE_PATH = table.concat(CMAKE_INCLUDE_PATH, path.envsep()) - envs.CMAKE_PREFIX_PATH = table.concat(CMAKE_PREFIX_PATH, path.envsep()) + envs.CMAKE_LIBRARY_PATH = path.joinenv(CMAKE_LIBRARY_PATH) + envs.CMAKE_INCLUDE_PATH = path.joinenv(CMAKE_INCLUDE_PATH) + envs.CMAKE_PREFIX_PATH = path.joinenv(CMAKE_PREFIX_PATH) return envs end diff --git a/xmake/modules/package/tools/make.lua b/xmake/modules/package/tools/make.lua index 13e72b310..4a7850185 100644 --- a/xmake/modules/package/tools/make.lua +++ b/xmake/modules/package/tools/make.lua @@ -59,8 +59,8 @@ function buildenvs(package) table.insert(ACLOCAL_PATH, aclocal) end end - envs.ACLOCAL_PATH = table.concat(ACLOCAL_PATH, path.envsep()) - envs.PKG_CONFIG_PATH = table.concat(PKG_CONFIG_PATH, path.envsep()) + envs.ACLOCAL_PATH = path.joinenv(ACLOCAL_PATH) + envs.PKG_CONFIG_PATH = path.joinenv(PKG_CONFIG_PATH) return envs end diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index f977475ab..e5b25c450 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -78,8 +78,8 @@ function buildenvs(package) table.insert(ACLOCAL_PATH, aclocal) end end - envs.ACLOCAL_PATH = table.concat(ACLOCAL_PATH, path.envsep()) - envs.PKG_CONFIG_PATH = table.concat(PKG_CONFIG_PATH, path.envsep()) + envs.ACLOCAL_PATH = path.joinenv(ACLOCAL_PATH) + envs.PKG_CONFIG_PATH = path.joinenv(PKG_CONFIG_PATH) return envs end -- cgit v1.3.1 From 948e157842d7498486067c05708cf5cfd9a0b509 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 08:48:41 +0800 Subject: add compile selected files --- xmake/plugins/project/vsxmake/getinfo.lua | 6 +- xmake/plugins/project/vsxmake/render.lua | 6 +- xmake/plugins/project/vsxmake/vsproj/Xmake.props | 276 ++++++++--------- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 329 +++++++++++---------- .../vsxmake/vsproj/templates/#target#.vcxproj.user | 12 +- .../vsxmake/vsproj/templates/Xmake.Custom.props | 75 +++-- .../vsxmake/vsproj/templates/Xmake.Custom.targets | 44 +-- .../vcxproj.filters/#target#.vcxproj.filters | 62 ++-- .../vsproj/templates/vcxproj.filters/File.c(filec) | 6 +- .../templates/vcxproj.filters/File.cu(filecu) | 6 +- .../templates/vcxproj.filters/File.cxx(filecxx) | 6 +- .../templates/vcxproj.filters/File.obj(fileobj) | 6 +- .../templates/vcxproj.filters/File.rc(filerc) | 6 +- .../vsproj/templates/vcxproj.filters/Filter(dir) | 6 +- .../vsproj/templates/vcxproj.filters/Include(inc) | 6 +- .../vsproj/templates/vcxproj/#target#.vcxproj | 80 ++--- .../vsxmake/vsproj/templates/vcxproj/File.c(filec) | 6 +- .../vsproj/templates/vcxproj/File.cu(filecu) | 2 +- .../vsproj/templates/vcxproj/File.cxx(filecxx) | 6 +- .../vsproj/templates/vcxproj/File.obj(fileobj) | 2 +- .../vsproj/templates/vcxproj/File.rc(filerc) | 2 +- .../vsxmake/vsproj/templates/vcxproj/Include(inc) | 2 +- .../vcxproj/ProjectConfiguration(mode,arch) | 8 +- .../vsproj/templates/vcxproj/ProjectRef(dep) | 6 +- .../templates/vcxproj/XmakeConfig(mode,arch) | 26 +- .../vsproj/templates/vcxproj/XmakePath(mode,arch) | 18 +- xmake/plugins/project/vsxmake/vsxmake.lua | 31 +- 27 files changed, 556 insertions(+), 485 deletions(-) diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 4567adb1e..cbb1c7a54 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -53,7 +53,7 @@ function _make_dirs(dir) r[k] = _make_dirs(v) end r = table.unique(r) - return table.concat(r, path.envsep()) + return path.joinenv(r) end function _get_values(target, name) @@ -103,7 +103,7 @@ function _make_targetinfo(mode, arch, target) for _, d in ipairs(v) do table.insert(defs, vformat(d)) end - table.insert(runenvs, format("%s=%s", k, table.concat(defs, path.envsep()))) + table.insert(runenvs, format("%s=%s", k, path.joinenv(defs))) end targetinfo.runenvs = table.concat(runenvs, "\n") @@ -266,7 +266,7 @@ function main(outputdir, vsinfo) local dir = path.directory(f) target._sub2[f] = { - path = path.join("$(XmakeProjectDir)", f), + path = f, dir = dir } while dir ~= "." do diff --git a/xmake/plugins/project/vsxmake/render.lua b/xmake/plugins/project/vsxmake/render.lua index c672b30cd..99f635d04 100644 --- a/xmake/plugins/project/vsxmake/render.lua +++ b/xmake/plugins/project/vsxmake/render.lua @@ -37,14 +37,14 @@ function _expand(params) for _, v in ipairs(params) do if type(v) == "string" then for i, p in ipairs(r) do - r[i] = p .. ";" .. v + r[i] = p .. "\0" .. v end else local newr = {} for _, c in ipairs(v) do local rcopy = {} for i, p in ipairs(r) do - rcopy[i] = p .. ";" .. c + rcopy[i] = p .. "\0" .. c end newr= table.join(newr, rcopy) end @@ -52,7 +52,7 @@ function _expand(params) end end for i, p in ipairs(r) do - r[i] = p:split(";") + r[i] = p:split("\0") end return r end diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index 20432fec3..1814bc6b9 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -1,141 +1,141 @@ - - - $(Configuration) - release - - x86 - $(Platform) - x86 - - - - - - - - - - $(XmakeTarget) - $(TargetName) - $(MSBuildProjectName) - - binary - windows - - - - $(XmakeProjectDir)\build - $(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode) - $(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode) - - $(XMAKE_CONFIGDIR) - $(XmakeProjectDir)\.xmake - - $(XmakeTargetDir) - - - - - $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeProjectDir)')) - $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeScriptDir)')) - $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeBuilDir)')) - $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeTargetDir)')) - $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigDir)')) - $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigFileDir)')) - $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeRunDir)')) - - - $([System.IO.Path]::GetFullPath('$(XmakeProgramDir)/')) - $([System.IO.Path]::GetFullPath('$(XmakeProjectDir)/')) - $([System.IO.Path]::GetFullPath('$(XmakeScriptDir)/')) - $([System.IO.Path]::GetFullPath('$(XmakeBuilDir)/')) - $([System.IO.Path]::GetFullPath('$(XmakeTargetDir)/')) - $([System.IO.Path]::GetFullPath('$(XmakeConfigDir)/')) - $([System.IO.Path]::GetFullPath('$(XmakeConfigFileDir)/')) - $([System.IO.Path]::GetFullPath('$(XmakeRunDir)/')) - - - - true - false - false - - - - 10.0.10240.0 - 10.0.14393.0 - 10.0.17763.0 - 10.0 - - - v100 - v110 - v120 - v140 - v141 - v142 - - - - $(XmakeMfcKind) - Unicode - MultiByte - - - - - - - Application - - - - - DynamicLibrary - - - - - StaticLibrary - - - - - - - %(PreprocessorDefinitions);$(XmakeDefines) - stdcpp17 - stdcpp14 - stdcpp11 - - - - - - - - - - - - - - - $(XmakeBasename) - $([System.IO.Path]::GetFileNameWithoutExtension('$(XmakeFilename)')) - $([System.IO.Path]::GetExtension('$(XmakeFilename)')) - - - - $(XmakeIncludeDir);$(IncludePath) - $(XmakeLinkDir);$(LibraryPath) - $(XmakeTargetDir) - $(XmakeBuilDir).vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\ - + + + $(Configuration) + release + + x86 + $(Platform) + x86 + + + + + + + + + + $(XmakeTarget) + $(TargetName) + $(MSBuildProjectName) + + binary + windows + + + + $(XmakeProjectDir)\build + $(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode) + $(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode) + + $(XMAKE_CONFIGDIR) + $(XmakeProjectDir)\.xmake + + $(XmakeTargetDir) + + + + + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeProjectDir)')) + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeScriptDir)')) + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeBuilDir)')) + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeTargetDir)')) + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigDir)')) + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigFileDir)')) + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeRunDir)')) + + + $([System.IO.Path]::GetFullPath('$(XmakeProgramDir)/')) + $([System.IO.Path]::GetFullPath('$(XmakeProjectDir)/')) + $([System.IO.Path]::GetFullPath('$(XmakeScriptDir)/')) + $([System.IO.Path]::GetFullPath('$(XmakeBuilDir)/')) + $([System.IO.Path]::GetFullPath('$(XmakeTargetDir)/')) + $([System.IO.Path]::GetFullPath('$(XmakeConfigDir)/')) + $([System.IO.Path]::GetFullPath('$(XmakeConfigFileDir)/')) + $([System.IO.Path]::GetFullPath('$(XmakeRunDir)/')) + + + + true + false + false + + + + 10.0.10240.0 + 10.0.14393.0 + 10.0.17763.0 + 10.0 + + + v100 + v110 + v120 + v140 + v141 + v142 + + + + $(XmakeMfcKind) + Unicode + MultiByte + + + + + + + Application + + + + + DynamicLibrary + + + + + StaticLibrary + + + + + + + %(PreprocessorDefinitions);$(XmakeDefines) + stdcpp17 + stdcpp14 + stdcpp11 + + + + + + + + + + + + + + + $(XmakeBasename) + $([System.IO.Path]::GetFileNameWithoutExtension('$(XmakeFilename)')) + $([System.IO.Path]::GetExtension('$(XmakeFilename)')) + + + + $(XmakeIncludeDir);$(IncludePath) + $(XmakeLinkDir);$(LibraryPath) + $(XmakeTargetDir) + $(XmakeBuilDir).vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\ + diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 05102ab40..940490271 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -1,169 +1,194 @@ - - - - + + + + - - <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' != ''">-F "$(XmakeProjectFile)" - <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' == ''">-P . - - <_XmakeCommonFlags>$(XmakeCommonFlags.Trim()) - <_XmakeCommonFlags Condition="$(XmakeVerbose)">$(_XmakeCommonFlags) -v - <_XmakeCommonFlags Condition="$(XmakeDiagnosis)">$(_XmakeCommonFlags) -D - <_XmakeCommonFlags>$(_XmakeCommonFlags) $(_XmakeProjectFlag) + + <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' != ''">-F "$(XmakeProjectFile)" + <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' == ''">-P . + + <_XmakeCommonFlags>$(XmakeCommonFlags.Trim()) + <_XmakeCommonFlags Condition="$(XmakeVerbose)">-v $(_XmakeCommonFlags) + <_XmakeCommonFlags Condition="$(XmakeDiagnosis)">-D $(_XmakeCommonFlags) + <_XmakeCommonFlags>$(XmakeCommonFlags.Trim()) + <_XmakeCommonFlags>$(_XmakeCommonFlags) $(_XmakeProjectFlag) - <_XmakeBuilDir>$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)').TrimEnd('/\'.ToCharArray())) + <_XmakeBuilDir>$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)').TrimEnd('/\'.ToCharArray())) - <_XmakeConfigFlags>$(XmakeConfigFlags.Trim()) - <_XmakeConfigFlags>-p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$(_XmakeBuilDir)" $(_XmakeConfigFlags) + <_XmakeConfigFlags>$(XmakeConfigFlags.Trim()) + <_XmakeConfigFlags>-p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$(_XmakeBuilDir)" $(_XmakeConfigFlags) - <_XmakeBuildFlags>$(XmakeBuildFlags.Trim()) - <_XmakeBuildFlags Condition="$(XmakeWarning)">$(_XmakeBuildFlags) -w - - <_XmakeCleanFlags>$(XmakeCleanFlags.Trim()) + <_XmakeBuildFlags>$(XmakeBuildFlags.Trim()) + <_XmakeBuildFlags Condition="$(XmakeWarning)">-w $(_XmakeBuildFlags) + + <_XmakeCleanFlags>$(XmakeCleanFlags.Trim()) - <_XmakeBuildFlags>$(_XmakeBuildFlags.Trim()) - <_XmakeCleanFlags>$(_XmakeCleanFlags.Trim()) - <_XmakeConfigFlags>$(_XmakeConfigFlags.Trim()) - <_XmakeCommonFlags>$(_XmakeCommonFlags.Trim()) + <_XmakeBuildFlags>$(_XmakeBuildFlags.Trim()) + <_XmakeCleanFlags>$(_XmakeCleanFlags.Trim()) + <_XmakeConfigFlags>$(_XmakeConfigFlags.Trim()) + <_XmakeCommonFlags>$(_XmakeCommonFlags.Trim()) - <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))" - <_XmakeEnv> - pushd "$(XmakeProjectDir)" - set XMAKE_CONFIGDIR=$(XmakeConfigDir) - set XMAKE_PROGRAM_DIR=$(XmakeProgramDir) - - + <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))" + <_XmakeEnv> + pushd "$(XmakeProjectDir)" + set XMAKE_CONFIGDIR=$(XmakeConfigDir) + set XMAKE_PROGRAM_DIR=$(XmakeProgramDir) + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @(File) + --files="$(FileList)" + + + + + + + + - - + - + Xmake Props: + XmakeTarget: $(XmakeTarget) + 'XmakePlat|Mode|Arch': '$(XmakePlat)|$(XmakeMode)|$(XmakeArch)' + XmakeBasename: $(XmakeBasename) + XmakeFilename: $(XmakeFilename) + XmakeKind: $(XmakeKind) + XmakeCudaVersion: $(XmakeCudaVersion) + XmakeMfcKind: $(XmakeMfcKind) + XmakeDefines: $(XmakeDefines) + XmakeLanguages: $(XmakeLanguages) + Xmake Path: + XmakeProgramDir: $(XmakeProgramDir) + XmakeProjectDir: $(XmakeProjectDir) + XmakeScriptDir: $(XmakeScriptDir) + XmakeBuilDir: $(XmakeBuilDir) + XmakeConfigDir: $(XmakeConfigDir) + XmakeConfigFileDir: $(XmakeConfigFileDir) + XmakeIncludeDir: $(XmakeIncludeDir) + XmakeLinkDir: $(XmakeLinkDir) + Xmake Flags: + XmakeWarning: $(XmakeWarning) + XmakeVerbose: $(XmakeVerbose) + XmakeDiagnosis: $(XmakeDiagnosis) + XmakeCommonFlags: $(XmakeCommonFlags) + XmakeConfigFlags: $(XmakeConfigFlags) + XmakeBuildFlags: $(XmakeBuildFlags) + XmakeCleanFlags: $(XmakeCleanFlags) + Xmake Internal: + _XmakeCommonFlags: $(_XmakeCommonFlags) + _XmakeConfigFlags: $(_XmakeConfigFlags) + _XmakeBuildFlags: $(_XmakeBuildFlags) + _XmakeCleanFlags: $(_XmakeCleanFlags) + _XmakeExecutable: $(_XmakeExecutable) + _XmakeEnv: $(_XmakeEnv) + Vs Props: + 'Configuration|Platform': '$(Configuration)|$(Platform)' + VisualStudioVersion: $(VisualStudioVersion) + MSBuildProjectDirectory: $(MSBuildProjectDirectory) + MSBuildProjectName: $(MSBuildProjectName) + OutDir: $(OutDir) + IntDir: $(IntDir) + TargetName: $(TargetName) + TargetExt: $(TargetExt) + PlatformToolset: $(PlatformToolset) + CharacterSet: $(CharacterSet) + UseOfMfc: $(UseOfMfc) + WindowsTargetPlatformVersion: $(WindowsTargetPlatformVersion) + PreprocessorDefinitions: %(ClCompile.PreprocessorDefinitions) + LanguageStandard: %(ClCompile.LanguageStandard) + SelectedFiles: $(SelectedFiles) + " Importance="High" /> + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user b/xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user index 399b00e30..a994443e1 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user +++ b/xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user @@ -1,10 +1,10 @@  - - - $(XmakeRunDir) - $(XmakeRunEnvs) + + + $(XmakeRunDir) + $(XmakeRunEnvs) $(LocalDebuggerEnvironment) - true - + true + \ No newline at end of file diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.props b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.props index 6f47fe7a0..55f596456 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.props +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.props @@ -1,35 +1,50 @@ - - - - - - - + + + + + + - - - + + - For -w, -v and -D, use , and is more convenient. - --> - true - false - false - $(XmakeCleanflags) - $(XmakeBuildFlags) - $(XmakeConfigFlags) - $(XmakeCommonFlags) - + + + + + + + + + + + + + + + + $(XmakeCleanflags) + + + $(XmakeBuildFlags) + + + $(XmakeConfigFlags) + + + $(XmakeCommonFlags) + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.targets b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.targets index c63cbed32..8a5153db8 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.targets +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.targets @@ -1,27 +1,29 @@ - - + + - - + + You can also define your own targets and call them like: + + + + + To find task that you can used in custom targets, + see: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-task-reference + --> - - - - - - + + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters index c79ec740a..a4c6cf5c1 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters @@ -2,45 +2,45 @@ - - - {CC7C6180-942D-056E-3227-E6A2B3FB19CD} - + + + {CC7C6180-942D-056E-3227-E6A2B3FB19CD} + #Import(Filter)# - - - - Properties - - - Properties - - - Properties - - - + + + + Properties + + + Properties + + + Properties + + + #Import(Include)# - - + + #Import(File.c)# - - + + #Import(File.cxx)# - - + + #Import(File.cu)# - - + + #Import(File.obj)# - - + + #Import(File.rc)# - + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.c(filec) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.c(filec) index d33f87944..020488ce4 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.c(filec) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.c(filec) @@ -1,3 +1,3 @@ - - #dir# - + + #dir# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cu(filecu) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cu(filecu) index 643bb220f..520e88430 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cu(filecu) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cu(filecu) @@ -1,3 +1,3 @@ - - #dir# - + + #dir# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cxx(filecxx) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cxx(filecxx) index d33f87944..020488ce4 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cxx(filecxx) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cxx(filecxx) @@ -1,3 +1,3 @@ - - #dir# - + + #dir# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.obj(fileobj) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.obj(fileobj) index adacd3b67..5ee8281b7 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.obj(fileobj) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.obj(fileobj) @@ -1,3 +1,3 @@ - - #dir# - + + #dir# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.rc(filerc) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.rc(filerc) index a46047781..c1118ab55 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.rc(filerc) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.rc(filerc) @@ -1,3 +1,3 @@ - - #dir# - + + #dir# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Filter(dir) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Filter(dir) index 6f97fa98d..763e5e83c 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Filter(dir) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Filter(dir) @@ -1,3 +1,3 @@ - - {#dir_id#} - + + {#dir_id#} + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) index 17344346b..3a21dc7bf 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) @@ -1,3 +1,3 @@ - - #dir# - + + #dir# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj index d0e4e94d7..164140542 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj @@ -2,58 +2,58 @@ - + #Import(ProjectConfiguration)# - - - {#target_id#} - $(XMAKE_PROGRAM_DIR) - #programdir# - release - Win32 - #scriptdir# - #projectdir# - #projectfile# - #target# - + + + {#target_id#} + $(XMAKE_PROGRAM_DIR) + #programdir# + release + Win32 + #scriptdir# + #projectdir# + #projectfile# + #target# + #Import(XmakeConfig)# #Import(XmakePath)# - - - - - - - + + + + + + + #Import(Include)# - - + + #Import(File.c)# - - + + #Import(File.cxx)# - - + + #Import(File.cu)# - - + + #Import(File.obj)# - - + + #Import(File.rc)# - - - + --> + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.c(filec) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.c(filec) index 36e16832a..68c1a7d5b 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.c(filec) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.c(filec) @@ -1,3 +1,3 @@ - - CompileAsC - + + CompileAsC + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cu(filecu) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cu(filecu) index 7b3f0a6fe..1d1d98f7d 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cu(filecu) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cu(filecu) @@ -1 +1 @@ - + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cxx(filecxx) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cxx(filecxx) index 076adfd5a..a8534b74b 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cxx(filecxx) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cxx(filecxx) @@ -1,3 +1,3 @@ - - CompileAsCpp - + + CompileAsCpp + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.obj(fileobj) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.obj(fileobj) index 1e7cd6f45..5c858884d 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.obj(fileobj) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.obj(fileobj) @@ -1 +1 @@ - + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.rc(filerc) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.rc(filerc) index 25d1c58ab..e15b89bbe 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.rc(filerc) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.rc(filerc) @@ -1 +1 @@ - + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) index 0178e0f9a..dfd5df637 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) @@ -1 +1 @@ - + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectConfiguration(mode,arch) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectConfiguration(mode,arch) index f2169767f..f2d2eac47 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectConfiguration(mode,arch) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectConfiguration(mode,arch) @@ -1,4 +1,4 @@ - - #mode# - #vsarch# - + + #mode# + #vsarch# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) index 7804e4cba..33434eca3 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) @@ -1,3 +1,3 @@ - - {#target_id#} - + + {#target_id#} + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) index da73700f4..341c807f9 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) @@ -1,13 +1,13 @@ - - #basename# - #filename# - #mode# - #plat# - #arch# - #kind# - #defines# - #languages# - #cudaver# - #mfckind# - #runenvs# - + + #basename# + #filename# + #mode# + #plat# + #arch# + #kind# + #defines# + #languages# + #cudaver# + #mfckind# + #runenvs# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch) index 2c8adc429..42644b1f5 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch) @@ -1,9 +1,9 @@ - - #buildir# - #configdir# - #configfiledir# - #targetdir# - #includedirs# - #linkdirs# - #rundir# - + + #buildir# + #configdir# + #configfiledir# + #targetdir# + #includedirs# + #linkdirs# + #rundir# + diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index cf91eb40e..348138ed7 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -45,6 +45,35 @@ function _filter_files(files, exts) return f end +-- escape special chars in msbuild file +function _escape(str) + if not str then + return nil + end + + local map = + { ["%"] = "%25" -- Referencing metadata + ,["$"] = "%24" -- Referencing properties + ,["@"] = "%40" -- Referencing item lists + ,["'"] = "%27" -- Conditions and other expressions + ,[";"] = "%3B" -- List separator + ,["?"] = "%3F" -- Wildcard character for file names in Include and Exclude attributes + ,["*"] = "%2A" -- Wildcard character for use in file names in Include and Exclude attributes + } + + local has_prefix = false + if str:startswith("$(XmakeProjectDir)") then + has_prefix = true + str = str:sub(#("$(XmakeProjectDir)") + 1) + end + + str = (string.gsub(str, "[%%%$@'\";%?%*]", function (c) return assert(map[c]) end)) + if has_prefix then + str = "$(XmakeProjectDir)" .. str + end + return str +end + function _buildparams(info, target, default) local function getprop(match, opt) @@ -62,7 +91,7 @@ function _buildparams(info, target, default) r = i[match] or r end - return r or default + return _escape(r) or default end local function listconfig(args) -- cgit v1.3.1 From d9560889580bfe3c58f2f3f09b2f52ed3a03a36f Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 08:56:26 +0800 Subject: fix code style --- xmake/core/base/os.lua | 58 ++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index fe88c65bb..6be21560c 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -11,7 +11,7 @@ -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. --- +-- -- Copyright (C) 2015 - 2019, TBOOX Open Source Group. -- -- @author ruki @@ -39,15 +39,15 @@ os._setenv = os._setenv or os.setenv os._getenvs = os._getenvs or os.getenvs os._readlink = os._readlink or os.readlink --- copy single file or directory +-- copy single file or directory function os._cp(src, dst) - + -- check assert(src and dst) -- is file? if os.isfile(src) then - + -- the destination is directory? append the filename if os.isdir(dst) or path.islastsep(dst) then dst = path.join(dst, path.filename(src)) @@ -59,7 +59,7 @@ function os._cp(src, dst) end -- is directory? elseif os.isdir(src) then - + -- the destination directory exists? append the filename if os.isdir(dst) or path.islastsep(dst) then dst = path.join(dst, path.filename(path.translate(src))) @@ -74,20 +74,20 @@ function os._cp(src, dst) else return false, string.format("cannot copy file %s, error: not found this file", src) end - + -- ok return true end -- move single file or directory function os._mv(src, dst) - + -- check assert(src and dst) -- exists file or directory? if os.exists(src) then - + -- the destination directory exists? append the filename if os.isdir(dst) or path.islastsep(dst) then dst = path.join(dst, path.filename(path.translate(src))) @@ -101,14 +101,14 @@ function os._mv(src, dst) else return false, string.format("cannot move %s to %s, not found this file %s", src, dst, os.strerror()) end - + -- ok return true end --- remove single file or directory +-- remove single file or directory function os._rm(filedir) - + -- check assert(filedir) @@ -136,7 +136,7 @@ function os.argw(argv) -- match all arguments local results = {} for _, arg in ipairs(table.wrap(argv)) do - + -- exists wildcards? if arg:find("([%+%-%^%$%*%[%]%%])") then local pathes = os.match(arg, 'a') @@ -185,7 +185,7 @@ end -- match files or directories -- --- @param pattern the search pattern +-- @param pattern the search pattern -- uses "*" to match any part of a file or directory name, -- uses "**" to recurse into subdirectories. -- @@ -198,7 +198,7 @@ end -- @code -- local dirs, count = os.match("./src/*", true) -- local files, count = os.match("./src/**.c") --- local file = os.match("./src/test.c", 'f', function (filepath, isdir) +-- local file = os.match("./src/test.c", 'f', function (filepath, isdir) -- return true -- continue it -- return false -- break it -- end) @@ -235,7 +235,7 @@ function os.match(pattern, mode, callback) assert(mode, "invalid match mode: %s", mode) elseif mode then mode = 1 - else + else mode = 0 end @@ -314,7 +314,7 @@ end -- copy files or directories function os.cp(...) - + -- check arguments local args = {...} if #args < 2 then @@ -341,7 +341,7 @@ end -- move files or directories function os.mv(...) - + -- check arguments local args = {...} if #args < 2 then @@ -368,7 +368,7 @@ end -- remove files or directories function os.rm(...) - + -- check arguments local args = {...} if #args < 1 then @@ -433,14 +433,14 @@ function os.cd(dir) else return nil, string.format("cannot change directory %s, not found this directory %s", dir, os.strerror()) end - + -- ok return oldir end -- create directories function os.mkdir(...) - + -- check arguments local args = {...} if #args < 1 then @@ -460,7 +460,7 @@ end -- remove directories function os.rmdir(...) - + -- check arguments local args = {...} if #args < 1 then @@ -564,7 +564,7 @@ function os.runv(program, argv, opt) return true end --- execute command +-- execute command function os.exec(cmd, outfile, errfile) -- parse arguments @@ -581,8 +581,8 @@ end -- -- @param program "clang", "xcrun -sdk macosx clang", "~/dir/test\ xxx/clang" -- filename "clang", "xcrun"", "~/dir/test\ xxx/clang" --- @param argv the arguments --- @param opt the options, .e.g {wildcards = false, stdout = outfile, stderr = errfile, +-- @param argv the arguments +-- @param opt the options, .e.g {wildcards = false, stdout = outfile, stderr = errfile, -- envs = {PATH = "xxx;xx", CFLAGS = "xx"}} -- function os.execv(program, argv, opt) @@ -631,7 +631,7 @@ function os.execv(program, argv, opt) -- wait process local waitok = -1 - local status = -1 + local status = -1 if coroutine.running() then -- save the current directory @@ -688,7 +688,7 @@ function os.iorunv(program, argv, opt) local errfile = os.tmpfile() -- run command - local ok = os.execv(program, argv, table.join(opt, {stdout = outfile, stderr = errfile})) + local ok = os.execv(program, argv, table.join(opt, {stdout = outfile, stderr = errfile})) -- get output and error data local outdata = io.readfile(outfile) @@ -983,13 +983,11 @@ function os.addenvp(name, values, sep) if #values > 0 then local oldenv = os.getenv(name) local appendenv = table.concat(values, sep) - local newenv if oldenv == "" or oldenv == nil then - newenv = appendenv + return os._setenv(name, appendenv) else - newenv = appendenv .. sep .. oldenv + return os._setenv(name, appendenv .. sep .. oldenv) end - return os._setenv(name, newenv) else return true end -- cgit v1.3.1 From c435e94919e7ee83b0a1ae4aeb589362422343bd Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 13:11:53 +0800 Subject: fix lines --- xmake/core/sandbox/modules/io.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xmake/core/sandbox/modules/io.lua b/xmake/core/sandbox/modules/io.lua index 69cd22b76..49cb1b509 100644 --- a/xmake/core/sandbox/modules/io.lua +++ b/xmake/core/sandbox/modules/io.lua @@ -53,6 +53,8 @@ if sandbox_io_file.__index ~= sandbox_io_file then end end end + -- file:lines does not use its second return value for error + sandbox_io_file.lines = io.file.lines end -- get file size -- cgit v1.3.1 From 9b8aef08039cbd82503d62f13e13096e166104e4 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 14:43:54 +0800 Subject: chang sperator for array --- xmake/plugins/project/vstudio/impl/vs201x.lua | 4 ++-- xmake/plugins/project/vsxmake/getinfo.lua | 4 ++-- xmake/plugins/project/xmake.lua | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index d414a69a3..3ea83fac2 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -165,7 +165,7 @@ function _make_vsinfo_modes() local vsinfo_modes = {} local modes = option.get("modes") if modes then - for _, mode in ipairs(modes:split(',')) do + for _, mode in ipairs(path.splitenv(modes)) do table.insert(vsinfo_modes, mode:trim()) end else @@ -181,7 +181,7 @@ function _make_vsinfo_archs() local vsinfo_archs = {} local archs = option.get("archs") if archs then - for _, arch in ipairs(archs:split(',')) do + for _, arch in ipairs(path.splitenv(archs)) do table.insert(vsinfo_archs, arch:trim()) end else diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index cbb1c7a54..97e1e4961 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -129,7 +129,7 @@ function _make_vsinfo_modes() local vsinfo_modes = {} local modes = option.get("modes") if modes then - for _, mode in ipairs(modes:split(',')) do + for _, mode in ipairs(path.splitenv(modes)) do table.insert(vsinfo_modes, mode:trim()) end else @@ -145,7 +145,7 @@ function _make_vsinfo_archs() local vsinfo_archs = {} local archs = option.get("archs") if archs then - for _, arch in ipairs(archs:split(',')) do + for _, arch in ipairs(path.splitenv(archs)) do table.insert(vsinfo_archs, arch:trim()) end else diff --git a/xmake/plugins/project/xmake.lua b/xmake/plugins/project/xmake.lua index 023d3d87d..88d8a1ced 100644 --- a/xmake/plugins/project/xmake.lua +++ b/xmake/plugins/project/xmake.lua @@ -47,12 +47,10 @@ task("project") , " - vsxmake2010 ~ vsmake2019" } , {'m', "modes", "kv", nil, "Set the project modes." , " .e.g " - , " - xmake project -k makefile" - , " - xmake project -k compile_commands" - , " - xmake project -k vs2015 -m \"release,debug\"" } - , {'a', "archs", "kv", nil, "Set the project archs." + , " - xmake project -k vs2015 -m \"release" .. path.envsep() .. "debug\"" } + , {'a', "archs", "kv", nil, "Set the project archs." , " .e.g " - , " - xmake project -k vs2015 -a \"x86,x64\"" } + , " - xmake project -k vs2015 -a \"x86" .. path.envsep() .. "x64\"" } , {nil, "outputdir", "v", ".", "Set the output directory." } } } -- cgit v1.3.1 From e98bcd58485a636dc897946f652be9067d37a9e0 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 15:01:53 +0800 Subject: replace old sep --- xmake/plugins/project/vstudio/impl/vs201x.lua | 6 ++++++ xmake/plugins/project/vsxmake/getinfo.lua | 6 ++++++ xmake/plugins/project/vsxmake/vsxmake.lua | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index 3ea83fac2..af0a18d0c 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -165,6 +165,9 @@ function _make_vsinfo_modes() local vsinfo_modes = {} local modes = option.get("modes") if modes then + if not modes:find("\"") then + modes = modes:gsub(",", path.envsep()) + end for _, mode in ipairs(path.splitenv(modes)) do table.insert(vsinfo_modes, mode:trim()) end @@ -181,6 +184,9 @@ function _make_vsinfo_archs() local vsinfo_archs = {} local archs = option.get("archs") if archs then + if not archs:find("\"") then + archs = archs:gsub(",", path.envsep()) + end for _, arch in ipairs(path.splitenv(archs)) do table.insert(vsinfo_archs, arch:trim()) end diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 97e1e4961..ceb955b46 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -129,6 +129,9 @@ function _make_vsinfo_modes() local vsinfo_modes = {} local modes = option.get("modes") if modes then + if not modes:find("\"") then + modes = modes:gsub(",", path.envsep()) + end for _, mode in ipairs(path.splitenv(modes)) do table.insert(vsinfo_modes, mode:trim()) end @@ -145,6 +148,9 @@ function _make_vsinfo_archs() local vsinfo_archs = {} local archs = option.get("archs") if archs then + if not archs:find("\"") then + archs = archs:gsub(",", path.envsep()) + end for _, arch in ipairs(path.splitenv(archs)) do table.insert(vsinfo_archs, arch:trim()) end diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 348138ed7..a3235f060 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -67,7 +67,7 @@ function _escape(str) str = str:sub(#("$(XmakeProjectDir)") + 1) end - str = (string.gsub(str, "[%%%$@'\";%?%*]", function (c) return assert(map[c]) end)) + str = (string.gsub(str, "[%%%$@';%?%*]", function (c) return assert(map[c]) end)) if has_prefix then str = "$(XmakeProjectDir)" .. str end -- cgit v1.3.1 From 8a976c88c7b9da0a306fbbeac22870a7b00b4682 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 15:35:54 +0800 Subject: fix escape --- xmake/plugins/project/vsxmake/getinfo.lua | 69 +++++++++++++++++++++++++------ xmake/plugins/project/vsxmake/vsxmake.lua | 31 +------------- 2 files changed, 58 insertions(+), 42 deletions(-) diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index ceb955b46..1f9760f1a 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -31,6 +31,30 @@ import("lib.detect.find_tool") import("actions.config.configheader", {alias = "generate_configheader", rootdir = os.programdir()}) import("actions.config.configfiles", {alias = "generate_configfiles", rootdir = os.programdir()}) +-- escape special chars in msbuild file +function _escape(str) + if not str then + return nil + end + + local map = + { ["%"] = "%25" -- Referencing metadata + ,["$"] = "%24" -- Referencing properties + ,["@"] = "%40" -- Referencing item lists + ,["'"] = "%27" -- Conditions and other expressions + ,[";"] = "%3B" -- List separator + ,["?"] = "%3F" -- Wildcard character for file names in Include and Exclude attributes + ,["*"] = "%2A" -- Wildcard character for use in file names in Include and Exclude attributes + -- html entities + ,["\""] = """ + ,["<"] = "<" + ,[">"] = ">" + ,["&"] = "&" + } + + return (string.gsub(str, "[%%%$@';%?%*\"<>&]", function (c) return assert(map[c]) end)) +end + function _make_dirs(dir) if dir == nil then return "" @@ -42,18 +66,33 @@ function _make_dirs(dir) end if path.is_absolute(dir) then if dir:startswith(project.directory()) then - return path.join("$(XmakeProjectDir)", path.relative(dir, project.directory())) + return path.join("$(XmakeProjectDir)", _escape(path.relative(dir, project.directory()))) end - return dir + return _escape(dir) end - return path.join("$(XmakeProjectDir)", dir) + return path.join("$(XmakeProjectDir)", _escape(dir)) end local r = {} for k, v in ipairs(dir) do r[k] = _make_dirs(v) end r = table.unique(r) - return path.joinenv(r) + return table.concat(r, ";") +end + +function _make_arrs(arr) + if arr == nil then + return "" + end + if type(arr) == "string" then + return _escape(arr) + end + local r = {} + for k, v in ipairs(arr) do + r[k] = _make_arrs(v) + end + r = table.unique(r) + return table.concat(r, ";") end function _get_values(target, name) @@ -71,7 +110,13 @@ end function _make_targetinfo(mode, arch, target) -- init target info - local targetinfo = { mode = mode, arch = arch, plat = config.get("plat"), vsarch = (arch == "x86" and "Win32" or arch) } + local targetinfo = + { + mode = mode + , arch = arch + , plat = config.get("plat") + , vsarch = (arch == "x86" and "Win32" or arch) + } -- write only if not default -- use target:get("xxx") rather than target:xxx() @@ -80,8 +125,8 @@ function _make_targetinfo(mode, arch, target) targetinfo.kind = target:get("kind") -- save target file - targetinfo.basename = target:get("basename") - targetinfo.filename = target:get("filename") + targetinfo.basename = _escape(target:get("basename")) + targetinfo.filename = _escape(target:get("filename")) -- save dirs targetinfo.targetdir = _make_dirs(target:get("targetdir")) @@ -93,8 +138,8 @@ function _make_targetinfo(mode, arch, target) targetinfo.linkdirs = _make_dirs(_get_values(target, "linkdirs")) -- save defines - targetinfo.defines = table.concat(_get_values(target, "defines"), ";") - targetinfo.languages = table.concat(_get_values(target, "languages"), ";") + targetinfo.defines = _make_arrs(_get_values(target, "defines")) + targetinfo.languages = _make_arrs(_get_values(target, "languages")) -- save runenvs local runenvs = {} @@ -272,14 +317,14 @@ function main(outputdir, vsinfo) local dir = path.directory(f) target._sub2[f] = { - path = f, - dir = dir + path = _escape(f), + dir = _escape(dir) } while dir ~= "." do if not dirs[dir] then dirs[dir] = { - dir = dir, + dir = _escape(dir), dir_id = hash.uuid(dir) } end diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index a3235f060..cf91eb40e 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -45,35 +45,6 @@ function _filter_files(files, exts) return f end --- escape special chars in msbuild file -function _escape(str) - if not str then - return nil - end - - local map = - { ["%"] = "%25" -- Referencing metadata - ,["$"] = "%24" -- Referencing properties - ,["@"] = "%40" -- Referencing item lists - ,["'"] = "%27" -- Conditions and other expressions - ,[";"] = "%3B" -- List separator - ,["?"] = "%3F" -- Wildcard character for file names in Include and Exclude attributes - ,["*"] = "%2A" -- Wildcard character for use in file names in Include and Exclude attributes - } - - local has_prefix = false - if str:startswith("$(XmakeProjectDir)") then - has_prefix = true - str = str:sub(#("$(XmakeProjectDir)") + 1) - end - - str = (string.gsub(str, "[%%%$@';%?%*]", function (c) return assert(map[c]) end)) - if has_prefix then - str = "$(XmakeProjectDir)" .. str - end - return str -end - function _buildparams(info, target, default) local function getprop(match, opt) @@ -91,7 +62,7 @@ function _buildparams(info, target, default) r = i[match] or r end - return _escape(r) or default + return r or default end local function listconfig(args) -- cgit v1.3.1 From 482dfde9fd5cfa7ca02d70d76baf4b3a25f1d2b1 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 16:36:12 +0800 Subject: add values from opts and packages --- xmake/core/base/table.lua | 15 ++++----------- xmake/plugins/project/vsxmake/getinfo.lua | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index 9af47b5a8..3fc5d92c8 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -258,17 +258,10 @@ function table.unique(array, barrier) end -- add unique item - if type(v) == "string" then - if not exists[v] then - exists[v] = true - table.insert(unique, v) - end - else - local key = "\"" .. tostring(v) .. "\"" - if not exists[key] then - exists[key] = true - table.insert(unique, v) - end + if not exists[v] then + -- v will not be nil + exists[v] = true + table.insert(unique, v) end end diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 1f9760f1a..205e0ac4b 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -97,13 +97,34 @@ end function _get_values(target, name) local values = table.wrap(target:get(name)) + + -- from deps for _, dep in irpairs(target:orderdeps()) do local depinherit = target:extraconf("deps", dep:name(), "inherit") if depinherit == nil or depinherit then table.join2(values, dep:get(name, {interface = true})) end end - return values + + -- from opts + for _, opt in ipairs(target:orderopts()) do + table.join2(values, table.wrap(opt:get(name))) + end + + -- from packages + for _, pkg in ipairs(target:orderpkgs()) do + -- uses them instead of the builtin configs if exists extra package config + -- e.g. `add_packages("xxx", {links = "xxx"})` + local configinfo = target:pkgconfig(pkg:name()) + if configinfo and configinfo[name] then + table.join2(values, configinfo[name]) + else + -- uses the builtin package configs + table.join2(values, pkg:get(name)) + end + end + + return table.unique(values) end -- make target info -- cgit v1.3.1 From 4aa3db8ef3c5814c4ac5751a53435f6c6e824e66 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 17:16:04 +0800 Subject: fix code style --- xmake/plugins/project/vsxmake/getinfo.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 205e0ac4b..8aba32ba4 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -107,9 +107,9 @@ function _get_values(target, name) end -- from opts - for _, opt in ipairs(target:orderopts()) do - table.join2(values, table.wrap(opt:get(name))) - end + for _, opt in ipairs(target:orderopts()) do + table.join2(values, table.wrap(opt:get(name))) + end -- from packages for _, pkg in ipairs(target:orderpkgs()) do -- cgit v1.3.1 From 5f0af08bc708259905d8bb5921fbe0b354b56f5c Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 18:01:47 +0800 Subject: add custom files --- xmake/plugins/project/vsxmake/vsproj/Xmake.props | 17 +++++++++++++++++ .../project/vsxmake/vsproj/templates/Xmake.Custom.files | 11 +++++++++++ .../vsxmake/vsproj/templates/Xmake.Custom.files.filters | 13 +++++++++++++ .../templates/vcxproj.filters/#target#.vcxproj.filters | 12 ++++++++++-- .../vsxmake/vsproj/templates/vcxproj/#target#.vcxproj | 6 ------ xmake/plugins/project/vsxmake/vsxmake.lua | 4 ++++ 6 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index 1814bc6b9..ac84bf1d7 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -138,4 +138,21 @@ $(XmakeTargetDir) $(XmakeBuilDir).vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\ + + + + + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files new file mode 100644 index 000000000..a894e8d0d --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files @@ -0,0 +1,11 @@ + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters new file mode 100644 index 000000000..f69e1abb7 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters @@ -0,0 +1,13 @@ + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters index a4c6cf5c1..80a13f280 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters @@ -15,10 +15,16 @@ #Import(Filter)# - + Properties - + + Properties + + + Properties + + Properties @@ -43,4 +49,6 @@ #Import(File.rc)# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj index 164140542..8df23001e 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj @@ -28,12 +28,6 @@ #Import(XmakeConfig)# #Import(XmakePath)# - - - - - #Import(Include)# diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index cf91eb40e..424d30256 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -32,6 +32,8 @@ local template_fil = path.join(template_root, "vcxproj.filters", "#target#.vcxpr local template_usr = path.join(template_root, "#target#.vcxproj.user") local template_props = path.join(template_root, "Xmake.Custom.props") local template_targets = path.join(template_root, "Xmake.Custom.targets") +local template_files = path.join(template_root, "Xmake.Custom.files") +local template_filefil = path.join(template_root, "Xmake.Custom.files.filters") function _filter_files(files, exts) local extset = hashset.from(exts) @@ -153,6 +155,8 @@ function make(version) -- add project custom file _trycp(template_props, proj_dir) _trycp(template_targets, proj_dir) + _trycp(template_files, proj_dir) + _trycp(template_filefil, proj_dir) -- add project user file _trycp(template_usr, proj_dir, target .. ".vcxproj.user") end -- cgit v1.3.1 From 623add4344bf5e5d29b116356de7d398c2ddec2f Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 18:21:48 +0800 Subject: add auto detect vs version --- xmake/plugins/project/main.lua | 21 ++++++++++++++++++++- xmake/plugins/project/vstudio/impl/vsinfo.lua | 2 +- xmake/plugins/project/vsxmake/vsxmake.lua | 5 +++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua index d2ce39a10..ede6989fb 100755 --- a/xmake/plugins/project/main.lua +++ b/xmake/plugins/project/main.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("core.base.task") +import("core.project.config") import("core.platform.environment") import("make.makefile") import("cmake.cmakelists") @@ -30,6 +31,22 @@ import("vsxmake.vsxmake") import("clang.compile_flags") import("clang.compile_commands") +function _vs(outputdir) + local vsver = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`") + vprint("using project kind vs%d", vsver) + if vsver < 2010 then + return vs.make(vsver)(outputdir) + else + return vsx.make(vsver)(outputdir) + end +end + +function _vsxmake(outputdir) + local vsver = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`") + vprint("using project kind vsxmake%d", vsver) + return vsxmake.make(vsver)(outputdir) +end + -- make project function _make(kind) @@ -48,17 +65,19 @@ function _make(kind) , vs2015 = vsx.make(2015) , vs2017 = vsx.make(2017) , vs2019 = vsx.make(2019) + , vs = _vs , vsxmake2010 = vsxmake.make(2010) , vsxmake2012 = vsxmake.make(2012) , vsxmake2013 = vsxmake.make(2013) , vsxmake2015 = vsxmake.make(2015) , vsxmake2017 = vsxmake.make(2017) , vsxmake2019 = vsxmake.make(2019) + , vsxmake = _vsxmake , compile_flags = compile_flags.make , compile_commands = compile_commands.make } assert(maps[kind], "the project kind(%s) is not supported!", kind) - + -- make it maps[kind](option.get("outputdir")) end diff --git a/xmake/plugins/project/vstudio/impl/vsinfo.lua b/xmake/plugins/project/vstudio/impl/vsinfo.lua index 3da30d398..bd512a775 100644 --- a/xmake/plugins/project/vstudio/impl/vsinfo.lua +++ b/xmake/plugins/project/vstudio/impl/vsinfo.lua @@ -89,5 +89,5 @@ local vsinfo = function main(version) assert(version) - return assert(vsinfo[version]); + return assert(vsinfo[version], "unsupported vs version (%d)", version); end \ No newline at end of file diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 424d30256..3443563a9 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -129,6 +129,11 @@ end -- make function make(version) + -- check + if version < 2010 then + raise("vsxmake does not support vs version lower than 2010") + end + return function(outputdir) local info = getinfo(outputdir, vsinfo(version)) local paramsprovidersln = _buildparams(info) -- cgit v1.3.1 From 0c469ed3843a73b3fbf73640b75715f72fc7be53 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 19:25:44 +0800 Subject: fix setenv --- xmake/core/base/os.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 6be21560c..53670360f 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -534,10 +534,10 @@ function os.runv(program, argv, opt) opt = opt or {} -- make temporary log file - local log = os.tmpfile() + local logfile = os.tmpfile() -- execute it - local ok = os.execv(program, argv, table.join(opt, {stdout = log, stderr = log})) + local ok = os.execv(program, argv, table.join(opt, {stdout = logfile, stderr = logfile})) if ok ~= 0 then -- make errors @@ -551,14 +551,14 @@ function os.runv(program, argv, opt) end -- remove the temporary log file - os.rm(log) + os.rm(logfile) -- failed return false, errors end -- remove the temporary log file - os.rm(log) + os.rm(logfile) -- ok return true @@ -948,9 +948,9 @@ function os.setenv(name, ...) local values = {...} if #values <= 1 then -- keep compatible with original implementation - os._setenv(name, values[1] or "") + return os._setenv(name, values[1] or "") else - os._setenv(path.joinenv(values)) + return os._setenv(path.joinenv(values)) end end -- cgit v1.3.1 From 4ba16a3ce3b556686455378e1f7386508e65d0fb Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 19:34:20 +0800 Subject: add project name --- xmake/modules/package/tools/meson.lua | 2 +- xmake/plugins/project/vstudio/impl/vs200x_solution.lua | 2 +- xmake/plugins/project/vstudio/impl/vs201x_solution.lua | 2 +- xmake/plugins/project/vsxmake/getinfo.lua | 2 +- xmake/plugins/project/vsxmake/vsxmake.lua | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index e5b25c450..dac331ac9 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -24,7 +24,7 @@ import("core.project.config") -- get build directory function _get_buildir() - _g.buildir = _g.buildir or "build_" .. hash.uuid():split('%-')[1] + _g.buildir = _g.buildir or ("build_" .. hash.uuid():split('%-')[1]) return _g.buildir end diff --git a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua index 5653059c5..1333da648 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua @@ -88,7 +88,7 @@ end function make(vsinfo) -- init solution name - vsinfo.solution_name = project.name() or "vs" .. vsinfo.vstudio_version + vsinfo.solution_name = project.name() or ("vs" .. vsinfo.vstudio_version) -- open solution file local slnfile = vsfile.open(path.join(vsinfo.solution_dir, vsinfo.solution_name .. ".sln"), "w") diff --git a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua index d38ac15cf..cfcc20509 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua @@ -96,7 +96,7 @@ end function make(vsinfo) -- init solution name - vsinfo.solution_name = project.name() or "vs" .. vsinfo.vstudio_version + vsinfo.solution_name = project.name() or ("vs" .. vsinfo.vstudio_version) -- open solution file local slnpath = path.join(vsinfo.solution_dir, vsinfo.solution_name .. ".sln") diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 8aba32ba4..ad05c4788 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -241,7 +241,7 @@ function main(outputdir, vsinfo) vsinfo.projectdir = project.directory() vsinfo.sln_projectfile = path.relative(project.file(), vsinfo.solution_dir) local projectfile = path.filename(project.file()) - vsinfo.slnfile = path.filename(project.directory()) + vsinfo.slnfile = project.name() or path.filename(project.directory()) -- write only if not default if projectfile ~= "xmake.lua" then vsinfo.projectfile = projectfile diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 3443563a9..6fe5bce24 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -139,7 +139,7 @@ function make(version) local paramsprovidersln = _buildparams(info) -- write solution file - local sln = path.join(info.solution_dir, info.slnfile .. "_vsxmake" .. info.vstudio_version .. ".sln") + local sln = path.join(info.solution_dir, info.slnfile .. ".sln") io.writefile(sln, render(template_sln, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidersln)) -- add solution custom file -- cgit v1.3.1 From 33729fbb22f06ec784cbabf9fe06847a6077e86c Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 17 Jul 2019 21:30:07 +0800 Subject: fix runv --- xmake/core/base/os.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 53670360f..617b0ee52 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -541,7 +541,7 @@ function os.runv(program, argv, opt) if ok ~= 0 then -- make errors - local errors = io.readfile(log) + local errors = io.readfile(logfile) if not errors or #errors == 0 then if argv ~= nil then errors = string.format("runv(%s %s) failed(%d)!", program, table.concat(argv, ' '), ok) -- cgit v1.3.1 From c9f0e8a551778e185b1fb92f2bb07d8cc3581f95 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 18 Jul 2019 10:04:03 +0800 Subject: rename file; support cuda build selected file --- xmake/plugins/project/vsxmake/vsproj/Xmake.props | 12 ++++++------ xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 9 ++++++++- .../project/vsxmake/vsproj/templates/Xmake.Custom.files | 11 ----------- .../vsxmake/vsproj/templates/Xmake.Custom.files.filters | 13 ------------- .../project/vsxmake/vsproj/templates/Xmake.Custom.items | 11 +++++++++++ .../vsxmake/vsproj/templates/Xmake.Custom.items.filters | 13 +++++++++++++ .../templates/vcxproj.filters/#target#.vcxproj.filters | 4 ++-- xmake/plugins/project/vsxmake/vsxmake.lua | 8 ++++---- 8 files changed, 44 insertions(+), 37 deletions(-) delete mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files delete mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items.filters diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index ac84bf1d7..e954a435b 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -145,14 +145,14 @@ Include="$(MSBuildProjectDirectory)\Xmake.Custom.props" /> - - + + - + diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 940490271..0f4b287f5 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -139,6 +139,7 @@ MSBuild Properties: PreprocessorDefinitions: %(ClCompile.PreprocessorDefinitions) LanguageStandard: %(ClCompile.LanguageStandard) SelectedFiles: $(SelectedFiles) + VCTargetsPath: $(VCTargetsPath) " Importance="High" /> @@ -177,12 +178,18 @@ MSBuild Properties: - + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files deleted file mode 100644 index a894e8d0d..000000000 --- a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters deleted file mode 100644 index f69e1abb7..000000000 --- a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.files.filters +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items new file mode 100644 index 000000000..a894e8d0d --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items @@ -0,0 +1,11 @@ + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items.filters b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items.filters new file mode 100644 index 000000000..f69e1abb7 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.items.filters @@ -0,0 +1,13 @@ + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters index 80a13f280..ce686b448 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters @@ -21,10 +21,10 @@ Properties - + Properties - + Properties diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 6fe5bce24..ac9e27c85 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -32,8 +32,8 @@ local template_fil = path.join(template_root, "vcxproj.filters", "#target#.vcxpr local template_usr = path.join(template_root, "#target#.vcxproj.user") local template_props = path.join(template_root, "Xmake.Custom.props") local template_targets = path.join(template_root, "Xmake.Custom.targets") -local template_files = path.join(template_root, "Xmake.Custom.files") -local template_filefil = path.join(template_root, "Xmake.Custom.files.filters") +local template_items = path.join(template_root, "Xmake.Custom.items") +local template_itemfil = path.join(template_root, "Xmake.Custom.items.filters") function _filter_files(files, exts) local extset = hashset.from(exts) @@ -160,8 +160,8 @@ function make(version) -- add project custom file _trycp(template_props, proj_dir) _trycp(template_targets, proj_dir) - _trycp(template_files, proj_dir) - _trycp(template_filefil, proj_dir) + _trycp(template_items, proj_dir) + _trycp(template_itemfil, proj_dir) -- add project user file _trycp(template_usr, proj_dir, target .. ".vcxproj.user") end -- cgit v1.3.1 From b71a78ee5767b0ca3f0be22d53f4811370ace9b2 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 18 Jul 2019 10:15:36 +0800 Subject: add rc file --- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 0f4b287f5..6d03b348e 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -184,10 +184,14 @@ MSBuild Properties: - + + - + + + + -- cgit v1.3.1 From 7feb3e7300568bd9070c4478f43748842d257dcd Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 18 Jul 2019 10:44:36 +0800 Subject: support emoji in VS --- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 6d03b348e..922a6600b 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -34,6 +34,7 @@ <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))" <_XmakeEnv> + chcp 65001 > NUL pushd "$(XmakeProjectDir)" set XMAKE_CONFIGDIR=$(XmakeConfigDir) set XMAKE_PROGRAM_DIR=$(XmakeProgramDir) @@ -54,36 +55,36 @@ - + - + - + - - + + @(File) --files="$(FileList)" - + - + -- cgit v1.3.1 From c37f3a99f894496196616db830b29d34b7102384 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 18 Jul 2019 10:51:11 +0800 Subject: use exec WorkingDirectory --- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 922a6600b..9d2dad1bb 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -35,7 +35,6 @@ <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))" <_XmakeEnv> chcp 65001 > NUL - pushd "$(XmakeProjectDir)" set XMAKE_CONFIGDIR=$(XmakeConfigDir) set XMAKE_PROGRAM_DIR=$(XmakeProgramDir) @@ -55,17 +54,17 @@ - - - @@ -78,12 +77,12 @@ --files="$(FileList)" - - -- cgit v1.3.1 From 8ef441ef5507b58e024c55e3f1d6b80284bef4d6 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 18 Jul 2019 16:45:06 +0800 Subject: trim end slash --- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 9d2dad1bb..55a698927 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -35,8 +35,8 @@ <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))" <_XmakeEnv> chcp 65001 > NUL - set XMAKE_CONFIGDIR=$(XmakeConfigDir) - set XMAKE_PROGRAM_DIR=$(XmakeProgramDir) + set XMAKE_CONFIGDIR=$(XmakeConfigDir.TrimEnd('/\'.ToCharArray())) + set XMAKE_PROGRAM_DIR=$(XmakeProgramDir.TrimEnd('/\'.ToCharArray())) -- cgit v1.3.1 From a8cc8e8989fd52574088200c5d6bbc3a4582d911 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 18 Jul 2019 18:18:58 +0800 Subject: fix --- xmake/core/base/os.lua | 2 +- xmake/core/base/path.lua | 7 +++---- xmake/plugins/project/vsxmake/getinfo.lua | 25 +++++++++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 617b0ee52..4c23ed0c4 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -950,7 +950,7 @@ function os.setenv(name, ...) -- keep compatible with original implementation return os._setenv(name, values[1] or "") else - return os._setenv(path.joinenv(values)) + return os._setenv(name, path.joinenv(values)) end end diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua index d15c42fc4..8b35a771c 100644 --- a/xmake/core/base/path.lua +++ b/xmake/core/base/path.lua @@ -163,10 +163,11 @@ end function path.joinenv(env_table) -- check - env_table = env_table or {} + if not env_table or #env_table == 0 then + return "" + end local envsep = path.envsep() - if xmake._HOST == "windows" then local tab = {} for _, v in ipairs(env_table) do @@ -181,8 +182,6 @@ function path.joinenv(env_table) else return table.concat(env_table, envsep) end - - return result end -- the last character is the path seperator? diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index ad05c4788..b012ffff0 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -38,18 +38,19 @@ function _escape(str) end local map = - { ["%"] = "%25" -- Referencing metadata - ,["$"] = "%24" -- Referencing properties - ,["@"] = "%40" -- Referencing item lists - ,["'"] = "%27" -- Conditions and other expressions - ,[";"] = "%3B" -- List separator - ,["?"] = "%3F" -- Wildcard character for file names in Include and Exclude attributes - ,["*"] = "%2A" -- Wildcard character for use in file names in Include and Exclude attributes - -- html entities - ,["\""] = """ - ,["<"] = "<" - ,[">"] = ">" - ,["&"] = "&" + { + ["%"] = "%25" -- Referencing metadata + , ["$"] = "%24" -- Referencing properties + , ["@"] = "%40" -- Referencing item lists + , ["'"] = "%27" -- Conditions and other expressions + , [";"] = "%3B" -- List separator + , ["?"] = "%3F" -- Wildcard character for file names in Include and Exclude attributes + , ["*"] = "%2A" -- Wildcard character for use in file names in Include and Exclude attributes + -- html entities + , ["\""] = """ + , ["<"] = "<" + , [">"] = ">" + , ["&"] = "&" } return (string.gsub(str, "[%%%$@';%?%*\"<>&]", function (c) return assert(map[c]) end)) -- cgit v1.3.1 From e765aa75b91f847e93893271abe1cf265126da54 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Thu, 18 Jul 2019 19:50:02 +0800 Subject: cleanup code --- xmake/plugins/project/main.lua | 33 +++++++---------------------- xmake/plugins/project/vstudio/vs.lua | 17 ++++++++++++--- xmake/plugins/project/vstudio/vsx.lua | 35 ------------------------------- xmake/plugins/project/vsxmake/vsxmake.lua | 5 +++++ 4 files changed, 27 insertions(+), 63 deletions(-) delete mode 100644 xmake/plugins/project/vstudio/vsx.lua diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua index ede6989fb..cfcf10c2b 100755 --- a/xmake/plugins/project/main.lua +++ b/xmake/plugins/project/main.lua @@ -26,27 +26,10 @@ import("core.platform.environment") import("make.makefile") import("cmake.cmakelists") import("vstudio.vs") -import("vstudio.vsx") import("vsxmake.vsxmake") import("clang.compile_flags") import("clang.compile_commands") -function _vs(outputdir) - local vsver = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`") - vprint("using project kind vs%d", vsver) - if vsver < 2010 then - return vs.make(vsver)(outputdir) - else - return vsx.make(vsver)(outputdir) - end -end - -function _vsxmake(outputdir) - local vsver = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`") - vprint("using project kind vsxmake%d", vsver) - return vsxmake.make(vsver)(outputdir) -end - -- make project function _make(kind) @@ -59,20 +42,20 @@ function _make(kind) , vs2003 = vs.make(2003) , vs2005 = vs.make(2005) , vs2008 = vs.make(2008) - , vs2010 = vsx.make(2010) - , vs2012 = vsx.make(2012) - , vs2013 = vsx.make(2013) - , vs2015 = vsx.make(2015) - , vs2017 = vsx.make(2017) - , vs2019 = vsx.make(2019) - , vs = _vs + , vs2010 = vs.make(2010) + , vs2012 = vs.make(2012) + , vs2013 = vs.make(2013) + , vs2015 = vs.make(2015) + , vs2017 = vs.make(2017) + , vs2019 = vs.make(2019) + , vs = vs.make() , vsxmake2010 = vsxmake.make(2010) , vsxmake2012 = vsxmake.make(2012) , vsxmake2013 = vsxmake.make(2013) , vsxmake2015 = vsxmake.make(2015) , vsxmake2017 = vsxmake.make(2017) , vsxmake2019 = vsxmake.make(2019) - , vsxmake = _vsxmake + , vsxmake = vsxmake.make() , compile_flags = compile_flags.make , compile_commands = compile_commands.make } diff --git a/xmake/plugins/project/vstudio/vs.lua b/xmake/plugins/project/vstudio/vs.lua index a50180a23..e108ef22f 100644 --- a/xmake/plugins/project/vstudio/vs.lua +++ b/xmake/plugins/project/vstudio/vs.lua @@ -20,16 +20,27 @@ -- imports import("impl.vs200x") +import("impl.vs201x") import("impl.vsinfo") -- make factory function make(version) + if not version then + version = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`") + vprint("using project kind vs%d", version) + end + -- get vs version info local info = vsinfo(version) - -- make - return function(outputdir) - vs200x.make(outputdir, info) + if vsver < 2010 then + return function(outputdir) + vs200x.make(outputdir, info) + end + else + return function(outputdir) + vs201x.make(outputdir, info) + end end end diff --git a/xmake/plugins/project/vstudio/vsx.lua b/xmake/plugins/project/vstudio/vsx.lua deleted file mode 100644 index ff8b83281..000000000 --- a/xmake/plugins/project/vstudio/vsx.lua +++ /dev/null @@ -1,35 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015 - 2019, TBOOX Open Source Group. --- --- @author ruki --- @file vsx.lua --- - --- imports -import("impl.vs201x") -import("impl.vsinfo") - --- make factory -function make(version) - - -- get vs version info - local info = vsinfo(version) - - -- make - return function(outputdir) - vs201x.make(outputdir, info) - end -end diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index ac9e27c85..785569aef 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -129,6 +129,11 @@ end -- make function make(version) + if not version then + version = assert(tonumber(config.get("vs")), "invalid vs version, run `xmake f --vs=2015`") + vprint("using project kind vsxmake%d", version) + end + -- check if version < 2010 then raise("vsxmake does not support vs version lower than 2010") -- cgit v1.3.1 From ca45f8941e0b69582021d34061873c8752f76154 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Fri, 19 Jul 2019 00:03:57 +0800 Subject: fix config --- xmake/plugins/project/vstudio/vs.lua | 3 ++- xmake/plugins/project/vsxmake/getinfo.lua | 2 +- xmake/plugins/project/vsxmake/vsxmake.lua | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/project/vstudio/vs.lua b/xmake/plugins/project/vstudio/vs.lua index e108ef22f..1284828c6 100644 --- a/xmake/plugins/project/vstudio/vs.lua +++ b/xmake/plugins/project/vstudio/vs.lua @@ -22,6 +22,7 @@ import("impl.vs200x") import("impl.vs201x") import("impl.vsinfo") +import("core.project.config") -- make factory function make(version) @@ -34,7 +35,7 @@ function make(version) -- get vs version info local info = vsinfo(version) - if vsver < 2010 then + if version < 2010 then return function(outputdir) vs200x.make(outputdir, info) end diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index b012ffff0..906148fa2 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -242,7 +242,7 @@ function main(outputdir, vsinfo) vsinfo.projectdir = project.directory() vsinfo.sln_projectfile = path.relative(project.file(), vsinfo.solution_dir) local projectfile = path.filename(project.file()) - vsinfo.slnfile = project.name() or path.filename(project.directory()) + vsinfo.slnfile = path.filename(project.directory()) -- write only if not default if projectfile ~= "xmake.lua" then vsinfo.projectfile = projectfile diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 785569aef..2526b00cb 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -23,6 +23,7 @@ import("core.base.hashset") import("vstudio.impl.vsinfo", { rootdir = path.directory(os.scriptdir()) }) import("render") import("getinfo") +import("core.project.config") local template_root = path.join(os.scriptdir(), "vsproj", "templates") local template_sln = path.join(template_root, "sln", "vsxmake.sln") -- cgit v1.3.1