diff options
| author | ruki <[email protected]> | 2019-07-19 12:51:49 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-19 12:51:49 +0800 |
| commit | 660b6f4e66b95ae87b814fdaa538924cfc0f476c (patch) | |
| tree | 89a6bf45c6dc6ef52872b5d99d8b622c43ce9835 /xmake/plugins | |
| parent | ae533cdc5bcee78d7a24b64eac430d9197d0e043 (diff) | |
| parent | ca45f8941e0b69582021d34061873c8752f76154 (diff) | |
Merge pull request #488 from OpportunityLiu/vsproj
Improve vsxmake
Diffstat (limited to 'xmake/plugins')
37 files changed, 703 insertions, 536 deletions
diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua index d2ce39a10..cfcf10c2b 100755 --- a/xmake/plugins/project/main.lua +++ b/xmake/plugins/project/main.lua @@ -21,11 +21,11 @@ -- imports import("core.base.option") import("core.base.task") +import("core.project.config") 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") @@ -42,23 +42,25 @@ 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) + , 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.make() , 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/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.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index d414a69a3..af0a18d0c 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -165,7 +165,10 @@ function _make_vsinfo_modes() local vsinfo_modes = {} local modes = option.get("modes") if modes then - for _, mode in ipairs(modes:split(',')) do + 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 else @@ -181,7 +184,10 @@ function _make_vsinfo_archs() local vsinfo_archs = {} local archs = option.get("archs") if archs then - for _, arch in ipairs(archs:split(',')) do + 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 else 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/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/vstudio/vs.lua b/xmake/plugins/project/vstudio/vs.lua index a50180a23..1284828c6 100644 --- a/xmake/plugins/project/vstudio/vs.lua +++ b/xmake/plugins/project/vstudio/vs.lua @@ -20,16 +20,28 @@ -- imports import("impl.vs200x") +import("impl.vs201x") import("impl.vsinfo") +import("core.project.config") -- 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 version < 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/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 4567adb1e..906148fa2 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -31,6 +31,31 @@ 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,36 +67,78 @@ 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 table.concat(r, path.envsep()) + 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) 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 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 +147,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 +160,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 = {} @@ -103,7 +170,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") @@ -129,7 +196,10 @@ function _make_vsinfo_modes() local vsinfo_modes = {} local modes = option.get("modes") if modes then - for _, mode in ipairs(modes:split(',')) do + 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 else @@ -145,7 +215,10 @@ function _make_vsinfo_archs() local vsinfo_archs = {} local archs = option.get("archs") if archs then - for _, arch in ipairs(archs:split(',')) do + 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 else @@ -266,14 +339,14 @@ function main(outputdir, vsinfo) local dir = path.directory(f) target._sub2[f] = { - path = path.join("$(XmakeProjectDir)", 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/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..e954a435b 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -1,141 +1,158 @@ <?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup Label="XmakePropsInit"> - <!-- initialize this first to allow `Condition="'$(XmakeMode)|$(XmakeArch)' == 'release|x86'"` in custom props file --> - <XmakeMode Condition="'$(XmakeMode)' == ''">$(Configuration)</XmakeMode> - <XmakeMode Condition="'$(XmakeMode)' == ''">release</XmakeMode> + <PropertyGroup Label="XmakePropsInit"> + <!-- initialize this first to allow `Condition="'$(XmakeMode)|$(XmakeArch)' == 'release|x86'"` in custom props file --> + <XmakeMode Condition="'$(XmakeMode)' == ''">$(Configuration)</XmakeMode> + <XmakeMode Condition="'$(XmakeMode)' == ''">release</XmakeMode> - <XmakeArch Condition="'$(XmakeArch)' == '' And '$(Platform.ToLower())' == 'win32'">x86</XmakeArch> - <XmakeArch Condition="'$(XmakeArch)' == '' And '$(Platform.ToLower())' != 'win32'">$(Platform)</XmakeArch> - <XmakeArch Condition="'$(XmakeArch)' == ''">x86</XmakeArch> - </PropertyGroup> + <XmakeArch Condition="'$(XmakeArch)' == '' And '$(Platform.ToLower())' == 'win32'">x86</XmakeArch> + <XmakeArch Condition="'$(XmakeArch)' == '' And '$(Platform.ToLower())' != 'win32'">$(Platform)</XmakeArch> + <XmakeArch Condition="'$(XmakeArch)' == ''">x86</XmakeArch> + </PropertyGroup> - <ImportGroup Label="CustomSettings"> - <!--only search 2 levels to avoid accidentally import--> - <Import Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.props')" - Project="$(MSBuildProjectDirectory)\Xmake.Custom.props" /> - <Import Condition="!Exists('$(MSBuildProjectDirectory)\Xmake.Custom.props') And Exists('$(MSBuildProjectDirectory)\..\Xmake.Custom.props')" - Project="$(MSBuildProjectDirectory)\..\Xmake.Custom.props" /> - </ImportGroup> + <ImportGroup Label="CustomSettings"> + <!--only search 2 levels to avoid accidentally import--> + <Import Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.props')" + Project="$(MSBuildProjectDirectory)\Xmake.Custom.props" /> + <Import Condition="!Exists('$(MSBuildProjectDirectory)\Xmake.Custom.props') And Exists('$(MSBuildProjectDirectory)\..\Xmake.Custom.props')" + Project="$(MSBuildProjectDirectory)\..\Xmake.Custom.props" /> + </ImportGroup> - <PropertyGroup Label="XmakePropsFallback"> - <XmakeBasename Condition="'$(XmakeBasename)' == ''">$(XmakeTarget)</XmakeBasename> - <XmakeBasename Condition="'$(XmakeBasename)' == ''">$(TargetName)</XmakeBasename> - <XmakeBasename Condition="'$(XmakeBasename)' == ''">$(MSBuildProjectName)</XmakeBasename> + <PropertyGroup Label="XmakePropsFallback"> + <XmakeBasename Condition="'$(XmakeBasename)' == ''">$(XmakeTarget)</XmakeBasename> + <XmakeBasename Condition="'$(XmakeBasename)' == ''">$(TargetName)</XmakeBasename> + <XmakeBasename Condition="'$(XmakeBasename)' == ''">$(MSBuildProjectName)</XmakeBasename> - <XmakeKind Condition="'$(XmakeKind)' == ''">binary</XmakeKind> - <XmakePlat Condition="'$(XmakePlat)' == ''">windows</XmakePlat> - </PropertyGroup> + <XmakeKind Condition="'$(XmakeKind)' == ''">binary</XmakeKind> + <XmakePlat Condition="'$(XmakePlat)' == ''">windows</XmakePlat> + </PropertyGroup> - <PropertyGroup Label="XmakePathsFallback"> - <XmakeBuilDir Condition="'$(XmakeBuilDir)' == ''">$(XmakeProjectDir)\build</XmakeBuilDir> - <XmakeTargetDir Condition="'$(XmakeTargetDir)' == ''">$(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeTargetDir> - <XmakeConfigFileDir Condition="'$(XmakeConfigFileDir)' == ''">$(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeConfigFileDir> + <PropertyGroup Label="XmakePathsFallback"> + <XmakeBuilDir Condition="'$(XmakeBuilDir)' == ''">$(XmakeProjectDir)\build</XmakeBuilDir> + <XmakeTargetDir Condition="'$(XmakeTargetDir)' == ''">$(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeTargetDir> + <XmakeConfigFileDir Condition="'$(XmakeConfigFileDir)' == ''">$(XmakeBuilDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeConfigFileDir> - <XmakeConfigDir Condition="'$(XmakeConfigDir)' == ''">$(XMAKE_CONFIGDIR)</XmakeConfigDir> - <XmakeConfigDir Condition="'$(XmakeConfigDir)' == ''">$(XmakeProjectDir)\.xmake</XmakeConfigDir> + <XmakeConfigDir Condition="'$(XmakeConfigDir)' == ''">$(XMAKE_CONFIGDIR)</XmakeConfigDir> + <XmakeConfigDir Condition="'$(XmakeConfigDir)' == ''">$(XmakeProjectDir)\.xmake</XmakeConfigDir> - <XmakeRunDir Condition="'$(XmakeRunDir)' == ''">$(XmakeTargetDir)</XmakeRunDir> - </PropertyGroup> + <XmakeRunDir Condition="'$(XmakeRunDir)' == ''">$(XmakeTargetDir)</XmakeRunDir> + </PropertyGroup> - <PropertyGroup Label="XmakePathsResolve"> - <!-- resolve if they are relative paths --> - <XmakeProjectDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeProjectDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeProjectDir)'))</XmakeProjectDir> - <XmakeScriptDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeScriptDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeScriptDir)'))</XmakeScriptDir> - <XmakeBuilDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeBuilDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeBuilDir)'))</XmakeBuilDir> - <XmakeTargetDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeTargetDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeTargetDir)'))</XmakeTargetDir> - <XmakeConfigDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigDir)'))</XmakeConfigDir> - <XmakeConfigFileDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigFileDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigFileDir)'))</XmakeConfigFileDir> - <XmakeRunDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeRunDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeRunDir)'))</XmakeRunDir> + <PropertyGroup Label="XmakePathsResolve"> + <!-- resolve if they are relative paths --> + <XmakeProjectDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeProjectDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeProjectDir)'))</XmakeProjectDir> + <XmakeScriptDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeScriptDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeScriptDir)'))</XmakeScriptDir> + <XmakeBuilDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeBuilDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeBuilDir)'))</XmakeBuilDir> + <XmakeTargetDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeTargetDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeTargetDir)'))</XmakeTargetDir> + <XmakeConfigDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigDir)'))</XmakeConfigDir> + <XmakeConfigFileDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigFileDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigFileDir)'))</XmakeConfigFileDir> + <XmakeRunDir Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeRunDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeRunDir)'))</XmakeRunDir> - <!-- normalize paths --> - <XmakeProgramDir>$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)/'))</XmakeProgramDir> - <XmakeProjectDir>$([System.IO.Path]::GetFullPath('$(XmakeProjectDir)/'))</XmakeProjectDir> - <XmakeScriptDir>$([System.IO.Path]::GetFullPath('$(XmakeScriptDir)/'))</XmakeScriptDir> - <XmakeBuilDir>$([System.IO.Path]::GetFullPath('$(XmakeBuilDir)/'))</XmakeBuilDir> - <XmakeTargetDir>$([System.IO.Path]::GetFullPath('$(XmakeTargetDir)/'))</XmakeTargetDir> - <XmakeConfigDir>$([System.IO.Path]::GetFullPath('$(XmakeConfigDir)/'))</XmakeConfigDir> - <XmakeConfigFileDir>$([System.IO.Path]::GetFullPath('$(XmakeConfigFileDir)/'))</XmakeConfigFileDir> - <XmakeRunDir>$([System.IO.Path]::GetFullPath('$(XmakeRunDir)/'))</XmakeRunDir> - </PropertyGroup> + <!-- normalize paths --> + <XmakeProgramDir>$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)/'))</XmakeProgramDir> + <XmakeProjectDir>$([System.IO.Path]::GetFullPath('$(XmakeProjectDir)/'))</XmakeProjectDir> + <XmakeScriptDir>$([System.IO.Path]::GetFullPath('$(XmakeScriptDir)/'))</XmakeScriptDir> + <XmakeBuilDir>$([System.IO.Path]::GetFullPath('$(XmakeBuilDir)/'))</XmakeBuilDir> + <XmakeTargetDir>$([System.IO.Path]::GetFullPath('$(XmakeTargetDir)/'))</XmakeTargetDir> + <XmakeConfigDir>$([System.IO.Path]::GetFullPath('$(XmakeConfigDir)/'))</XmakeConfigDir> + <XmakeConfigFileDir>$([System.IO.Path]::GetFullPath('$(XmakeConfigFileDir)/'))</XmakeConfigFileDir> + <XmakeRunDir>$([System.IO.Path]::GetFullPath('$(XmakeRunDir)/'))</XmakeRunDir> + </PropertyGroup> - <PropertyGroup Label="XmakeFlagsFallback"> - <XmakeWarning Condition="'$(XmakeWarning)' == ''">true</XmakeWarning> - <XmakeVerbose Condition="'$(XmakeVerbose)' == ''">false</XmakeVerbose> - <XmakeDiagnosis Condition="'$(XmakeDiagnosis)' == ''">false</XmakeDiagnosis> - </PropertyGroup> + <PropertyGroup Label="XmakeFlagsFallback"> + <XmakeWarning Condition="'$(XmakeWarning)' == ''">true</XmakeWarning> + <XmakeVerbose Condition="'$(XmakeVerbose)' == ''">false</XmakeVerbose> + <XmakeDiagnosis Condition="'$(XmakeDiagnosis)' == ''">false</XmakeDiagnosis> + </PropertyGroup> - <PropertyGroup Condition="'$(WindowsTargetPlatformVersion)' == ''"> - <WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)' == '14.0'">10.0.10240.0</WindowsTargetPlatformVersion> - <WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)' == '15.0'">10.0.14393.0</WindowsTargetPlatformVersion> - <WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)' == '16.0'">10.0.17763.0</WindowsTargetPlatformVersion> - <WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">10.0</WindowsTargetPlatformVersion> - </PropertyGroup> - <PropertyGroup Condition="'$(PlatformToolset)' == ''"> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset> - </PropertyGroup> + <PropertyGroup Condition="'$(WindowsTargetPlatformVersion)' == ''"> + <WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)' == '14.0'">10.0.10240.0</WindowsTargetPlatformVersion> + <WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)' == '15.0'">10.0.14393.0</WindowsTargetPlatformVersion> + <WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)' == '16.0'">10.0.17763.0</WindowsTargetPlatformVersion> + <WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <PropertyGroup Condition="'$(PlatformToolset)' == ''"> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset> + </PropertyGroup> - <PropertyGroup Label="AdditionalProps"> - <UseOfMfc Condition="'$(XmakeMfcKind)' != ''">$(XmakeMfcKind)</UseOfMfc> - <CharacterSet Condition="'$(CharacterSet)' == '' And ($(XmakeDefines.Contains(';UNICODE;')) Or $(XmakeDefines.EndsWith(';UNICODE')) Or $(XmakeDefines.StartsWith('UNICODE;')) Or $(XmakeDefines.Equals('UNICODE')))">Unicode</CharacterSet> - <CharacterSet Condition="'$(CharacterSet)' == ''">MultiByte</CharacterSet> - </PropertyGroup> + <PropertyGroup Label="AdditionalProps"> + <UseOfMfc Condition="'$(XmakeMfcKind)' != ''">$(XmakeMfcKind)</UseOfMfc> + <CharacterSet Condition="'$(CharacterSet)' == '' And ($(XmakeDefines.Contains(';UNICODE;')) Or $(XmakeDefines.EndsWith(';UNICODE')) Or $(XmakeDefines.StartsWith('UNICODE;')) Or $(XmakeDefines.Equals('UNICODE')))">Unicode</CharacterSet> + <CharacterSet Condition="'$(CharacterSet)' == ''">MultiByte</CharacterSet> + </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <Choose> - <When Condition="'$(XmakeKind)' == 'binary'"> - <PropertyGroup> - <ConfigurationType>Application</ConfigurationType> - </PropertyGroup> - </When> - <When Condition="'$(XmakeKind)' == 'shared'"> - <PropertyGroup> - <ConfigurationType>DynamicLibrary</ConfigurationType> - </PropertyGroup> - </When> - <When Condition="'$(XmakeKind)' == 'static'"> - <PropertyGroup> - <ConfigurationType>StaticLibrary</ConfigurationType> - </PropertyGroup> - </When> - </Choose> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <Choose> + <When Condition="'$(XmakeKind)' == 'binary'"> + <PropertyGroup> + <ConfigurationType>Application</ConfigurationType> + </PropertyGroup> + </When> + <When Condition="'$(XmakeKind)' == 'shared'"> + <PropertyGroup> + <ConfigurationType>DynamicLibrary</ConfigurationType> + </PropertyGroup> + </When> + <When Condition="'$(XmakeKind)' == 'static'"> + <PropertyGroup> + <ConfigurationType>StaticLibrary</ConfigurationType> + </PropertyGroup> + </When> + </Choose> - <ItemDefinitionGroup> - <ClCompile> - <PreprocessorDefinitions>%(PreprocessorDefinitions);$(XmakeDefines)</PreprocessorDefinitions> - <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx17'))">stdcpp17</LanguageStandard> - <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx14'))">stdcpp14</LanguageStandard> - <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx11'))">stdcpp11</LanguageStandard> - </ClCompile> - </ItemDefinitionGroup> + <ItemDefinitionGroup> + <ClCompile> + <PreprocessorDefinitions>%(PreprocessorDefinitions);$(XmakeDefines)</PreprocessorDefinitions> + <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx17'))">stdcpp17</LanguageStandard> + <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx14'))">stdcpp14</LanguageStandard> + <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('cxx11'))">stdcpp11</LanguageStandard> + </ClCompile> + </ItemDefinitionGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - <Import Condition="'$(XmakeCudaVersion)' != '' And Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props')" - Project="$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props" /> - </ImportGroup> + <ImportGroup Label="ExtensionSettings"> + <Import Condition="'$(XmakeCudaVersion)' != '' And Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props')" + Project="$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props" /> + </ImportGroup> - <ImportGroup Label="PropertySheets"> - <Import Condition="Exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" - Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> - </ImportGroup> + <ImportGroup Label="PropertySheets"> + <Import Condition="Exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" + Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> + </ImportGroup> - <PropertyGroup Label="GlobalsFallback"> - <TargetName Condition="'$(XmakeFilename)' == ''">$(XmakeBasename)</TargetName> - <TargetName Condition="'$(XmakeFilename)' != ''">$([System.IO.Path]::GetFileNameWithoutExtension('$(XmakeFilename)'))</TargetName> - <TargetExt Condition="'$(XmakeFilename)' != ''">$([System.IO.Path]::GetExtension('$(XmakeFilename)'))</TargetExt> - </PropertyGroup> - - <PropertyGroup Label="Path"> - <IncludePath>$(XmakeIncludeDir);$(IncludePath)</IncludePath> - <LibraryPath>$(XmakeLinkDir);$(LibraryPath)</LibraryPath> - <OutDir>$(XmakeTargetDir)</OutDir> - <IntDir>$(XmakeBuilDir).vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\</IntDir> - </PropertyGroup> + <PropertyGroup Label="GlobalsFallback"> + <TargetName Condition="'$(XmakeFilename)' == ''">$(XmakeBasename)</TargetName> + <TargetName Condition="'$(XmakeFilename)' != ''">$([System.IO.Path]::GetFileNameWithoutExtension('$(XmakeFilename)'))</TargetName> + <TargetExt Condition="'$(XmakeFilename)' != ''">$([System.IO.Path]::GetExtension('$(XmakeFilename)'))</TargetExt> + </PropertyGroup> + + <PropertyGroup Label="Path"> + <IncludePath>$(XmakeIncludeDir);$(IncludePath)</IncludePath> + <LibraryPath>$(XmakeLinkDir);$(LibraryPath)</LibraryPath> + <OutDir>$(XmakeTargetDir)</OutDir> + <IntDir>$(XmakeBuilDir).vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\</IntDir> + </PropertyGroup> + + <!-- Common files --> + <ItemGroup> + <None Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.props')" + Include="$(MSBuildProjectDirectory)\Xmake.Custom.props" /> + <None Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.targets')" + Include="$(MSBuildProjectDirectory)\Xmake.Custom.targets" /> + <None Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.items')" + Include="$(MSBuildProjectDirectory)\Xmake.Custom.items" /> + <None Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.items.filters')" + Include="$(MSBuildProjectDirectory)\Xmake.Custom.items.filters" /> + <None Condition="'$(XmakeScriptDir)' != '$(XmakeProjectDir)' And Exists('$(XmakeScriptDir)\xmake.lua')" + Include="$(XmakeScriptDir)\xmake.lua" /> + </ItemGroup> + + <Import Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.items')" + Project="$(MSBuildProjectDirectory)\Xmake.Custom.items" /> </Project> diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 05102ab40..55a698927 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -1,169 +1,205 @@ <?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - <Import Condition="'$(XmakeCudaVersion)' != '' And Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets')" - Project="$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets" /> - </ImportGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + <Import Condition="'$(XmakeCudaVersion)' != '' And Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets')" + Project="$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets" /> + </ImportGroup> - <PropertyGroup Label="XmakeInternal"> - <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' != ''">-F "$(XmakeProjectFile)"</_XmakeProjectFlag> - <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' == ''">-P .</_XmakeProjectFlag> - - <_XmakeCommonFlags>$(XmakeCommonFlags.Trim())</_XmakeCommonFlags> - <_XmakeCommonFlags Condition="$(XmakeVerbose)">$(_XmakeCommonFlags) -v</_XmakeCommonFlags> - <_XmakeCommonFlags Condition="$(XmakeDiagnosis)">$(_XmakeCommonFlags) -D</_XmakeCommonFlags> - <_XmakeCommonFlags>$(_XmakeCommonFlags) $(_XmakeProjectFlag)</_XmakeCommonFlags> + <PropertyGroup Label="XmakeInternal"> + <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' != ''">-F "$(XmakeProjectFile)"</_XmakeProjectFlag> + <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' == ''">-P .</_XmakeProjectFlag> + + <_XmakeCommonFlags>$(XmakeCommonFlags.Trim())</_XmakeCommonFlags> + <_XmakeCommonFlags Condition="$(XmakeVerbose)">-v $(_XmakeCommonFlags)</_XmakeCommonFlags> + <_XmakeCommonFlags Condition="$(XmakeDiagnosis)">-D $(_XmakeCommonFlags)</_XmakeCommonFlags> + <_XmakeCommonFlags>$(XmakeCommonFlags.Trim())</_XmakeCommonFlags> + <_XmakeCommonFlags>$(_XmakeCommonFlags) $(_XmakeProjectFlag)</_XmakeCommonFlags> - <_XmakeBuilDir>$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)').TrimEnd('/\'.ToCharArray()))</_XmakeBuilDir> + <_XmakeBuilDir>$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)').TrimEnd('/\'.ToCharArray()))</_XmakeBuilDir> - <_XmakeConfigFlags>$(XmakeConfigFlags.Trim())</_XmakeConfigFlags> - <_XmakeConfigFlags>-p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$(_XmakeBuilDir)" $(_XmakeConfigFlags)</_XmakeConfigFlags> + <_XmakeConfigFlags>$(XmakeConfigFlags.Trim())</_XmakeConfigFlags> + <_XmakeConfigFlags>-p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$(_XmakeBuilDir)" $(_XmakeConfigFlags)</_XmakeConfigFlags> - <_XmakeBuildFlags>$(XmakeBuildFlags.Trim())</_XmakeBuildFlags> - <_XmakeBuildFlags Condition="$(XmakeWarning)">$(_XmakeBuildFlags) -w</_XmakeBuildFlags> - - <_XmakeCleanFlags>$(XmakeCleanFlags.Trim())</_XmakeCleanFlags> + <_XmakeBuildFlags>$(XmakeBuildFlags.Trim())</_XmakeBuildFlags> + <_XmakeBuildFlags Condition="$(XmakeWarning)">-w $(_XmakeBuildFlags)</_XmakeBuildFlags> + + <_XmakeCleanFlags>$(XmakeCleanFlags.Trim())</_XmakeCleanFlags> - <_XmakeBuildFlags>$(_XmakeBuildFlags.Trim())</_XmakeBuildFlags> - <_XmakeCleanFlags>$(_XmakeCleanFlags.Trim())</_XmakeCleanFlags> - <_XmakeConfigFlags>$(_XmakeConfigFlags.Trim())</_XmakeConfigFlags> - <_XmakeCommonFlags>$(_XmakeCommonFlags.Trim())</_XmakeCommonFlags> + <_XmakeBuildFlags>$(_XmakeBuildFlags.Trim())</_XmakeBuildFlags> + <_XmakeCleanFlags>$(_XmakeCleanFlags.Trim())</_XmakeCleanFlags> + <_XmakeConfigFlags>$(_XmakeConfigFlags.Trim())</_XmakeConfigFlags> + <_XmakeCommonFlags>$(_XmakeCommonFlags.Trim())</_XmakeCommonFlags> - <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))"</_XmakeExecutable> - <_XmakeEnv> - pushd "$(XmakeProjectDir)" - set XMAKE_CONFIGDIR=$(XmakeConfigDir) - set XMAKE_PROGRAM_DIR=$(XmakeProgramDir) - </_XmakeEnv> - </PropertyGroup> + <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))"</_XmakeExecutable> + <_XmakeEnv> + chcp 65001 > NUL + set XMAKE_CONFIGDIR=$(XmakeConfigDir.TrimEnd('/\'.ToCharArray())) + set XMAKE_PROGRAM_DIR=$(XmakeProgramDir.TrimEnd('/\'.ToCharArray())) + </_XmakeEnv> + </PropertyGroup> - <Target Name="_XmakeProjCheck"> - <Warning Condition="'$(XmakeCudaVersion)' != '' And !Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets')" - Text="File '$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets' not found" /> - <Warning Condition="'$(XmakeCudaVersion)' != '' And !Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props')" - Text="File '$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props' not found" /> - <Error Condition="!Exists('$(XmakeProgramDir)\xmake.exe')" - Text="xmake.exe not found at '$(XmakeProgramDir)', please set XMAKE_PROGRAM_DIR in environments or XmakeProgramDir in vcxproj file" /> - <Error Condition="'$(XmakeProjectFile)' == '' And !Exists('$(XmakeProjectDir)\xmake.lua')" - Text="xmake.lua not found at '$(XmakeProjectDir)', please set XmakeProjectDir in vcxproj file" /> - <Error Condition="'$(XmakeProjectFile)' != '' And !Exists('$(XmakeProjectDir)\$(XmakeProjectFile)')" - Text="$(XmakeProjectFile) not found at '$(XmakeProjectDir)', please set XmakeProjectDir in vcxproj file" /> - </Target> - <Target Name="_XmakeConfig" DependsOnTargets="_XmakeProjCheck"> - <Message Text="$xmake config $(_XmakeCommonFlags) $(_XmakeConfigFlags) $(XmakeTarget)" Importance="High" /> - <Exec Command="$(_XmakeEnv) -$(_XmakeExecutable) config $(_XmakeCommonFlags) $(_XmakeConfigFlags) $(XmakeTarget)" EchoOff="true"/> - </Target> - <Target Name="_XmakeReconfig" DependsOnTargets="_XmakeProjCheck"> - <Message Text="$xmake config $(_XmakeCommonFlags) -c $(_XmakeConfigFlags) $(XmakeTarget)" Importance="High" /> - <Exec Command="$(_XmakeEnv) -$(_XmakeExecutable) config $(_XmakeCommonFlags) -c $(_XmakeConfigFlags) $(XmakeTarget)" EchoOff="true"/> - </Target> - <Target Name="_XmakeBuild" DependsOnTargets="_XmakeProjCheck"> - <Message Text="$xmake build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" Importance="High" /> - <Exec Command="$(_XmakeEnv) -$(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" EchoOff="true"/> - </Target> - <Target Name="_XmakeClean" DependsOnTargets="_XmakeProjCheck"> - <Message Text="$xmake clean $(_XmakeCommonFlags) -a $(_XmakeCleanFlags) $(XmakeTarget)" Importance="High" /> - <Exec Command="$(_XmakeEnv) -$(_XmakeExecutable) clean $(_XmakeCommonFlags) -a $(_XmakeCleanFlags) $(XmakeTarget)" EchoOff="true"/> - </Target> + <Target Name="_XmakeProjCheck"> + <Warning Condition="'$(XmakeCudaVersion)' != '' And !Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets')" + Text="File '$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets' not found" /> + <Warning Condition="'$(XmakeCudaVersion)' != '' And !Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props')" + Text="File '$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props' not found" /> + <Error Condition="!Exists('$(XmakeProgramDir)\xmake.exe')" + Text="xmake.exe not found at '$(XmakeProgramDir)', please set XMAKE_PROGRAM_DIR in environments or XmakeProgramDir in vcxproj file" /> + <Error Condition="'$(XmakeProjectFile)' == '' And !Exists('$(XmakeProjectDir)\xmake.lua')" + Text="xmake.lua not found at '$(XmakeProjectDir)', please set XmakeProjectDir in vcxproj file" /> + <Error Condition="'$(XmakeProjectFile)' != '' And !Exists('$(XmakeProjectDir)\$(XmakeProjectFile)')" + Text="$(XmakeProjectFile) not found at '$(XmakeProjectDir)', please set XmakeProjectDir in vcxproj file" /> + </Target> + <Target Name="_XmakeConfig" DependsOnTargets="_XmakeProjCheck"> + <Message Text="$xmake config $(_XmakeCommonFlags) $(_XmakeConfigFlags) $(XmakeTarget)" Importance="High" /> + <Exec WorkingDirectory="$(XmakeProjectDir)" StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) + $(_XmakeExecutable) config $(_XmakeCommonFlags) $(_XmakeConfigFlags) $(XmakeTarget)" EchoOff="true" /> + </Target> + <Target Name="_XmakeReconfig" DependsOnTargets="_XmakeProjCheck"> + <Message Text="$xmake config $(_XmakeCommonFlags) -c $(_XmakeConfigFlags) $(XmakeTarget)" Importance="High" /> + <Exec WorkingDirectory="$(XmakeProjectDir)" StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) + $(_XmakeExecutable) config $(_XmakeCommonFlags) -c $(_XmakeConfigFlags) $(XmakeTarget)" EchoOff="true" /> + </Target> + <Target Name="_XmakeBuild" DependsOnTargets="_XmakeProjCheck"> + <Message Text="$xmake build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" Importance="High" /> + <Exec WorkingDirectory="$(XmakeProjectDir)" StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) + $(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" EchoOff="true" /> + </Target> + <Target Name="_XmakeBuildFile" DependsOnTargets="_XmakeProjCheck"> + <ItemGroup> + <SelectedFile Include="$(SelectedFiles)" /> + <File Include="$([MSBuild]::MakeRelative('$(XmakeProjectDir)', $([System.IO.Path]::GetFullPath('%(SelectedFile.Identity)'))))" /> + </ItemGroup> + <PropertyGroup> + <FileList>@(File)</FileList> + <FileFlag>--files="$(FileList)"</FileFlag> + </PropertyGroup> + <Message Text="$xmake build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(FileFlag) $(XmakeTarget)" Importance="High" /> + <Exec WorkingDirectory="$(XmakeProjectDir)" StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) + $(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(FileFlag) $(XmakeTarget)" EchoOff="true" /> + </Target> + <Target Name="_XmakeClean" DependsOnTargets="_XmakeProjCheck"> + <Message Text="$xmake clean $(_XmakeCommonFlags) -a $(_XmakeCleanFlags) $(XmakeTarget)" Importance="High" /> + <Exec WorkingDirectory="$(XmakeProjectDir)" StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) + $(_XmakeExecutable) clean $(_XmakeCommonFlags) -a $(_XmakeCleanFlags) $(XmakeTarget)" EchoOff="true" /> + </Target> - <Target Name="Show"> - <Message Text=" + <Target Name="Show"> + <Message Text=" MSBuild Properties: - 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) - " Importance="High" /> - </Target> + 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) + VCTargetsPath: $(VCTargetsPath) + " Importance="High" /> + </Target> + + <Target Name="BeforeBuild" /> + <Target Name="AfterBuild" /> + <Target Name="Build" Condition="'$(DesignTimeBuild)' != 'true'"> + <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> + <CallTarget Targets="BeforeBuild" /> + <CallTarget Targets="_XmakeConfig;_XmakeBuild" /> + <CallTarget Targets="AfterBuild" /> + </Target> + + <Target Name="BeforeClean" /> + <Target Name="AfterClean" /> + <Target Name="Clean" Condition="'$(DesignTimeBuild)' != 'true'"> + <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> + <CallTarget Targets="BeforeClean" /> + <CallTarget Targets="_XmakeClean;_XmakeReconfig" /> + <CallTarget Targets="AfterClean" /> + </Target> - <Target Name="BeforeBuild" /> - <Target Name="AfterBuild" /> - <Target Name="Build" Condition="'$(DesignTimeBuild)' != 'true'"> - <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> - <CallTarget Targets="BeforeBuild" /> - <CallTarget Targets="_XmakeConfig;_XmakeBuild" /> - <CallTarget Targets="AfterBuild" /> - </Target> + <Target Name="BeforeRebuild" /> + <Target Name="AfterRebuild" /> + <Target Name="Rebuild" Condition="'$(DesignTimeBuild)' != 'true'"> + <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> + <CallTarget Targets="BeforeRebuild" /> + <CallTarget Targets="BeforeClean" /> + <CallTarget Targets="_XmakeClean;_XmakeReconfig" /> + <CallTarget Targets="AfterClean" /> + <CallTarget Targets="BeforeBuild" /> + <CallTarget Targets="_XmakeBuild" /> + <CallTarget Targets="AfterBuild" /> + <CallTarget Targets="AfterRebuild" /> + </Target> - <Target Name="BeforeClean" /> - <Target Name="AfterClean" /> - <Target Name="Clean" Condition="'$(DesignTimeBuild)' != 'true'"> - <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> - <CallTarget Targets="BeforeClean" /> - <CallTarget Targets="_XmakeClean;_XmakeReconfig" /> - <CallTarget Targets="AfterClean" /> - </Target> - <Target Name="BeforeRebuild" /> - <Target Name="AfterRebuild" /> - <Target Name="Rebuild" Condition="'$(DesignTimeBuild)' != 'true'"> - <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> - <CallTarget Targets="BeforeRebuild" /> - <CallTarget Targets="BeforeClean" /> - <CallTarget Targets="_XmakeClean;_XmakeReconfig" /> - <CallTarget Targets="AfterClean" /> - <CallTarget Targets="BeforeBuild" /> - <CallTarget Targets="_XmakeBuild" /> - <CallTarget Targets="AfterBuild" /> - <CallTarget Targets="AfterRebuild" /> - </Target> + <Target Name="BeforeBuildFiles" /> + <Target Name="AfterBuildFiles" /> + <Target Name="BuildFiles" Condition="'$(DesignTimeBuild)' != 'true'"> + <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> + <CallTarget Targets="BeforeBuildFiles" /> + <CallTarget Targets="_XmakeConfig;_XmakeBuildFile" /> + <CallTarget Targets="AfterBuildFiles" /> + </Target> + <!-- override default compile commands --> + <Target Name="ClCompile" Condition="'$(DesignTimeBuild)' != 'true'"> + <CallTarget Targets="BuildFiles" /> + </Target> + <Target Name="ResourceCompile" Condition="'$(DesignTimeBuild)' != 'true'"> + <CallTarget Targets="BuildFiles" /> + </Target> + <Target Name="CudaBuild" Condition="'$(DesignTimeBuild)' != 'true'"> + <CallTarget Targets="BuildFiles" /> + </Target> - <ImportGroup Label="CustomTargets"> - <!--only search 2 levels to avoid accidentally import--> - <Import Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.targets')" - Project="$(MSBuildProjectDirectory)\Xmake.Custom.targets" /> - <Import Condition="!Exists('$(MSBuildProjectDirectory)\Xmake.Custom.targets') And Exists('$(MSBuildProjectDirectory)\..\Xmake.Custom.targets')" - Project="$(MSBuildProjectDirectory)\..\Xmake.Custom.targets" /> - </ImportGroup> + <ImportGroup Label="CustomTargets"> + <!--only search 2 levels to avoid accidentally import--> + <Import Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.targets')" + Project="$(MSBuildProjectDirectory)\Xmake.Custom.targets" /> + <Import Condition="!Exists('$(MSBuildProjectDirectory)\Xmake.Custom.targets') And Exists('$(MSBuildProjectDirectory)\..\Xmake.Custom.targets')" + Project="$(MSBuildProjectDirectory)\..\Xmake.Custom.targets" /> + </ImportGroup> </Project> 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 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <LocalDebuggerCommandArguments></LocalDebuggerCommandArguments> - <LocalDebuggerWorkingDirectory>$(XmakeRunDir)</LocalDebuggerWorkingDirectory> - <LocalDebuggerEnvironment>$(XmakeRunEnvs) + <PropertyGroup> + <LocalDebuggerCommandArguments></LocalDebuggerCommandArguments> + <LocalDebuggerWorkingDirectory>$(XmakeRunDir)</LocalDebuggerWorkingDirectory> + <LocalDebuggerEnvironment>$(XmakeRunEnvs) $(LocalDebuggerEnvironment)</LocalDebuggerEnvironment> - <LocalDebuggerMergeEnvironment>true</LocalDebuggerMergeEnvironment> - </PropertyGroup> + <LocalDebuggerMergeEnvironment>true</LocalDebuggerMergeEnvironment> + </PropertyGroup> </Project>
\ No newline at end of file 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <!-- + Use this file to include custom files for visual studio projects. + + This file will be imported by .vcxproj + --> + <ItemGroup> + <!-- <None Include="$(XmakeProjectDir)\xxx\yyy\zzz" /> --> + </ItemGroup> +</Project> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <!-- + Use this file to include custom files for visual studio projects. + + This file will be imported by .vcxproj.filters + --> + <ItemGroup> + <!-- <None Include="$(XmakeProjectDir)\xxx\yyy\zzz"> + <Filter>xxx\yyy</Filter> + </None> --> + </ItemGroup> +</Project> 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 @@ <?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <!-- inherit parent settings --> - <Import Condition="Exists('$(MSBuildThisFileDirectory)\..\Xmake.Custom.props')" - Project="$(MSBuildThisFileDirectory)\..\Xmake.Custom.props" /> - - <PropertyGroup Label="XmakePaths"> - <!-- set environment XMAKE_CONFIGDIR for xmake tasks --> - <!-- - <XmakeConfigDir Condition="'$(XmakeMode)|$(XmakeArch)' == 'release|x86'">$(XmakeProjectDir)\.xmake</XmakeConfigDir> - <XmakeBuilDir>$(XmakeProjectDir)\build</XmakeBuilDir> - --> - </PropertyGroup> + <!-- inherit parent settings --> + <Import Condition="Exists('$(MSBuildThisFileDirectory)\..\Xmake.Custom.props')" + Project="$(MSBuildThisFileDirectory)\..\Xmake.Custom.props" /> + + <PropertyGroup Label="XmakePaths"> + <!-- set environment XMAKE_CONFIGDIR for xmake tasks --> + <!-- <XmakeConfigDir Condition="'$(XmakeMode)|$(XmakeArch)' == 'release|x86'">$(XmakeProjectDir)\.xmake</XmakeConfigDir> --> - <PropertyGroup Label="XmakeFlags"> - <!-- Configure these flags to customize xmake build process --> - <!-- - Inherit parents: - <XmakeCleanFlags>$(XmakeCleanflags) -D</XmakeCleanFlags> - Override parents: - <XmakeCleanFlags>-D</XmakeCleanFlags> - Respect parents: - <XmakeCleanFlags Condition=" '$(XmakeCleanFlags)' == '' ">-D</XmakeCleanFlags> + <!-- set output dir for xmake tasks --> + <!-- <XmakeBuilDir>$(XmakeProjectDir)\build</XmakeBuilDir> --> + </PropertyGroup> - For -w, -v and -D, use <XmakeWarning>, <XmakeVerbose> and <XmakeDiagnosis> is more convenient. - --> - <XmakeWarning Condition="'$(XmakeWarning)' == ''">true</XmakeWarning> - <XmakeVerbose Condition="'$(XmakeVerbose)' == ''">false</XmakeVerbose> - <XmakeDiagnosis Condition="'$(XmakeDiagnosis)' == ''">false</XmakeDiagnosis> - <XmakeCleanFlags>$(XmakeCleanflags)</XmakeCleanFlags> - <XmakeBuildFlags>$(XmakeBuildFlags)</XmakeBuildFlags> - <XmakeConfigFlags>$(XmakeConfigFlags)</XmakeConfigFlags> - <XmakeCommonFlags>$(XmakeCommonFlags)</XmakeCommonFlags> - </PropertyGroup> + <PropertyGroup Label="XmakeFlags"> + <!-- Configure these flags to customize xmake build process --> + <!-- + Inherit parents: + <XmakeCleanFlags>$(XmakeCleanflags) -D</XmakeCleanFlags> + Override parents: + <XmakeCleanFlags>-D</XmakeCleanFlags> + Respect parents: + <XmakeCleanFlags Condition=" '$(XmakeCleanFlags)' == '' ">-D</XmakeCleanFlags> + + For -w, -v and -D, use <XmakeWarning>, <XmakeVerbose> and <XmakeDiagnosis> is more convenient. + --> + + <!-- Set -w for "xmake build" --> + <!-- <XmakeWarning Condition="'$(XmakeWarning)' == ''">true</XmakeWarning> --> + + <!-- Set -v for all xmake call --> + <!-- <XmakeVerbose Condition="'$(XmakeVerbose)' == ''">false</XmakeVerbose> --> + + <!-- Set -D for all xmake call --> + <!-- <XmakeDiagnosis Condition="'$(XmakeDiagnosis)' == ''">false</XmakeDiagnosis> --> + + + <!-- Additional flags for "xmake clean" --> + <XmakeCleanFlags>$(XmakeCleanflags)</XmakeCleanFlags> + + <!-- Additional flags for "xmake build" --> + <XmakeBuildFlags>$(XmakeBuildFlags)</XmakeBuildFlags> + + <!-- Additional flags for "xmake config" --> + <XmakeConfigFlags>$(XmakeConfigFlags)</XmakeConfigFlags> + + <!-- Additional flags for all xmake call --> + <XmakeCommonFlags>$(XmakeCommonFlags)</XmakeCommonFlags> + </PropertyGroup> </Project> 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 @@ <?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <!-- inherit parent settings --> - <Import Condition="Exists('$(MSBuildThisFileDirectory)\..\Xmake.Custom.targets')" - Project="$(MSBuildThisFileDirectory)\..\Xmake.Custom.targets" /> + <!-- inherit parent settings --> + <Import Condition="Exists('$(MSBuildThisFileDirectory)\..\Xmake.Custom.targets')" + Project="$(MSBuildThisFileDirectory)\..\Xmake.Custom.targets" /> - <!-- Override these targets to customize your build workflow --> - <!-- - If you uncomment targets below, - targets with same name that comes from ../Xmake.Custom.targets will be overrided. + <!-- Override these targets to customize your build workflow --> + <!-- + If you uncomment targets below, + targets with same name that comes from ../Xmake.Custom.targets will be overrided. - You can also define your own targets and call them like: - <Target Name="BeforeBuild"> - <CallTarget Targets="CustomStep1;CustomStep2" /> - </Target> - - To find task that you can used in custom targets, - see: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-task-reference - --> + You can also define your own targets and call them like: + <Target Name="BeforeBuild"> + <CallTarget Targets="CustomStep1;CustomStep2" /> + </Target> + + To find task that you can used in custom targets, + see: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-task-reference + --> - <!-- <Target Name="BeforeRebuild"></Target> --> - <!-- <Target Name="AfterRebuild"></Target> --> - <!-- <Target Name="BeforeBuild"></Target> --> - <!-- <Target Name="AfterBuild"></Target> --> - <!-- <Target Name="BeforeClean"></Target> --> - <!-- <Target Name="AfterClean"></Target> --> + <!-- <Target Name="BeforeRebuild"></Target> --> + <!-- <Target Name="AfterRebuild"></Target> --> + <!-- <Target Name="BeforeBuild"></Target> --> + <!-- <Target Name="AfterBuild"></Target> --> + <!-- <Target Name="BeforeClean"></Target> --> + <!-- <Target Name="AfterClean"></Target> --> + <!-- <Target Name="BeforeBuildFiles"></Target> --> + <!-- <Target Name="AfterBuildFiles"></Target> --> </Project> 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..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 @@ -2,45 +2,53 @@ <!-- #xmake_info# - This file is auto generated by xmake. + This file is auto generated by xmake. - Please DO NOT EDIT since all your modification will lost after re-generation. - See https://github.com/xmake-io/xmake/pull/472 for more infomation. + Please DO NOT EDIT since all your modification will lost after re-generation. + See https://github.com/xmake-io/xmake/pull/472 for more infomation. --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Properties"> - <UniqueIdentifier>{CC7C6180-942D-056E-3227-E6A2B3FB19CD}</UniqueIdentifier> - </Filter> + <ItemGroup> + <Filter Include="Properties"> + <UniqueIdentifier>{CC7C6180-942D-056E-3227-E6A2B3FB19CD}</UniqueIdentifier> + </Filter> #Import(Filter)# - </ItemGroup> - <ItemGroup> - <None Include="Xmake.Custom.props"> - <Filter>Properties</Filter> - </None> - <None Include="Xmake.Custom.targets"> - <Filter>Properties</Filter> - </None> - <None Include="$(XmakeScriptDir)\xmake.lua"> - <Filter>Properties</Filter> - </None> - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> + <None Include="$(MSBuildProjectDirectory)\Xmake.Custom.props"> + <Filter>Properties</Filter> + </None> + <None Include="$(MSBuildProjectDirectory)\Xmake.Custom.targets"> + <Filter>Properties</Filter> + </None> + <None Include="$(MSBuildProjectDirectory)\Xmake.Custom.items"> + <Filter>Properties</Filter> + </None> + <None Include="$(MSBuildProjectDirectory)\Xmake.Custom.items.filters"> + <Filter>Properties</Filter> + </None> + <None Include="$(XmakeScriptDir)\xmake.lua"> + <Filter>Properties</Filter> + </None> + </ItemGroup> + <ItemGroup> #Import(Include)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.c)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.cxx)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.cu)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.obj)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.rc)# - </ItemGroup> + </ItemGroup> + <Import Condition="Exists('$(MSBuildThisFileDirectory)\Xmake.Custom.files.filters')" + Project="$(MSBuildThisFileDirectory)\Xmake.Custom.files.filters" /> </Project> 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 @@ - <ClCompile Include="#path#"> - <Filter>#dir#</Filter> - </ClCompile> + <ClCompile Include="$(XmakeProjectDir)#path#"> + <Filter>#dir#</Filter> + </ClCompile> 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 @@ - <CudaCompile Include="#path#"> - <Filter>#dir#</Filter> - </CudaCompile> + <CudaCompile Include="$(XmakeProjectDir)#path#"> + <Filter>#dir#</Filter> + </CudaCompile> 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 @@ - <ClCompile Include="#path#"> - <Filter>#dir#</Filter> - </ClCompile> + <ClCompile Include="$(XmakeProjectDir)#path#"> + <Filter>#dir#</Filter> + </ClCompile> 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 @@ - <Object Include="#path#"> - <Filter>#dir#</Filter> - </Object> + <Object Include="$(XmakeProjectDir)#path#"> + <Filter>#dir#</Filter> + </Object> 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 @@ - <ResourceCompile Include="#path#"> - <Filter>#dir#</Filter> - </ResourceCompile> + <ResourceCompile Include="$(XmakeProjectDir)#path#"> + <Filter>#dir#</Filter> + </ResourceCompile> 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 @@ - <Filter Include="#dir#"> - <UniqueIdentifier>{#dir_id#}</UniqueIdentifier> - </Filter> + <Filter Include="#dir#"> + <UniqueIdentifier>{#dir_id#}</UniqueIdentifier> + </Filter> 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 @@ - <ClInclude Include="#path#"> - <Filter>#dir#</Filter> - </ClInclude> + <ClInclude Include="$(XmakeProjectDir)#path#"> + <Filter>#dir#</Filter> + </ClInclude> diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj index d0e4e94d7..8df23001e 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj @@ -2,58 +2,52 @@ <!-- #xmake_info# - This file is auto generated by xmake. + This file is auto generated by xmake. - Please DO NOT EDIT since all your modification will lost after re-generation. - If you would like to have any customization, - edit Xmake.Custom.props and Xmake.Custom.targets instead. + Please DO NOT EDIT since all your modification will lost after re-generation. + If you would like to have any customization, + edit Xmake.Custom.props and Xmake.Custom.targets instead. - See https://github.com/xmake-io/xmake/pull/472 for more infomation. + See https://github.com/xmake-io/xmake/pull/472 for more infomation. --> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> + <ItemGroup Label="ProjectConfigurations"> #Import(ProjectConfiguration)# - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{#target_id#}</ProjectGuid> - <XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">$(XMAKE_PROGRAM_DIR)</XmakeProgramDir> - <XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">#programdir#</XmakeProgramDir> - <Configuration Condition="'$(Configuration)' == ''">release</Configuration> - <Platform Condition="'$(Platform)' == ''">Win32</Platform> - <XmakeScriptDir>#scriptdir#</XmakeScriptDir> - <XmakeProjectDir>#projectdir#</XmakeProjectDir> - <XmakeProjectFile>#projectfile#</XmakeProjectFile> - <XmakeTarget>#target#</XmakeTarget> - </PropertyGroup> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{#target_id#}</ProjectGuid> + <XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">$(XMAKE_PROGRAM_DIR)</XmakeProgramDir> + <XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">#programdir#</XmakeProgramDir> + <Configuration Condition="'$(Configuration)' == ''">release</Configuration> + <Platform Condition="'$(Platform)' == ''">Win32</Platform> + <XmakeScriptDir>#scriptdir#</XmakeScriptDir> + <XmakeProjectDir>#projectdir#</XmakeProjectDir> + <XmakeProjectFile>#projectfile#</XmakeProjectFile> + <XmakeTarget>#target#</XmakeTarget> + </PropertyGroup> #Import(XmakeConfig)# #Import(XmakePath)# - <Import Project="$(XmakeProgramDir)\plugins\project\vsxmake\vsproj\xmake.props" /> - <ItemGroup> - <None Include="Xmake.Custom.props" /> - <None Include="Xmake.Custom.targets" /> - <None Condition="'$(XmakeScriptDir)' != '$(XmakeProjectDir)' And Exists('$(XmakeScriptDir)\xmake.lua')" - Include="$(XmakeScriptDir)\xmake.lua" /> - </ItemGroup> - <ItemGroup> + <Import Project="$(XmakeProgramDir)\plugins\project\vsxmake\vsproj\xmake.props" /> + <ItemGroup> #Import(Include)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.c)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.cxx)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.cu)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.obj)# - </ItemGroup> - <ItemGroup> + </ItemGroup> + <ItemGroup> #Import(File.rc)# - </ItemGroup> - <!-- <ItemGroup> + </ItemGroup> + <!-- <ItemGroup> #Import(ProjectRef)# - </ItemGroup> --> - <Import Project="$(XmakeProgramDir)\plugins\project\vsxmake\vsproj\xmake.targets" /> + </ItemGroup> --> + <Import Project="$(XmakeProgramDir)\plugins\project\vsxmake\vsproj\xmake.targets" /> </Project> 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 @@ - <ClCompile Include="#path#"> - <CompileAs>CompileAsC</CompileAs> - </ClCompile> + <ClCompile Include="$(XmakeProjectDir)#path#"> + <CompileAs>CompileAsC</CompileAs> + </ClCompile> 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 @@ - <CudaCompile Include="#path#" /> + <CudaCompile Include="$(XmakeProjectDir)#path#" /> 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 @@ - <ClCompile Include="#path#"> - <CompileAs>CompileAsCpp</CompileAs> - </ClCompile> + <ClCompile Include="$(XmakeProjectDir)#path#"> + <CompileAs>CompileAsCpp</CompileAs> + </ClCompile> 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 @@ - <Object Include="#path#" /> + <Object Include="$(XmakeProjectDir)#path#" /> 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 @@ - <ResourceCompile Include="#path#" /> + <ResourceCompile Include="$(XmakeProjectDir)#path#" /> 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 @@ - <ClInclude Include="#path#" /> + <ClInclude Include="$(XmakeProjectDir)#path#" /> 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 @@ - <ProjectConfiguration Include="#mode#|#arch#"> - <Configuration>#mode#</Configuration> - <Platform>#vsarch#</Platform> - </ProjectConfiguration> + <ProjectConfiguration Include="#mode#|#arch#"> + <Configuration>#mode#</Configuration> + <Platform>#vsarch#</Platform> + </ProjectConfiguration> 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 @@ - <ProjectReference Include="..\#target#\#target#.vcxproj"> - <Project>{#target_id#}</Project> - </ProjectReference> + <ProjectReference Include="..\#target#\#target#.vcxproj"> + <Project>{#target_id#}</Project> + </ProjectReference> 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 @@ - <PropertyGroup Label="XmakeConfig" Condition="'$(Configuration)|$(Platform)'=='#mode#|#vsarch#'"> - <XmakeBasename>#basename#</XmakeBasename> - <XmakeFilename>#filename#</XmakeFilename> - <XmakeMode>#mode#</XmakeMode> - <XmakePlat>#plat#</XmakePlat> - <XmakeArch>#arch#</XmakeArch> - <XmakeKind>#kind#</XmakeKind> - <XmakeDefines>#defines#</XmakeDefines> - <XmakeLanguages>#languages#</XmakeLanguages> - <XmakeCudaVersion>#cudaver#</XmakeCudaVersion> - <XmakeMfcKind>#mfckind#</XmakeMfcKind> - <XmakeRunEnvs>#runenvs#</XmakeRunEnvs> - </PropertyGroup> + <PropertyGroup Label="XmakeConfig" Condition="'$(Configuration)|$(Platform)'=='#mode#|#vsarch#'"> + <XmakeBasename>#basename#</XmakeBasename> + <XmakeFilename>#filename#</XmakeFilename> + <XmakeMode>#mode#</XmakeMode> + <XmakePlat>#plat#</XmakePlat> + <XmakeArch>#arch#</XmakeArch> + <XmakeKind>#kind#</XmakeKind> + <XmakeDefines>#defines#</XmakeDefines> + <XmakeLanguages>#languages#</XmakeLanguages> + <XmakeCudaVersion>#cudaver#</XmakeCudaVersion> + <XmakeMfcKind>#mfckind#</XmakeMfcKind> + <XmakeRunEnvs>#runenvs#</XmakeRunEnvs> + </PropertyGroup> 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 @@ - <PropertyGroup Label="XmakePath" Condition="'$(Configuration)|$(Platform)'=='#mode#|#vsarch#'"> - <XmakeBuilDir>#buildir#</XmakeBuilDir> - <XmakeConfigDir>#configdir#</XmakeConfigDir> - <XmakeConfigFileDir>#configfiledir#</XmakeConfigFileDir> - <XmakeTargetDir>#targetdir#</XmakeTargetDir> - <XmakeIncludeDir>#includedirs#</XmakeIncludeDir> - <XmakeLinkDir>#linkdirs#</XmakeLinkDir> - <XmakeRunDir>#rundir#</XmakeRunDir> - </PropertyGroup> + <PropertyGroup Label="XmakePath" Condition="'$(Configuration)|$(Platform)'=='#mode#|#vsarch#'"> + <XmakeBuilDir>#buildir#</XmakeBuilDir> + <XmakeConfigDir>#configdir#</XmakeConfigDir> + <XmakeConfigFileDir>#configfiledir#</XmakeConfigFileDir> + <XmakeTargetDir>#targetdir#</XmakeTargetDir> + <XmakeIncludeDir>#includedirs#</XmakeIncludeDir> + <XmakeLinkDir>#linkdirs#</XmakeLinkDir> + <XmakeRunDir>#rundir#</XmakeRunDir> + </PropertyGroup> diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index cf91eb40e..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") @@ -32,6 +33,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_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) @@ -127,12 +130,22 @@ 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") + end + return function(outputdir) local info = getinfo(outputdir, vsinfo(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 @@ -153,6 +166,8 @@ function make(version) -- add project custom file _trycp(template_props, proj_dir) _trycp(template_targets, 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 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." } } } |
