From 515a9c3f542ef1b104a3af9a2398335e2d10fe7c Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sat, 13 Jul 2019 09:32:30 +0800 Subject: support call xmake from msbuild --- xmake/modules/detect/tools/find_nvcc.lua | 2 +- xmake/plugins/project/main.lua | 39 ++- .../plugins/project/vstudio/impl/vs200x_vcproj.lua | 15 +- .../project/vstudio/impl/vs201x_solution.lua | 3 - .../project/vstudio/impl/vs201x_vcxproj.lua | 39 +-- .../vstudio/impl/vs201x_vcxproj_filters.lua | 3 - xmake/plugins/project/vstudio/impl/vsinfo.lua | 93 +++++++ xmake/plugins/project/vstudio/vs.lua | 35 +++ xmake/plugins/project/vstudio/vs2002.lua | 36 --- xmake/plugins/project/vstudio/vs2003.lua | 36 --- xmake/plugins/project/vstudio/vs2005.lua | 36 --- xmake/plugins/project/vstudio/vs2008.lua | 36 --- xmake/plugins/project/vstudio/vs2010.lua | 37 --- xmake/plugins/project/vstudio/vs2012.lua | 37 --- xmake/plugins/project/vstudio/vs2013.lua | 37 --- xmake/plugins/project/vstudio/vs2015.lua | 37 --- xmake/plugins/project/vstudio/vs2017.lua | 37 --- xmake/plugins/project/vstudio/vs2019.lua | 37 --- xmake/plugins/project/vstudio/vsx.lua | 35 +++ xmake/plugins/project/vsxmake/getinfo.lua | 292 +++++++++++++++++++++ xmake/plugins/project/vsxmake/render.lua | 74 ++++++ xmake/plugins/project/vsxmake/vsproj/Xmake.props | 139 ++++++++++ xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 161 ++++++++++++ .../vsxmake/vsproj/templates/#target#.vcxproj.user | 10 + .../vsxmake/vsproj/templates/Xmake.Custom.props | 35 +++ .../vsxmake/vsproj/templates/Xmake.Custom.targets | 27 ++ .../templates/sln/ProjConfig(target,mode,arch) | 2 + .../vsxmake/vsproj/templates/sln/Project(target) | 2 + .../vsproj/templates/sln/SlnConfig(mode,arch) | 1 + .../vsxmake/vsproj/templates/sln/vsxmake.sln | 34 +++ .../vcxproj.filters/#target#.vcxproj.filters | 43 +++ .../vsproj/templates/vcxproj.filters/File.c(filec) | 3 + .../templates/vcxproj.filters/File.cu(filecu) | 3 + .../templates/vcxproj.filters/File.cxx(filecxx) | 3 + .../templates/vcxproj.filters/File.obj(fileobj) | 3 + .../templates/vcxproj.filters/File.rc(filerc) | 3 + .../vsproj/templates/vcxproj.filters/Filter(dir) | 3 + .../vsproj/templates/vcxproj/#target#.vcxproj | 56 ++++ .../vsxmake/vsproj/templates/vcxproj/File.c(filec) | 3 + .../vsproj/templates/vcxproj/File.cu(filecu) | 1 + .../vsproj/templates/vcxproj/File.cxx(filecxx) | 3 + .../vsproj/templates/vcxproj/File.obj(fileobj) | 1 + .../vsproj/templates/vcxproj/File.rc(filerc) | 1 + .../vcxproj/ProjectConfiguration(mode,arch) | 4 + .../vsproj/templates/vcxproj/ProjectRef(dep) | 3 + .../templates/vcxproj/XmakeConfig(mode,arch) | 13 + .../vsproj/templates/vcxproj/XmakePath(mode,arch) | 9 + xmake/plugins/project/vsxmake/vsxmake.lua | 158 +++++++++++ xmake/plugins/project/xmake.lua | 6 +- 49 files changed, 1283 insertions(+), 443 deletions(-) create mode 100644 xmake/plugins/project/vstudio/impl/vsinfo.lua create mode 100644 xmake/plugins/project/vstudio/vs.lua delete mode 100644 xmake/plugins/project/vstudio/vs2002.lua delete mode 100644 xmake/plugins/project/vstudio/vs2003.lua delete mode 100644 xmake/plugins/project/vstudio/vs2005.lua delete mode 100644 xmake/plugins/project/vstudio/vs2008.lua delete mode 100644 xmake/plugins/project/vstudio/vs2010.lua delete mode 100644 xmake/plugins/project/vstudio/vs2012.lua delete mode 100644 xmake/plugins/project/vstudio/vs2013.lua delete mode 100644 xmake/plugins/project/vstudio/vs2015.lua delete mode 100755 xmake/plugins/project/vstudio/vs2017.lua delete mode 100755 xmake/plugins/project/vstudio/vs2019.lua create mode 100644 xmake/plugins/project/vstudio/vsx.lua create mode 100644 xmake/plugins/project/vsxmake/getinfo.lua create mode 100644 xmake/plugins/project/vsxmake/render.lua create mode 100644 xmake/plugins/project/vsxmake/vsproj/Xmake.props create mode 100644 xmake/plugins/project/vsxmake/vsproj/Xmake.targets create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.props create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.targets create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/sln/ProjConfig(target,mode,arch) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/sln/Project(target) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/sln/SlnConfig(mode,arch) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.c(filec) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cu(filecu) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cxx(filecxx) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.obj(fileobj) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.rc(filerc) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Filter(dir) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.c(filec) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cu(filecu) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cxx(filecxx) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.obj(fileobj) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.rc(filerc) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectConfiguration(mode,arch) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch) create mode 100644 xmake/plugins/project/vsxmake/vsxmake.lua diff --git a/xmake/modules/detect/tools/find_nvcc.lua b/xmake/modules/detect/tools/find_nvcc.lua index 5b97f3dc9..ce98c9a60 100644 --- a/xmake/modules/detect/tools/find_nvcc.lua +++ b/xmake/modules/detect/tools/find_nvcc.lua @@ -51,7 +51,7 @@ function main(opt) -- not found? attempt to find program from cuda toolchains if not program then - local toolchains = find_cuda(config.get("cuda")) + local toolchains = find_cuda() if toolchains and toolchains.bindir then program = find_program(path.join(toolchains.bindir, "nvcc"), opt) end diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua index e56795086..d2ce39a10 100755 --- a/xmake/plugins/project/main.lua +++ b/xmake/plugins/project/main.lua @@ -24,16 +24,9 @@ import("core.base.task") import("core.platform.environment") import("make.makefile") import("cmake.cmakelists") -import("vstudio.vs2002") -import("vstudio.vs2003") -import("vstudio.vs2005") -import("vstudio.vs2008") -import("vstudio.vs2010") -import("vstudio.vs2012") -import("vstudio.vs2013") -import("vstudio.vs2015") -import("vstudio.vs2017") -import("vstudio.vs2019") +import("vstudio.vs") +import("vstudio.vsx") +import("vsxmake.vsxmake") import("clang.compile_flags") import("clang.compile_commands") @@ -45,16 +38,22 @@ function _make(kind) { makefile = makefile.make , cmakelists = cmakelists.make - , vs2002 = vs2002.make - , vs2003 = vs2003.make - , vs2005 = vs2005.make - , vs2008 = vs2008.make - , vs2010 = vs2010.make - , vs2012 = vs2012.make - , vs2013 = vs2013.make - , vs2015 = vs2015.make - , vs2017 = vs2017.make - , vs2019 = vs2019.make + , vs2002 = vs.make(2002) + , 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) + , vsxmake2010 = vsxmake.make(2010) + , vsxmake2012 = vsxmake.make(2012) + , vsxmake2013 = vsxmake.make(2013) + , vsxmake2015 = vsxmake.make(2015) + , vsxmake2017 = vsxmake.make(2017) + , vsxmake2019 = vsxmake.make(2019) , compile_flags = compile_flags.make , compile_commands = compile_commands.make } diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua index 61878af6a..91769a6bf 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua @@ -97,7 +97,7 @@ function _make_linkflags(target, vcprojdir) -- save flag table.insert(flags, flag) end - + -- make flags string flags = os.args(flags) @@ -114,20 +114,11 @@ function _make_header(vcprojfile, vsinfo, target) -- the target name local targetname = target:name() - -- the versions - local versions = - { - vs2002 = '7.0' - , vs2003 = '7.1' - , vs2005 = '8.0' - , vs2008 = '9.0' - } - -- make header - vcprojfile:print("") + vcprojfile:print("") vcprojfile:enter("") - vcxprojfile:enter("", assert(versions["vs" .. vsinfo.vstudio_version])) + vcxprojfile:enter("", assert(vsinfo.project_version)) end -- make tailer @@ -813,7 +783,4 @@ function make(vsinfo, target) -- exit solution file vcxprojfile:close() - - -- convert gb2312 to utf8 - io.writefile(vcxprojpath, io.readfile(vcxprojpath):convert("gb2312", "utf8")) end diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua index 0a850bda1..d241dd909 100755 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua @@ -161,7 +161,4 @@ function make(vsinfo, target) -- exit solution file filtersfile:close() - - -- convert gb2312 to utf8 - io.writefile(filterspath, io.readfile(filterspath):convert("gb2312", "utf8")) end diff --git a/xmake/plugins/project/vstudio/impl/vsinfo.lua b/xmake/plugins/project/vstudio/impl/vsinfo.lua new file mode 100644 index 000000000..3da30d398 --- /dev/null +++ b/xmake/plugins/project/vstudio/impl/vsinfo.lua @@ -0,0 +1,93 @@ +--!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 OpportunityLiu +-- @file vsinfo.lua +-- + +local vsinfo = +{ + [2002] = + { vstudio_version = "2002" + , solution_version = "7" + , project_version = "7.0" + } +, [2003] = + { vstudio_version = "2003" + , solution_version = "8" + , project_version = "7.1" + } +, [2005] = + { vstudio_version = "2005" + , solution_version = "9" + , project_version = "8.0" + } +, [2008] = + { vstudio_version = "2008" + , solution_version = "10" + , project_version = "9.0" + } +, [2010] = + { vstudio_version = "2010" + , project_version = "4" + , filters_version = "4.0" + , solution_version = "11" + , toolset_version = "v100" + } +, [2012] = + { vstudio_version = "2012" + , project_version = "4" + , filters_version = "4.0" + , solution_version = "12" + , toolset_version = "v110" + } +, [2013] = + { vstudio_version = "2013" + , project_version = "12" + , filters_version = "4.0" + , solution_version = "12" + , toolset_version = "v120" + } +, [2015] = + { vstudio_version = "2015" + , project_version = "14" + , filters_version = "4.0" + , solution_version = "12" + , toolset_version = "v140" + , sdk_version = "10.0.10240.0" + } +, [2017] = + { vstudio_version = "2017" + , project_version = "15" + , filters_version = "4.0" + , solution_version = "12" + , toolset_version = "v141" + , sdk_version = "10.0.14393.0" + } +, [2019] = + { vstudio_version = "2019" + , project_version = "16" + , filters_version = "4.0" + , solution_version = "12" + , toolset_version = "v142" + , sdk_version = "10.0.17763.0" + } +} + +function main(version) + assert(version) + return assert(vsinfo[version]); +end \ No newline at end of file diff --git a/xmake/plugins/project/vstudio/vs.lua b/xmake/plugins/project/vstudio/vs.lua new file mode 100644 index 000000000..a50180a23 --- /dev/null +++ b/xmake/plugins/project/vstudio/vs.lua @@ -0,0 +1,35 @@ +--!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 vs.lua +-- + +-- imports +import("impl.vs200x") +import("impl.vsinfo") + +-- make factory +function make(version) + + -- get vs version info + local info = vsinfo(version) + + -- make + return function(outputdir) + vs200x.make(outputdir, info) + end +end diff --git a/xmake/plugins/project/vstudio/vs2002.lua b/xmake/plugins/project/vstudio/vs2002.lua deleted file mode 100644 index 98b4125b2..000000000 --- a/xmake/plugins/project/vstudio/vs2002.lua +++ /dev/null @@ -1,36 +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 vs2003.lua --- - --- imports -import("impl.vs200x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2002" - , solution_version = "7" - } - - -- make project - vs200x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2003.lua b/xmake/plugins/project/vstudio/vs2003.lua deleted file mode 100644 index 6acc282f9..000000000 --- a/xmake/plugins/project/vstudio/vs2003.lua +++ /dev/null @@ -1,36 +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 vs2003.lua --- - --- imports -import("impl.vs200x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2003" - , solution_version = "8" - } - - -- make project - vs200x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2005.lua b/xmake/plugins/project/vstudio/vs2005.lua deleted file mode 100644 index d212a7264..000000000 --- a/xmake/plugins/project/vstudio/vs2005.lua +++ /dev/null @@ -1,36 +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 vs2005.lua --- - --- imports -import("impl.vs200x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2005" - , solution_version = "9" - } - - -- make project - vs200x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2008.lua b/xmake/plugins/project/vstudio/vs2008.lua deleted file mode 100644 index 226847af0..000000000 --- a/xmake/plugins/project/vstudio/vs2008.lua +++ /dev/null @@ -1,36 +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 vs2008.lua --- - --- imports -import("impl.vs200x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2008" - , solution_version = "10" - } - - -- make project - vs200x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2010.lua b/xmake/plugins/project/vstudio/vs2010.lua deleted file mode 100644 index ed399691d..000000000 --- a/xmake/plugins/project/vstudio/vs2010.lua +++ /dev/null @@ -1,37 +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 vs2010.lua --- - --- imports -import("impl.vs201x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2010" - , filters_version = "4.0" - , solution_version = "11" - } - - -- make project - vs201x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2012.lua b/xmake/plugins/project/vstudio/vs2012.lua deleted file mode 100644 index 4d420336d..000000000 --- a/xmake/plugins/project/vstudio/vs2012.lua +++ /dev/null @@ -1,37 +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 vs2012.lua --- - --- imports -import("impl.vs201x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2012" - , filters_version = "4.0" - , solution_version = "12" - } - - -- make project - vs201x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2013.lua b/xmake/plugins/project/vstudio/vs2013.lua deleted file mode 100644 index f29cd1b66..000000000 --- a/xmake/plugins/project/vstudio/vs2013.lua +++ /dev/null @@ -1,37 +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 vs2013.lua --- - --- imports -import("impl.vs201x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2013" - , filters_version = "4.0" - , solution_version = "12" - } - - -- make project - vs201x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2015.lua b/xmake/plugins/project/vstudio/vs2015.lua deleted file mode 100644 index de00e0346..000000000 --- a/xmake/plugins/project/vstudio/vs2015.lua +++ /dev/null @@ -1,37 +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 vs2015.lua --- - --- imports -import("impl.vs201x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2015" - , filters_version = "4.0" - , solution_version = "12" - } - - -- make project - vs201x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2017.lua b/xmake/plugins/project/vstudio/vs2017.lua deleted file mode 100755 index 6ffa58e0f..000000000 --- a/xmake/plugins/project/vstudio/vs2017.lua +++ /dev/null @@ -1,37 +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 vs2017.lua --- - --- imports -import("impl.vs201x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2017" - , filters_version = "4.0" - , solution_version = "12" - } - - -- make project - vs201x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vs2019.lua b/xmake/plugins/project/vstudio/vs2019.lua deleted file mode 100755 index e45ca355a..000000000 --- a/xmake/plugins/project/vstudio/vs2019.lua +++ /dev/null @@ -1,37 +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 vs2019.lua --- - --- imports -import("impl.vs201x") - --- make -function make(outputdir) - - -- init vstudio info - local vsinfo = - { - vstudio_version = "2019" - , filters_version = "4.0" - , solution_version = "12" - } - - -- make project - vs201x.make(outputdir, vsinfo) -end diff --git a/xmake/plugins/project/vstudio/vsx.lua b/xmake/plugins/project/vstudio/vsx.lua new file mode 100644 index 000000000..ff8b83281 --- /dev/null +++ b/xmake/plugins/project/vstudio/vsx.lua @@ -0,0 +1,35 @@ +--!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 new file mode 100644 index 000000000..4333e71ca --- /dev/null +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -0,0 +1,292 @@ +--!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 OpportunityLiu +-- @file getinfo.lua +-- + +-- imports +import("core.base.option") +import("core.base.semver") +import("core.project.config") +import("core.project.project") +import("core.platform.platform") +import("core.platform.environment") +import("core.tool.compiler") +import("core.tool.linker") +import("lib.detect.find_tool") +import("actions.config.configheader", {alias = "generate_configheader", rootdir = os.programdir()}) + +function _make_dirs(dir) + if dir == nil then + return "" + end + if type(dir) == "string" then + dir = path.translate(dir) + if dir == "" then + return "" + end + if path.is_absolute(dir) then + if dir:startswith(project.directory()) then + return path.join("$(XmakeProjectDir)", path.relative(dir, project.directory())) + end + return dir + end + return path.join("$(XmakeProjectDir)", 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()) +end + +function _get_values(target, name) + local values = table.wrap(target:get(name)) + 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 +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) } + + -- write only if not default + -- use target:get("xxx") rather than target:xxx() + + -- save target kind + targetinfo.kind = target:get("kind") + + -- save target file + targetinfo.basename = target:get("basename") + targetinfo.filename = target:get("filename") + + -- save dirs + targetinfo.targetdir = _make_dirs(target:get("targetdir")) + targetinfo.buildir = _make_dirs(config.get("buildir")) + targetinfo.rundir = _make_dirs(target:get("rundir")) + targetinfo.configdir = _make_dirs(os.getenv("XMAKE_CONFIGDIR")) + targetinfo.configfiledir = _make_dirs(target:get("configdir")) + targetinfo.includedirs = _make_dirs(_get_values(target, "includedirs")) + 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"), ";") + + -- save runenvs + local runenvs = {} + for k, v in pairs(target:get("runenvs")) do + local defs = {} + for _, d in ipairs(v) do + table.insert(defs, vformat(d)) + end + table.insert(runenvs, format("%s=%s", k, table.concat(defs, path.envsep()))) + end + targetinfo.runenvs = table.concat(runenvs, "\n") + + -- use mfc? save the mfc runtime kind + if target:rule("win.sdk.mfc.shared_app") or target:rule("win.sdk.mfc.shared") then + targetinfo.mfckind = "Dynamic" + elseif target:rule("win.sdk.mfc.static_app") or target:rule("win.sdk.mfc.static") then + targetinfo.mfckind = "Static" + end + + -- use cuda? save the cuda runtime version + if target:rule("cuda") then + local nvcc = find_tool("nvcc", { version = true }) + local ver = semver.new(nvcc.version) + targetinfo.cudaver = ver:major() .. "." .. ver:minor() + end + + -- ok + return targetinfo +end + +function _make_vsinfo_modes() + local vsinfo_modes = {} + local modes = option.get("modes") + if modes then + for _, mode in ipairs(modes:split(',')) do + table.insert(vsinfo_modes, mode:trim()) + end + else + vsinfo_modes = project.modes() + end + if not vsinfo_modes or #vsinfo_modes == 0 then + vsinfo_modes = { config.mode() } + end + return vsinfo_modes +end + +function _make_vsinfo_archs() + local vsinfo_archs = {} + local archs = option.get("archs") + if archs then + for _, arch in ipairs(archs:split(',')) do + table.insert(vsinfo_archs, arch:trim()) + end + else + vsinfo_archs = platform.archs() + end + if not vsinfo_archs or #vsinfo_archs == 0 then + vsinfo_archs = { config.arch() } + end + return vsinfo_archs +end + +-- make vstudio project +function main(outputdir, vsinfo) + + -- enter project directory + local oldir = os.cd(project.directory()) + + -- init solution directory + vsinfo.solution_dir = path.absolute(path.join(outputdir, "vsxmake" .. vsinfo.vstudio_version)) + vsinfo.programdir = xmake.programdir() + 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()) + -- write only if not default + if projectfile ~= "xmake.lua" then + vsinfo.projectfile = projectfile + vsinfo.slnfile = path.basename(projectfile) + end + + vsinfo.xmake_info = format("xmake version %s", xmake.version()) + vsinfo.solution_id = hash.uuid(project.directory() .. vsinfo.solution_dir) + vsinfo.vs_version = vsinfo.project_version .. ".0" + + -- init modes + vsinfo.modes = _make_vsinfo_modes() + -- init archs + vsinfo.archs = _make_vsinfo_archs() + + -- load targets + local targets = {} + vsinfo._sub2 = {} + for _, mode in ipairs(vsinfo.modes) do + vsinfo._sub2[mode] = {} + for _, arch in ipairs(vsinfo.archs) do + vsinfo._sub2[mode][arch] = { mode = mode, arch = arch } + + -- trace + print("checking for the %s.%s ...", mode, arch) + + -- reload config, project and platform + if mode ~= config.mode() or arch ~= config.arch() then + + -- modify config + config.set("as", nil, {force = true}) -- force to re-check as for ml/ml64 + config.set("mode", mode, {readonly = true, force = true}) + config.set("arch", arch, {readonly = true, force = true}) + + -- clear project to reload and recheck it + project.clear() + + -- check project options + project.check() + + -- reload platform + platform.load(config.plat()) + + -- re-generate configheader + generate_configheader() + end + + -- ensure to enter project directory + os.cd(project.directory()) + + -- enter environment (maybe check flags by calling tools) + environment.enter("toolchains") + + -- save targets + for targetname, target in pairs(project.targets()) do + if not target:isphony() then + + -- make target with the given mode and arch + targets[targetname] = targets[targetname] or {} + local _target = targets[targetname] + + -- init target info + _target.target = targetname + _target.vcxprojdir = path.join(vsinfo.solution_dir, targetname) + _target.target_id = hash.uuid(targetname) + _target.kind = target:targetkind() + _target.scriptdir = path.relative(target:scriptdir(), _target.vcxprojdir) + _target.projectdir = path.relative(project.directory(), _target.vcxprojdir) + local tgtdir = target:get("targetdir") + if tgtdir then _target.targetdir = path.relative(tgtdir, _target.vcxprojdir) end + _target._sub = _target._sub or {} + _target._sub[mode] = _target._sub[mode] or {} + _target._sub[mode][arch] = _make_targetinfo(mode, arch, target) + + -- save all sourcefiles and headerfiles + _target.sourcefiles = table.unique(table.join(_target.sourcefiles or {}, (target:sourcefiles()))) + _target.headerfiles = table.unique(table.join(_target.headerfiles or {}, (target:headerfiles()))) + + _target.deps = table.unique(table.join(_target.deps or {}, table.keys(target:deps()), nil)) + end + end + + -- leave environment + environment.leave("toolchains") + end + end + + -- leave project directory + os.cd(oldir) + for _,target in pairs(targets) do + target._sub2 = {} + local dirs = {} + for _,f in ipairs(target.sourcefiles) do + local dir = path.directory(f) + target._sub2[f] = + { + path = path.join("$(XmakeProjectDir)", f), + dir = dir + } + while dir ~= "." do + if not dirs[dir] then + dirs[dir] = + { + dir = dir, + dir_id = hash.uuid(dir) + } + end + dir = path.directory(dir) + end + end + target._sub3 = dirs + target.dirs = table.keys(dirs) + target._sub4 = {} + for _, v in ipairs(target.deps) do + target._sub4[v] = targets[v] + end + end + vsinfo.targets = table.keys(targets) + vsinfo._sub = targets + return vsinfo +end diff --git a/xmake/plugins/project/vsxmake/render.lua b/xmake/plugins/project/vsxmake/render.lua new file mode 100644 index 000000000..c672b30cd --- /dev/null +++ b/xmake/plugins/project/vsxmake/render.lua @@ -0,0 +1,74 @@ +--!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 OpportunityLiu +-- @file render.lua +-- + +function _fill(opt, parmas) + return function(match) + local imp = match:match("^Import%((.+)%)$") + if imp then + local func, overload = os.files(path.join(opt.templatedir, imp .. "(*)")) + assert(overload == 1) + func = func[1] + local args = path.filename(func):match("%((.+)%)$"):split(",") + return _render(func, opt, args) + end + return opt.paramsprovider(match, parmas) or "" + end +end + +function _expand(params) + local r = {""} + for _, v in ipairs(params) do + if type(v) == "string" then + for i, p in ipairs(r) do + r[i] = p .. ";" .. v + end + else + local newr = {} + for _, c in ipairs(v) do + local rcopy = {} + for i, p in ipairs(r) do + rcopy[i] = p .. ";" .. c + end + newr= table.join(newr, rcopy) + end + r = newr + end + end + for i, p in ipairs(r) do + r[i] = p:split(";") + end + return r +end + +function _render(templatepath, opt, args) + + local template = io.readfile(templatepath) + local params = _expand(opt.paramsprovider(args)) + local replaced = "" + for _, v in ipairs(params) do + replaced = replaced .. template:gsub(opt.pattern, _fill(opt, v)) + end + return replaced +end + +function main(templatepath, pattern, paramsprovider) + local opt = { pattern = pattern, paramsprovider = paramsprovider, templatedir = path.directory(templatepath) } + return _render(templatepath, opt, {}) +end \ No newline at end of file diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props new file mode 100644 index 000000000..02c36e28b --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -0,0 +1,139 @@ + + + + + $(Configuration) + release + + x86 + $(Platform) + auto + + + + + + + + + $(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('$(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);$(XmakeConfigFileDir);$(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 new file mode 100644 index 000000000..e87012146 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -0,0 +1,161 @@ + + + + + + + + + + <_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) + + <_XmakeConfigFlags>$(XmakeConfigFlags.Trim()) + <_XmakeConfigFlags>$(_XmakeConfigFlags) -p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)'))" + + <_XmakeBuildFlags>$(XmakeBuildFlags.Trim()) + <_XmakeBuildFlags Condition="$(XmakeWarning)">$(_XmakeBuildFlags) -w + + <_XmakeCleanFlags>$(XmakeCleanFlags.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) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user b/xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user new file mode 100644 index 000000000..399b00e30 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/#target#.vcxproj.user @@ -0,0 +1,10 @@ + + + + + $(XmakeRunDir) + $(XmakeRunEnvs) +$(LocalDebuggerEnvironment) + 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 new file mode 100644 index 000000000..6f47fe7a0 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.props @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + true + false + false + $(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 new file mode 100644 index 000000000..c63cbed32 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/Xmake.Custom.targets @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/sln/ProjConfig(target,mode,arch) b/xmake/plugins/project/vsxmake/vsproj/templates/sln/ProjConfig(target,mode,arch) new file mode 100644 index 000000000..427703018 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/sln/ProjConfig(target,mode,arch) @@ -0,0 +1,2 @@ + {#target_id#}.#mode#|#arch#.ActiveCfg = #mode#|#vsarch# + {#target_id#}.#mode#|#arch#.Build.0 = #mode#|#vsarch# diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/sln/Project(target) b/xmake/plugins/project/vsxmake/vsproj/templates/sln/Project(target) new file mode 100644 index 000000000..11e743c8a --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/sln/Project(target) @@ -0,0 +1,2 @@ +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "#target#", "#target#\#target#.vcxproj", "{#target_id#}" +EndProject diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/sln/SlnConfig(mode,arch) b/xmake/plugins/project/vsxmake/vsproj/templates/sln/SlnConfig(mode,arch) new file mode 100644 index 000000000..b1784b846 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/sln/SlnConfig(mode,arch) @@ -0,0 +1 @@ + #mode#|#arch# = #mode#|#arch# diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln b/xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln new file mode 100644 index 000000000..bc2872afe --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln @@ -0,0 +1,34 @@ +Microsoft Visual Studio Solution File, Format Version #solution_version#.0 +# Visual Studio Version #vs_version# +# +# #xmake_info# +# +# 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. +# +VisualStudioVersion = #vs_version# +MinimumVisualStudioVersion = 10.0 +#Import(Project)# +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Properties", "Properties", "{007754BD-BB1F-452F-A0D8-13EF216C5ED9}" + ProjectSection(SolutionItems) = preProject + Xmake.Custom.props = Xmake.Custom.props + Xmake.Custom.targets = Xmake.Custom.targets + #sln_projectfile# = #sln_projectfile# + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution +#Import(SlnConfig)# + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +#Import(ProjConfig)# + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {#solution_id#} + EndGlobalSection +EndGlobal 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 new file mode 100644 index 000000000..48428a006 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters @@ -0,0 +1,43 @@ + + + + + + {CC7C6180-942D-056E-3227-E6A2B3FB19CD} + +#Import(Filter)# + + + + Properties + + + Properties + + + Properties + + + +#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) new file mode 100644 index 000000000..d33f87944 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.c(filec) @@ -0,0 +1,3 @@ + + #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) new file mode 100644 index 000000000..643bb220f --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cu(filecu) @@ -0,0 +1,3 @@ + + #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) new file mode 100644 index 000000000..d33f87944 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.cxx(filecxx) @@ -0,0 +1,3 @@ + + #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) new file mode 100644 index 000000000..adacd3b67 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.obj(fileobj) @@ -0,0 +1,3 @@ + + #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) new file mode 100644 index 000000000..a46047781 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.rc(filerc) @@ -0,0 +1,3 @@ + + #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) new file mode 100644 index 000000000..6f97fa98d --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Filter(dir) @@ -0,0 +1,3 @@ + + {#dir_id#} + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj new file mode 100644 index 000000000..734c2a9cb --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj @@ -0,0 +1,56 @@ + + + + +#Import(ProjectConfiguration)# + + + {#target_id#} + $(XMAKE_PROGRAM_DIR) + #programdir# + release + Win32 + #scriptdir# + #projectdir# + #projectfile# + #target# + +#Import(XmakeConfig)# +#Import(XmakePath)# + + + + + + + +#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) new file mode 100644 index 000000000..36e16832a --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.c(filec) @@ -0,0 +1,3 @@ + + 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) new file mode 100644 index 000000000..7b3f0a6fe --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cu(filecu) @@ -0,0 +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) new file mode 100644 index 000000000..076adfd5a --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.cxx(filecxx) @@ -0,0 +1,3 @@ + + 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) new file mode 100644 index 000000000..1e7cd6f45 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.obj(fileobj) @@ -0,0 +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) new file mode 100644 index 000000000..25d1c58ab --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.rc(filerc) @@ -0,0 +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) new file mode 100644 index 000000000..f2169767f --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectConfiguration(mode,arch) @@ -0,0 +1,4 @@ + + #mode# + #vsarch# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) new file mode 100644 index 000000000..7804e4cba --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/ProjectRef(dep) @@ -0,0 +1,3 @@ + + {#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) new file mode 100644 index 000000000..da73700f4 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) @@ -0,0 +1,13 @@ + + #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) new file mode 100644 index 000000000..2c8adc429 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch) @@ -0,0 +1,9 @@ + + #buildir# + #configdir# + #configfiledir# + #targetdir# + #includedirs# + #linkdirs# + #rundir# + diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua new file mode 100644 index 000000000..19ec2bfa6 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -0,0 +1,158 @@ +--!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 OpportunityLiu +-- @file vsxmake.lua +-- + +-- imports +import("core.base.hashset") +import("vstudio.impl.vsinfo", { rootdir = path.directory(os.scriptdir()) }) +import("render") +import("getinfo") + +local template_root = path.join(os.scriptdir(), "vsproj", "templates") +local template_sln = path.join(template_root, "sln", "vsxmake.sln") +local template_vcx = path.join(template_root, "vcxproj", "#target#.vcxproj") + +local template_fil = path.join(template_root, "vcxproj.filters", "#target#.vcxproj.filters") +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") + +function _filter_files(files, exts) + local extset = hashset.from(exts) + local f = {} + for _, file in ipairs(files) do + local ext = path.extension(file) + if extset:has(ext) then + table.insert(f, file) + end + end + return f +end + +function _buildparams(info, target, default) + + local function getprop(match, opt) + local i = info + local r = info[match] + if target then + opt = table.join(target, opt) + end + for _,k in ipairs(opt) do + local v = (i._sub or {})[k] or (i._sub2 or {})[k] or (i._sub3 or {})[k] or (i._sub4 or {})[k]or i[k] + if v == nil then + raise("key '" .. k .. "' not found") + end + i = v + r = i[match] or r + end + + return r or default + end + + local function listconfig(args) + for _, k in ipairs(args) do + args[k] = true + end + local r = {} + if args.target then + table.insert(r, info.targets) + end + if args.mode then + table.insert(r, info.modes) + end + if args.arch then + table.insert(r, info.archs) + end + if args.dir then + table.insert(r, info._sub[target].dirs) + end + if args.dep then + table.insert(r, info._sub[target].deps) + end + if args.filec then + local files = info._sub[target].sourcefiles + table.insert(r, _filter_files(files, {".c"})) + elseif args.filecxx then + local files = info._sub[target].sourcefiles + table.insert(r, _filter_files(files, {".cpp", ".cc", ".cxx"})) + elseif args.filecu then + local files = info._sub[target].sourcefiles + table.insert(r, _filter_files(files, {".cu"})) + elseif args.fileobj then + local files = info._sub[target].sourcefiles + table.insert(r, _filter_files(files, {".obj", ".o"})) + elseif args.filerc then + local files = info._sub[target].sourcefiles + table.insert(r, _filter_files(files, {".rc"})) + end + return r + end + + return function(match, opt) + if type(match) == "table" then + return listconfig(match) + end + return getprop(match, opt) + end +end + +function _trycp(file, target, targetname) + targetname = targetname or path.filename(file) + local targetfile = path.join(target, targetname) + if os.isfile(targetfile) then + dprint("skipped file %s", path.relative(targetfile)) + return + end + os.cp(file,targetfile) +end + +-- make +function make(version) + + 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") + io.writefile(sln, render(template_sln, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidersln)) + + -- add solution custom file + _trycp(template_props, info.solution_dir) + _trycp(template_targets, info.solution_dir) + + for _, target in ipairs(info.targets) do + local paramsprovidertarget = _buildparams(info, target, "") + local proj_dir = info._sub[target].vcxprojdir + + -- write project file + local proj = path.join(proj_dir, target .. ".vcxproj") + io.writefile(proj, render(template_vcx, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidertarget)) + + local projfil = path.join(proj_dir, target .. ".vcxproj.filters") + io.writefile(projfil, render(template_fil, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidertarget)) + + -- add project custom file + _trycp(template_props, proj_dir) + _trycp(template_targets, proj_dir) + -- add project user file + _trycp(template_usr, proj_dir, target .. ".vcxproj.user") + end + end +end diff --git a/xmake/plugins/project/xmake.lua b/xmake/plugins/project/xmake.lua index 717c41b0d..023d3d87d 100644 --- a/xmake/plugins/project/xmake.lua +++ b/xmake/plugins/project/xmake.lua @@ -42,8 +42,10 @@ task("project") , " - makefile" , " - compile_flags" , " - compile_commands (clang compilation database with json format)" - , " - vs2002, vs2003, vs2005, vs2008, vs2010, vs2012, vs2013, vs2015, vs2017" } - , {'m', "modes", "kv", nil, "Set the project modes." + , " - vs2002, vs2003, vs2005, vs2008" + , " - vs2010, vs2012, vs2013, vs2015, vs2017, vs2019" + , " - vsxmake2010 ~ vsmake2019" } + , {'m', "modes", "kv", nil, "Set the project modes." , " .e.g " , " - xmake project -k makefile" , " - xmake project -k compile_commands" -- cgit v1.3.1 From ef8f86298be7e2ed2dae96acef7077e252dc8ed3 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sat, 13 Jul 2019 22:35:54 +0800 Subject: improve dump --- xmake/core/base/colors.lua | 8 +++--- xmake/core/base/dump.lua | 57 ++++++++++++++++++++++++------------------ xmake/themes/dark/xmake.lua | 2 ++ xmake/themes/default/xmake.lua | 2 ++ xmake/themes/emoji/xmake.lua | 2 ++ xmake/themes/plain/xmake.lua | 2 ++ 6 files changed, 45 insertions(+), 28 deletions(-) diff --git a/xmake/core/base/colors.lua b/xmake/core/base/colors.lua index d44670fab..5df37b54a 100644 --- a/xmake/core/base/colors.lua +++ b/xmake/core/base/colors.lua @@ -260,6 +260,7 @@ end -- @param str the string with colors -- @param opt options -- patch_reset: wrap str with `"${reset}"`? +-- ignore_unknown: ignore unknown codes like `"${unknown_code}"`? -- -- 8 colors: -- @@ -340,12 +341,12 @@ function colors.translate(str, opt) for _, theme_block_sub in ipairs(theme_block:split("%s")) do table.insert(blocks, theme_block_sub) end - else + else table.insert(blocks, block) end elseif block:startswith("color.") or block:startswith("text.") then local default_theme = {["color.error"] = "red", ["color.warning"] = "yellow", ["text.error"] = "error", ["text.warning"] = "warning"} - local theme_block = default_theme[block] + local theme_block = default_theme[block] if theme_block then table.insert(blocks, theme_block) else @@ -384,7 +385,8 @@ function colors.translate(str, opt) local emoji_code = emoji.translate(block) if emoji_code then table.insert(text_buffer, emoji_code) - else + elseif not opt.ignore_unknown then + -- unknown code, regard as plain text table.insert(text_buffer, block) end end diff --git a/xmake/core/base/dump.lua b/xmake/core/base/dump.lua index 34e54508a..7a9b5ee56 100644 --- a/xmake/core/base/dump.lua +++ b/xmake/core/base/dump.lua @@ -32,30 +32,34 @@ function dump._format(fmtkey, fmtdefault, ...) return string.format(fmt, ...) end +function dump._translate(str) + return colors.translate(str, { patch_reset = false, ignore_unknown = true }) +end + -- print string function dump._print_string(str, as_key) local quote = (not as_key) or (not str:match("^[a-zA-Z_][a-zA-Z0-9_]*$")) if quote then - io.write(colors.translate("${reset}${color.dump.string_quote}\"${reset}${color.dump.string}", { patch_reset = false })) + io.write(dump._translate("${reset}${color.dump.string_quote}\"${reset}${color.dump.string}")) else - io.write(colors.translate("${reset}${color.dump.string}", { patch_reset = false })) + io.write(dump._translate("${reset}${color.dump.string}")) end io.write(str) if quote then - io.write(colors.translate("${reset}${color.dump.string_quote}\"${reset}", { patch_reset = false })) + io.write(dump._translate("${reset}${color.dump.string_quote}\"${reset}")) else - io.write(colors.translate("${reset}", { patch_reset = false })) + io.write(dump._translate("${reset}")) end end -- print keyword function dump._print_keyword(keyword) - io.write(colors.translate("${color.dump.keyword}" .. tostring(keyword))) + io.write(dump._translate("${reset}${color.dump.keyword}"), tostring(keyword), dump._translate("${reset}")) end -- print number function dump._print_number(num) - io.write(colors.translate("${color.dump.number}" .. tostring(num))) + io.write(dump._translate("${reset}${color.dump.number}"), tostring(num), dump._translate("${reset}")) end -- print function @@ -68,14 +72,18 @@ function dump._print_function(func, as_key) if funcinfo.linedefined >= 0 then srcinfo = srcinfo .. ":" .. funcinfo.linedefined end - io.write(colors.translate("${color.dump.function}function ${bright}" .. (funcinfo.name or "") .. "${reset}${dim}" .. srcinfo)) + local funcname = funcinfo.name and (funcinfo.name .. " ") or "" + io.write(dump._translate("${reset}${color.dump.function}function ${bright}"), funcname, dump._translate("${reset}${dim}"), srcinfo) end -- print value with default format function dump._print_default(value) - io.write(colors.translate("${color.dump.default}", { patch_reset = false })) - io.write(dump._format("text.dump.default_format", "%s", value)) - io.write(colors.translate("${reset}", { patch_reset = false })) + io.write(dump._translate("${color.dump.default}"), dump._format("text.dump.default_format", "%s", value), dump._translate("${reset}")) +end + +-- print udata value with scalar format +function dump._print_udata_scalar(value) + io.write(dump._translate("${color.dump.udata}"), dump._format("text.dump.udata_format", "%s", value), dump._translate("${reset}")) end -- print scalar value @@ -90,6 +98,8 @@ function dump._print_scalar(value, as_key) dump._print_string(value, as_key) elseif type(value) == "function" then dump._print_function(value, as_key) + elseif type(value) == "userdata" then + dump._print_udata_scalar(value) else dump._print_default(value) end @@ -97,15 +107,12 @@ end -- print anchor function dump._print_anchor(value) - io.write(colors.translate("${color.dump.anchor}", { patch_reset = false })) - io.write(dump._format("text.dump.anchor", "&%s", value)) - io.write(colors.translate("${reset}", { patch_reset = false })) + io.write(dump._translate("${color.dump.anchor}"), dump._format("text.dump.anchor", "&%s", value), dump._translate("${reset}")) end + -- print reference function dump._print_reference(value) - io.write(colors.translate("${color.dump.reference}", { patch_reset = false })) - io.write(dump._format("text.dump.reference", "*%s", value)) - io.write(colors.translate("${reset}", { patch_reset = false })) + io.write(dump._translate("${color.dump.reference}"), dump._format("text.dump.reference", "*%s", value), dump._translate("${reset}")) end function dump._print_table_anchor(value, printed_set) @@ -136,7 +143,7 @@ function dump._print_metatable(value, metatable, inner_indent, printed_set, prin io.write("\n", inner_indent) local funcname = k:sub(3) dump._print_keyword(funcname) - io.write(colors.translate("${dim} = ")) + io.write(dump._translate("${reset} ${dim}=${reset} ")) if funcname == "tostring" or funcname == "len" then local ok, result = pcall(v, value, value) if ok then @@ -173,7 +180,7 @@ function dump._print_metatable(value, metatable, inner_indent, printed_set, prin dump._print_keyword("(") dump._print_scalar(k, true) dump._print_keyword(")") - io.write(colors.translate("${dim} = ")) + io.write(dump._translate("${reset} ${dim}=${reset} ")) if v and printed_set[v] then dump._print_reference(printed_set[v]) else @@ -193,16 +200,16 @@ function dump._print_udata(value, first_indent, remain_indent) local inner_indent = remain_indent .. " " -- print open brackets - io.write(colors.translate("${dim}[")) + io.write(dump._translate("${reset}${color.dump.udata}[${reset}")) -- print metatable local no_value = not dump._print_metatable(value, metatable, inner_indent, { len = 0 }, false) -- print close brackets if no_value then - io.write(colors.translate(" ${dim}]")) + io.write(dump._translate(" ${color.dump.udata}]${reset}")) else - io.write("\b \n" .. remain_indent .. colors.translate("${dim}]")) + io.write("\b \n", remain_indent, dump._translate("${reset}${color.dump.udata}]${reset}")) end end @@ -224,7 +231,7 @@ function dump._print_table(value, first_indent, remain_indent, printed_set) local first_value = true -- print open brackets - io.write(colors.translate("${dim}{")) + io.write(dump._translate("${reset}${dim}{${reset}")) local function print_newline() if first_value then @@ -262,7 +269,7 @@ function dump._print_table(value, first_indent, remain_indent, printed_set) if not is_arr or type(k) ~= "number" then print_newline() dump._print_scalar(k, true) - io.write(colors.translate("${dim} = ")) + io.write(dump._translate("${reset} ${dim}=${reset} ")) if type(v) == "table" then if printed_set[v] then dump._print_reference(printed_set[v]) @@ -278,9 +285,9 @@ function dump._print_table(value, first_indent, remain_indent, printed_set) -- print close brackets if first_value then - io.write(colors.translate(" ${dim}}")) + io.write(dump._translate(" ${dim}}${reset}")) else - io.write("\b \n" .. remain_indent .. colors.translate("${dim}}")) + io.write("\b \n", remain_indent, dump._translate("${reset}${dim}}${reset}")) end end diff --git a/xmake/themes/dark/xmake.lua b/xmake/themes/dark/xmake.lua index ad1152e97..c0eb30c34 100644 --- a/xmake/themes/dark/xmake.lua +++ b/xmake/themes/dark/xmake.lua @@ -53,11 +53,13 @@ theme("dark") -- color dump set_text("dump.default_format", "<%s>") + set_text("dump.udata_format", "[%s]") set_text("dump.anchor", "&%s") set_text("dump.reference", "*%s") set_color("dump.anchor", "yellow") set_color("dump.reference", "yellow") set_color("dump.default", "bright") + set_color("dump.udata", "yellow") set_color("dump.string", "magenta bright") set_color("dump.string_quote", "magenta") set_color("dump.keyword", "blue") diff --git a/xmake/themes/default/xmake.lua b/xmake/themes/default/xmake.lua index f099196db..294d0e543 100644 --- a/xmake/themes/default/xmake.lua +++ b/xmake/themes/default/xmake.lua @@ -53,11 +53,13 @@ theme("default") -- color dump set_text("dump.default_format", "<%s>") + set_text("dump.udata_format", "[%s]") set_text("dump.anchor", "&%s") set_text("dump.reference", "*%s") set_color("dump.anchor", "yellow") set_color("dump.reference", "yellow") set_color("dump.default", "bright") + set_color("dump.udata", "yellow") set_color("dump.string", "magenta bright") set_color("dump.string_quote", "magenta") set_color("dump.keyword", "blue") diff --git a/xmake/themes/emoji/xmake.lua b/xmake/themes/emoji/xmake.lua index 663271719..8ba303896 100644 --- a/xmake/themes/emoji/xmake.lua +++ b/xmake/themes/emoji/xmake.lua @@ -53,11 +53,13 @@ theme("emoji") -- color dump set_text("dump.default_format", "<%s>") + set_text("dump.udata_format", "[%s]") set_text("dump.anchor", "⚓ %s") set_text("dump.reference", "⛵ %s") set_color("dump.anchor", "yellow") set_color("dump.reference", "yellow") set_color("dump.default", "bright") + set_color("dump.udata", "yellow") set_color("dump.string", "magenta bright") set_color("dump.string_quote", "magenta") set_color("dump.keyword", "blue") diff --git a/xmake/themes/plain/xmake.lua b/xmake/themes/plain/xmake.lua index 69760dca2..54e731c06 100644 --- a/xmake/themes/plain/xmake.lua +++ b/xmake/themes/plain/xmake.lua @@ -53,11 +53,13 @@ theme("plain") -- color dump set_text("dump.default_format", "<%s>") + set_text("dump.udata_format", "[%s]") set_text("dump.anchor", "&%s") set_text("dump.reference", "*%s") set_color("dump.anchor", "") set_color("dump.reference", "") set_color("dump.default", "") + set_color("dump.udata", "") set_color("dump.string", "") set_color("dump.string_quote", "") set_color("dump.keyword", "") -- cgit v1.3.1 From 6f49281f6397fbb876ea9f88a72fe47da36af89d Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sat, 13 Jul 2019 22:43:38 +0800 Subject: fix table dump style --- xmake/core/base/dump.lua | 15 +++++++++++---- xmake/themes/dark/xmake.lua | 2 ++ xmake/themes/default/xmake.lua | 2 ++ xmake/themes/emoji/xmake.lua | 2 ++ xmake/themes/plain/xmake.lua | 2 ++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/xmake/core/base/dump.lua b/xmake/core/base/dump.lua index 7a9b5ee56..42f09e2c6 100644 --- a/xmake/core/base/dump.lua +++ b/xmake/core/base/dump.lua @@ -86,6 +86,11 @@ function dump._print_udata_scalar(value) io.write(dump._translate("${color.dump.udata}"), dump._format("text.dump.udata_format", "%s", value), dump._translate("${reset}")) end +-- print table value with scalar format +function dump._print_table_scalar(value) + io.write(dump._translate("${color.dump.table}"), dump._format("text.dump.table_format", "%s", value), dump._translate("${reset}")) +end + -- print scalar value function dump._print_scalar(value, as_key) if type(value) == "nil" then @@ -100,6 +105,8 @@ function dump._print_scalar(value, as_key) dump._print_function(value, as_key) elseif type(value) == "userdata" then dump._print_udata_scalar(value) + elseif type(value) == "table" then + dump._print_table_scalar(value) else dump._print_default(value) end @@ -223,7 +230,7 @@ function dump._print_table(value, first_indent, remain_indent, printed_set) if not first_level and tostringmethod then local ok, strrep = pcall(tostringmethod, value, value) if ok then - return dump._print_default(strrep) + return dump._print_table_scalar(strrep) end end printed_set = printed_set or { len = 0 } @@ -231,7 +238,7 @@ function dump._print_table(value, first_indent, remain_indent, printed_set) local first_value = true -- print open brackets - io.write(dump._translate("${reset}${dim}{${reset}")) + io.write(dump._translate("${reset}${color.dump.table}{${reset}")) local function print_newline() if first_value then @@ -285,9 +292,9 @@ function dump._print_table(value, first_indent, remain_indent, printed_set) -- print close brackets if first_value then - io.write(dump._translate(" ${dim}}${reset}")) + io.write(dump._translate(" ${color.dump.table}}${reset}")) else - io.write("\b \n", remain_indent, dump._translate("${reset}${dim}}${reset}")) + io.write("\b \n", remain_indent, dump._translate("${reset}${color.dump.table}}${reset}")) end end diff --git a/xmake/themes/dark/xmake.lua b/xmake/themes/dark/xmake.lua index c0eb30c34..cb9c6a093 100644 --- a/xmake/themes/dark/xmake.lua +++ b/xmake/themes/dark/xmake.lua @@ -54,12 +54,14 @@ theme("dark") -- color dump set_text("dump.default_format", "<%s>") set_text("dump.udata_format", "[%s]") + set_text("dump.table_format", "{%s}") set_text("dump.anchor", "&%s") set_text("dump.reference", "*%s") set_color("dump.anchor", "yellow") set_color("dump.reference", "yellow") set_color("dump.default", "bright") set_color("dump.udata", "yellow") + set_color("dump.table", "bright") set_color("dump.string", "magenta bright") set_color("dump.string_quote", "magenta") set_color("dump.keyword", "blue") diff --git a/xmake/themes/default/xmake.lua b/xmake/themes/default/xmake.lua index 294d0e543..568e351e2 100644 --- a/xmake/themes/default/xmake.lua +++ b/xmake/themes/default/xmake.lua @@ -54,12 +54,14 @@ theme("default") -- color dump set_text("dump.default_format", "<%s>") set_text("dump.udata_format", "[%s]") + set_text("dump.table_format", "{%s}") set_text("dump.anchor", "&%s") set_text("dump.reference", "*%s") set_color("dump.anchor", "yellow") set_color("dump.reference", "yellow") set_color("dump.default", "bright") set_color("dump.udata", "yellow") + set_color("dump.table", "bright") set_color("dump.string", "magenta bright") set_color("dump.string_quote", "magenta") set_color("dump.keyword", "blue") diff --git a/xmake/themes/emoji/xmake.lua b/xmake/themes/emoji/xmake.lua index 8ba303896..39a1bee8f 100644 --- a/xmake/themes/emoji/xmake.lua +++ b/xmake/themes/emoji/xmake.lua @@ -54,12 +54,14 @@ theme("emoji") -- color dump set_text("dump.default_format", "<%s>") set_text("dump.udata_format", "[%s]") + set_text("dump.table_format", "{%s}") set_text("dump.anchor", "⚓ %s") set_text("dump.reference", "⛵ %s") set_color("dump.anchor", "yellow") set_color("dump.reference", "yellow") set_color("dump.default", "bright") set_color("dump.udata", "yellow") + set_color("dump.table", "bright") set_color("dump.string", "magenta bright") set_color("dump.string_quote", "magenta") set_color("dump.keyword", "blue") diff --git a/xmake/themes/plain/xmake.lua b/xmake/themes/plain/xmake.lua index 54e731c06..057d2ddf0 100644 --- a/xmake/themes/plain/xmake.lua +++ b/xmake/themes/plain/xmake.lua @@ -54,12 +54,14 @@ theme("plain") -- color dump set_text("dump.default_format", "<%s>") set_text("dump.udata_format", "[%s]") + set_text("dump.table_format", "{%s}") set_text("dump.anchor", "&%s") set_text("dump.reference", "*%s") set_color("dump.anchor", "") set_color("dump.reference", "") set_color("dump.default", "") set_color("dump.udata", "") + set_color("dump.table", "") set_color("dump.string", "") set_color("dump.string_quote", "") set_color("dump.keyword", "") -- cgit v1.3.1 From d5489da5f95a1ce5a39c3a40d5ef77729cbb6e1f Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sat, 13 Jul 2019 22:50:28 +0800 Subject: use emoji name --- xmake/core/base/dump.lua | 7 +++++-- xmake/themes/emoji/xmake.lua | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/xmake/core/base/dump.lua b/xmake/core/base/dump.lua index 42f09e2c6..4cf76f115 100644 --- a/xmake/core/base/dump.lua +++ b/xmake/core/base/dump.lua @@ -28,8 +28,11 @@ local table = require("base/table") -- format string with theme colors function dump._format(fmtkey, fmtdefault, ...) local theme = colors.theme() - local fmt = theme and theme:get(fmtkey) or fmtdefault - return string.format(fmt, ...) + if theme then + return colors.translate(string.format(theme:get(fmtkey), ...)) + else + return string.format(fmtdefault, ...) + end end function dump._translate(str) diff --git a/xmake/themes/emoji/xmake.lua b/xmake/themes/emoji/xmake.lua index 39a1bee8f..da189e23f 100644 --- a/xmake/themes/emoji/xmake.lua +++ b/xmake/themes/emoji/xmake.lua @@ -55,8 +55,8 @@ theme("emoji") set_text("dump.default_format", "<%s>") set_text("dump.udata_format", "[%s]") set_text("dump.table_format", "{%s}") - set_text("dump.anchor", "⚓ %s") - set_text("dump.reference", "⛵ %s") + set_text("dump.anchor", "${anchor} %s") + set_text("dump.reference", "${sailboat} %s") set_color("dump.anchor", "yellow") set_color("dump.reference", "yellow") set_color("dump.default", "bright") -- cgit v1.3.1 From 612280f59e52f7108e87fa782ce8939fb4e80ec6 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sun, 14 Jul 2019 00:08:05 +0800 Subject: add comments --- xmake/core/base/dump.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xmake/core/base/dump.lua b/xmake/core/base/dump.lua index 4cf76f115..1fe5f1f20 100644 --- a/xmake/core/base/dump.lua +++ b/xmake/core/base/dump.lua @@ -35,6 +35,7 @@ function dump._format(fmtkey, fmtdefault, ...) end end +-- translate string with theme formats function dump._translate(str) return colors.translate(str, { patch_reset = false, ignore_unknown = true }) end @@ -125,6 +126,7 @@ function dump._print_reference(value) io.write(dump._translate("${color.dump.reference}"), dump._format("text.dump.reference", "*%s", value), dump._translate("${reset}")) end +-- print anchor and store to printed_set function dump._print_table_anchor(value, printed_set) printed_set.len = printed_set.len + 1 io.write(" ") @@ -132,6 +134,7 @@ function dump._print_table_anchor(value, printed_set) printed_set[value] = printed_set.len end +-- print metatable of value function dump._print_metatable(value, metatable, inner_indent, printed_set, print_archor) if not metatable then return false @@ -252,6 +255,7 @@ function dump._print_table(value, first_indent, remain_indent, printed_set) end if first_level then + -- print metatable first_value = not dump._print_metatable(value, metatable, inner_indent, printed_set, true) end -- cgit v1.3.1 From af141620835a0e519c30916d45dade25e365a0e8 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sun, 14 Jul 2019 18:23:17 +0800 Subject: use lzma and unicode --- scripts/installer.nsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/installer.nsi b/scripts/installer.nsi index e05a33dd4..253df3436 100644 --- a/scripts/installer.nsi +++ b/scripts/installer.nsi @@ -44,6 +44,12 @@ Name "XMake - v${VERSION}" ; The file to write OutFile "xmake.exe" +; Use unicode +Unicode true + +; Use best compressor +SetCompressor /FINAL /SOLID lzma + ; The default installation directory !ifdef x64 !define PROGRAMFILES $PROGRAMFILES64 -- cgit v1.3.1 From 8f82eac730b6ce94706c067f33bc1b25068b4ae6 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 15 Jul 2019 09:47:32 +0800 Subject: add headerfiles --- scripts/installer.nsi | 690 ++++++++++----------- xmake/plugins/project/vsxmake/getinfo.lua | 2 +- .../vcxproj.filters/#target#.vcxproj.filters | 3 + .../vsproj/templates/vcxproj.filters/Include(inc) | 3 + .../vsproj/templates/vcxproj/#target#.vcxproj | 3 + .../vsxmake/vsproj/templates/vcxproj/Include(inc) | 1 + xmake/plugins/project/vsxmake/vsxmake.lua | 2 + 7 files changed, 358 insertions(+), 346 deletions(-) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) create mode 100644 xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) diff --git a/scripts/installer.nsi b/scripts/installer.nsi index 253df3436..488292aeb 100644 --- a/scripts/installer.nsi +++ b/scripts/installer.nsi @@ -1,345 +1,345 @@ -; xmake.nsi -; -; This script is perhaps one of the simplest NSIs you can make. All of the -; optional settings are left to their default settings. The installer simply -; prompts the user asking them where to install, and drops a copy of xmake.nsi -; there. - -;-------------------------------- -; includes -!include "MUI2.nsh" -!include "WordFunc.nsh" -!include "WinMessages.nsh" -!include FileFunc.nsh -!include UAC.nsh - -; xmake version Information -!ifndef MAJOR - !define MAJOR 2 -!endif -!ifndef MINOR - !define MINOR 2 -!endif -!ifndef ALTER - !define ALTER 7 -!endif -!ifndef BUILD - !define BUILD 201906200000 -!endif - -!define VERSION ${MAJOR}.${MINOR}.${ALTER} -!define VERSION_FULL ${VERSION}+${BUILD} - -!ifdef x64 - !define ARCH x64 -!else - !define ARCH x86 -!endif - -;-------------------------------- - -; The name of the installer -Name "XMake - v${VERSION}" - -; The file to write -OutFile "xmake.exe" - -; Use unicode -Unicode true - -; Use best compressor -SetCompressor /FINAL /SOLID lzma - -; The default installation directory -!ifdef x64 - !define PROGRAMFILES $PROGRAMFILES64 - !define HKLM HKLM64 - !define HKCU HKCU64 -!else - !define PROGRAMFILES $PROGRAMFILES - !define HKLM HKLM - !define HKCU HKCU -!endif - -; Request application privileges for Windows Vista -RequestExecutionLevel user - -; Set DPI Aware -ManifestDPIAware true - -;-------------------------------- -; Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -; Icon -!define MUI_ICON "..\core\src\demo\xmake.ico" - -;-------------------------------- -; UAC helper - -!macro Init thing - uac_tryagain: - !insertmacro UAC_RunElevated - ${Switch} $0 - ${Case} 0 - ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done - ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on - ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user - MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0 - ${EndIf} - ;fall-through and die - ${Case} 1223 - MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!" - Quit - ${Case} 1062 - MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!" - Quit - ${Default} - MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, error $0" - Quit - ${EndSwitch} - - SetShellVarContext all -!macroend - -;-------------------------------- -; Install Pages - -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "..\LICENSE.md" -!insertmacro MUI_PAGE_COMPONENTS -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES -!define MUI_FINISHPAGE_LINK "Donate $$5" -!define MUI_FINISHPAGE_LINK_LOCATION "https://xmake.io/pages/donation.html#donate" -!insertmacro MUI_PAGE_FINISH - -;-------------------------------- -; Uninstall Pages - -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES -!insertmacro MUI_UNPAGE_FINISH - -;-------------------------------- -; Languages - -!insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -; Version Information - - -VIProductVersion ${VERSION}.0 -VIFileVersion ${VERSION}.0 -VIAddVersionKey /LANG=0 ProductName XMake -VIAddVersionKey /LANG=0 Comments "A cross-platform build utility based on Lua$\nwebsite: https://xmake.io" -VIAddVersionKey /LANG=0 CompanyName "The TBOOX Open Source Group" -VIAddVersionKey /LANG=0 LegalCopyright "Copyright (C) 2015-2019 Ruki Wang, tboox.org, xmake.io$\nCopyright (C) 2005-2015 Mike Pall, luajit.org" -VIAddVersionKey /LANG=0 FileDescription "XMake Installer - v${VERSION}" -VIAddVersionKey /LANG=0 OriginalFilename "xmake-${ARCH}.exe" -VIAddVersionKey /LANG=0 FileVersion ${VERSION_FULL} -VIAddVersionKey /LANG=0 ProductVersion ${VERSION_FULL} - - -;-------------------------------- -; Reg pathes - -!define RegUninstall "Software\Microsoft\Windows\CurrentVersion\Uninstall\XMake" - -;-------------------------------- - -Var NOADMIN - -Function TrimQuote - Exch $R1 ; Original string - Push $R2 - -Loop: - StrCpy $R2 "$R1" 1 - StrCmp "$R2" "'" TrimLeft - StrCmp "$R2" "$\"" TrimLeft - StrCmp "$R2" "$\r" TrimLeft - StrCmp "$R2" "$\n" TrimLeft - StrCmp "$R2" "$\t" TrimLeft - StrCmp "$R2" " " TrimLeft - GoTo Loop2 -TrimLeft: - StrCpy $R1 "$R1" "" 1 - Goto Loop - -Loop2: - StrCpy $R2 "$R1" 1 -1 - StrCmp "$R2" "'" TrimRight - StrCmp "$R2" "$\"" TrimRight - StrCmp "$R2" "$\r" TrimRight - StrCmp "$R2" "$\n" TrimRight - StrCmp "$R2" "$\t" TrimRight - StrCmp "$R2" " " TrimRight - GoTo Done -TrimRight: - StrCpy $R1 "$R1" -1 - Goto Loop2 - -Done: - Pop $R2 - Exch $R1 -FunctionEnd - -; Installer -Function .onInit - ${GetOptions} $CMDLINE "/NOADMIN" $NOADMIN - ${If} ${Errors} - !insertmacro Init "installer" - StrCpy $NOADMIN "false" - ${Else} - StrCpy $NOADMIN "true" - ${EndIf} - - ; load from reg - ${If} $InstDir == "" - ${If} $NOADMIN == "false" - ReadRegStr $R0 ${HKLM} ${RegUninstall} "InstallLocation" - ${Else} - ReadRegStr $R0 ${HKCU} ${RegUninstall} "InstallLocation" - ${EndIf} - ${If} $R0 != "" - Push $R0 - Call TrimQuote - Pop $R0 - StrCpy $InstDir $R0 - ${EndIf} - ${EndIf} - ; use default - ${If} $InstDir == "" - StrCpy $InstDir ${PROGRAMFILES}\xmake - ${EndIf} - -FunctionEnd - -Section "XMake (required)" InstallExeutable - - SectionIn RO - - ; Set output path to the installation directory. - SetOutPath $InstDir - - ; Remove previous directories used - RMDir /r "$InstDir" - - ; Put file there - File /r /x ".DS_Store" /x "*.swp" "..\xmake\*.*" - File "..\*.md" - File "..\core\build\xmake.exe" - File /r /x ".DS_Store" "..\winenv" - - WriteUninstaller "uninstall.exe" - - !macro AddReg RootKey - - ; Write uac info - WriteRegStr ${RootKey} ${RegUninstall} "NoAdmin" "$NOADMIN" - - ; Write the uninstall keys for Windows - WriteRegStr ${RootKey} ${RegUninstall} "DisplayName" "XMake build utility" - WriteRegStr ${RootKey} ${RegUninstall} "DisplayIcon" '"$InstDir\xmake.exe"' - WriteRegStr ${RootKey} ${RegUninstall} "Comments" "A cross-platform build utility based on Lua" - WriteRegStr ${RootKey} ${RegUninstall} "Publisher" "The TBOOX Open Source Group" - WriteRegStr ${RootKey} ${RegUninstall} "UninstallString" '"$InstDir\uninstall.exe"' - WriteRegStr ${RootKey} ${RegUninstall} "QuiteUninstallString" '"$InstDir\uninstall.exe" /S' - WriteRegStr ${RootKey} ${RegUninstall} "InstallLocation" $InstDir - WriteRegStr ${RootKey} ${RegUninstall} "HelpLink" 'https://xmake.io/' - WriteRegStr ${RootKey} ${RegUninstall} "URLInfoAbout" 'https://github.com/xmake-io/xmake' - WriteRegStr ${RootKey} ${RegUninstall} "URLUpdateInfo" 'https://github.com/xmake-io/xmake/releases' - WriteRegDWORD ${RootKey} ${RegUninstall} "VersionMajor" ${MAJOR} - WriteRegDWORD ${RootKey} ${RegUninstall} "VersionMinor" ${MINOR} - WriteRegStr ${RootKey} ${RegUninstall} "DisplayVersion" ${VERSION_FULL} - WriteRegDWORD ${RootKey} ${RegUninstall} "NoModify" 1 - WriteRegDWORD ${RootKey} ${RegUninstall} "NoRepair" 1 - - ;write size to reg - ${GetSize} "$InstDir" "/S=0K" $0 $1 $2 - IntFmt $0 "0x%08X" $0 - WriteRegDWORD ${RootKey} ${RegUninstall} "EstimatedSize" "$0" - !macroend - - ${If} $NOADMIN == "false" - !insertmacro AddReg ${HKLM} - ${Else} - !insertmacro AddReg ${HKCU} - ${EndIf} - -SectionEnd - -Section "Add to PATH" InstallPath - - !macro AddRegPATH RootKey - ; Remove the installation path from the $PATH environment variable first - ReadRegStr $R0 ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" - ${WordReplace} $R0 ";$InstDir" "" "+" $R1 - - ; Write the installation path into the $PATH environment variable - WriteRegExpandStr ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1;$InstDir" - !macroend - - ${If} $NOADMIN == "false" - !insertmacro AddRegPATH ${HKLM} - ${Else} - !insertmacro AddRegPATH ${HKCU} - ${EndIf} - -SectionEnd - -;-------------------------------- -; Descriptions - -; Language strings -LangString DESC_InstallExeutable ${LANG_ENGLISH} "A cross-platform build utility based on Lua" -LangString DESC_InstallPath ${LANG_ENGLISH} "Add xmake to PATH" - -; Assign language strings to sections -!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN -!insertmacro MUI_DESCRIPTION_TEXT ${InstallExeutable} $(DESC_InstallExeutable) -!insertmacro MUI_DESCRIPTION_TEXT ${InstallPath} $(DESC_InstallPath) -!insertmacro MUI_FUNCTION_DESCRIPTION_END - -;-------------------------------- - -; Uninstaller - -Function un.onInit - ; check if we need uac - ReadRegStr $NOADMIN ${HKLM} ${RegUninstall} "NoAdmin" - IfErrors 0 +2 - ReadRegStr $NOADMIN ${HKCU} ${RegUninstall} "NoAdmin" - - ${IfNot} $NOADMIN == "true" - !insertmacro Init "uninstaller" - ${EndIf} - -FunctionEnd - -Section "Uninstall" - - !macro RemoveReg RootKey - ; Remove registry keys - DeleteRegKey ${RootKey} ${RegUninstall} - - ; Remove the installation path from the $PATH environment variable - ReadRegStr $R0 ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" - ${WordReplace} $R0 ";$InstDir" "" "+" $R1 - ; MessageBox MB_OK|MB_USERICON '$R0 - $InstDir - $R1 ' - WriteRegExpandStr ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1" - !macroend - - ; Remove directories used - RMDir /r "$InstDir" - ${If} $NOADMIN == "false" - !insertmacro RemoveReg ${HKLM} - ${Else} - !insertmacro RemoveReg ${HKCU} - ${EndIf} - -SectionEnd +; xmake.nsi +; +; This script is perhaps one of the simplest NSIs you can make. All of the +; optional settings are left to their default settings. The installer simply +; prompts the user asking them where to install, and drops a copy of xmake.nsi +; there. + +;-------------------------------- +; includes +!include "MUI2.nsh" +!include "WordFunc.nsh" +!include "WinMessages.nsh" +!include FileFunc.nsh +!include UAC.nsh + +; xmake version Information +!ifndef MAJOR + !define MAJOR 2 +!endif +!ifndef MINOR + !define MINOR 2 +!endif +!ifndef ALTER + !define ALTER 7 +!endif +!ifndef BUILD + !define BUILD 201906200000 +!endif + +!define VERSION ${MAJOR}.${MINOR}.${ALTER} +!define VERSION_FULL ${VERSION}+${BUILD} + +!ifdef x64 + !define ARCH x64 +!else + !define ARCH x86 +!endif + +;-------------------------------- + +; The name of the installer +Name "XMake - v${VERSION}" + +; The file to write +OutFile "xmake.exe" + +; Use unicode +Unicode true + +; Use best compressor +SetCompressor /FINAL /SOLID lzma + +; The default installation directory +!ifdef x64 + !define PROGRAMFILES $PROGRAMFILES64 + !define HKLM HKLM64 + !define HKCU HKCU64 +!else + !define PROGRAMFILES $PROGRAMFILES + !define HKLM HKLM + !define HKCU HKCU +!endif + +; Request application privileges for Windows Vista +RequestExecutionLevel user + +; Set DPI Aware +ManifestDPIAware true + +;-------------------------------- +; Interface Settings + +!define MUI_ABORTWARNING + +;-------------------------------- +; Icon +!define MUI_ICON "..\core\src\demo\xmake.ico" + +;-------------------------------- +; UAC helper + +!macro Init thing + uac_tryagain: + !insertmacro UAC_RunElevated + ${Switch} $0 + ${Case} 0 + ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done + ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on + ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user + MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0 + ${EndIf} + ;fall-through and die + ${Case} 1223 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!" + Quit + ${Case} 1062 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!" + Quit + ${Default} + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, error $0" + Quit + ${EndSwitch} + + SetShellVarContext all +!macroend + +;-------------------------------- +; Install Pages + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "..\LICENSE.md" +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!define MUI_FINISHPAGE_LINK "Donate $$5" +!define MUI_FINISHPAGE_LINK_LOCATION "https://xmake.io/pages/donation.html#donate" +!insertmacro MUI_PAGE_FINISH + +;-------------------------------- +; Uninstall Pages + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +;-------------------------------- +; Languages + +!insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +; Version Information + + +VIProductVersion ${VERSION}.0 +VIFileVersion ${VERSION}.0 +VIAddVersionKey /LANG=0 ProductName XMake +VIAddVersionKey /LANG=0 Comments "A cross-platform build utility based on Lua$\nwebsite: https://xmake.io" +VIAddVersionKey /LANG=0 CompanyName "The TBOOX Open Source Group" +VIAddVersionKey /LANG=0 LegalCopyright "Copyright (C) 2015-2019 Ruki Wang, tboox.org, xmake.io$\nCopyright (C) 2005-2015 Mike Pall, luajit.org" +VIAddVersionKey /LANG=0 FileDescription "XMake Installer - v${VERSION}" +VIAddVersionKey /LANG=0 OriginalFilename "xmake-${ARCH}.exe" +VIAddVersionKey /LANG=0 FileVersion ${VERSION_FULL} +VIAddVersionKey /LANG=0 ProductVersion ${VERSION_FULL} + + +;-------------------------------- +; Reg pathes + +!define RegUninstall "Software\Microsoft\Windows\CurrentVersion\Uninstall\XMake" + +;-------------------------------- + +Var NOADMIN + +Function TrimQuote + Exch $R1 ; Original string + Push $R2 + +Loop: + StrCpy $R2 "$R1" 1 + StrCmp "$R2" "'" TrimLeft + StrCmp "$R2" "$\"" TrimLeft + StrCmp "$R2" "$\r" TrimLeft + StrCmp "$R2" "$\n" TrimLeft + StrCmp "$R2" "$\t" TrimLeft + StrCmp "$R2" " " TrimLeft + GoTo Loop2 +TrimLeft: + StrCpy $R1 "$R1" "" 1 + Goto Loop + +Loop2: + StrCpy $R2 "$R1" 1 -1 + StrCmp "$R2" "'" TrimRight + StrCmp "$R2" "$\"" TrimRight + StrCmp "$R2" "$\r" TrimRight + StrCmp "$R2" "$\n" TrimRight + StrCmp "$R2" "$\t" TrimRight + StrCmp "$R2" " " TrimRight + GoTo Done +TrimRight: + StrCpy $R1 "$R1" -1 + Goto Loop2 + +Done: + Pop $R2 + Exch $R1 +FunctionEnd + +; Installer +Function .onInit + ${GetOptions} $CMDLINE "/NOADMIN" $NOADMIN + ${If} ${Errors} + !insertmacro Init "installer" + StrCpy $NOADMIN "false" + ${Else} + StrCpy $NOADMIN "true" + ${EndIf} + + ; load from reg + ${If} $InstDir == "" + ${If} $NOADMIN == "false" + ReadRegStr $R0 ${HKLM} ${RegUninstall} "InstallLocation" + ${Else} + ReadRegStr $R0 ${HKCU} ${RegUninstall} "InstallLocation" + ${EndIf} + ${If} $R0 != "" + Push $R0 + Call TrimQuote + Pop $R0 + StrCpy $InstDir $R0 + ${EndIf} + ${EndIf} + ; use default + ${If} $InstDir == "" + StrCpy $InstDir ${PROGRAMFILES}\xmake + ${EndIf} + +FunctionEnd + +Section "XMake (required)" InstallExeutable + + SectionIn RO + + ; Set output path to the installation directory. + SetOutPath $InstDir + + ; Remove previous directories used + RMDir /r "$InstDir" + + ; Put file there + File /r /x ".DS_Store" /x "*.swp" "..\xmake\*.*" + File "..\*.md" + File "..\core\build\xmake.exe" + File /r /x ".DS_Store" "..\winenv" + + WriteUninstaller "uninstall.exe" + + !macro AddReg RootKey + + ; Write uac info + WriteRegStr ${RootKey} ${RegUninstall} "NoAdmin" "$NOADMIN" + + ; Write the uninstall keys for Windows + WriteRegStr ${RootKey} ${RegUninstall} "DisplayName" "XMake build utility" + WriteRegStr ${RootKey} ${RegUninstall} "DisplayIcon" '"$InstDir\xmake.exe"' + WriteRegStr ${RootKey} ${RegUninstall} "Comments" "A cross-platform build utility based on Lua" + WriteRegStr ${RootKey} ${RegUninstall} "Publisher" "The TBOOX Open Source Group" + WriteRegStr ${RootKey} ${RegUninstall} "UninstallString" '"$InstDir\uninstall.exe"' + WriteRegStr ${RootKey} ${RegUninstall} "QuiteUninstallString" '"$InstDir\uninstall.exe" /S' + WriteRegStr ${RootKey} ${RegUninstall} "InstallLocation" $InstDir + WriteRegStr ${RootKey} ${RegUninstall} "HelpLink" 'https://xmake.io/' + WriteRegStr ${RootKey} ${RegUninstall} "URLInfoAbout" 'https://github.com/xmake-io/xmake' + WriteRegStr ${RootKey} ${RegUninstall} "URLUpdateInfo" 'https://github.com/xmake-io/xmake/releases' + WriteRegDWORD ${RootKey} ${RegUninstall} "VersionMajor" ${MAJOR} + WriteRegDWORD ${RootKey} ${RegUninstall} "VersionMinor" ${MINOR} + WriteRegStr ${RootKey} ${RegUninstall} "DisplayVersion" ${VERSION_FULL} + WriteRegDWORD ${RootKey} ${RegUninstall} "NoModify" 1 + WriteRegDWORD ${RootKey} ${RegUninstall} "NoRepair" 1 + + ;write size to reg + ${GetSize} "$InstDir" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD ${RootKey} ${RegUninstall} "EstimatedSize" "$0" + !macroend + + ${If} $NOADMIN == "false" + !insertmacro AddReg ${HKLM} + ${Else} + !insertmacro AddReg ${HKCU} + ${EndIf} + +SectionEnd + +Section "Add to PATH" InstallPath + + !macro AddRegPATH RootKey + ; Remove the installation path from the $PATH environment variable first + ReadRegStr $R0 ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" + ${WordReplace} $R0 ";$InstDir" "" "+" $R1 + + ; Write the installation path into the $PATH environment variable + WriteRegExpandStr ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1;$InstDir" + !macroend + + ${If} $NOADMIN == "false" + !insertmacro AddRegPATH ${HKLM} + ${Else} + !insertmacro AddRegPATH ${HKCU} + ${EndIf} + +SectionEnd + +;-------------------------------- +; Descriptions + +; Language strings +LangString DESC_InstallExeutable ${LANG_ENGLISH} "A cross-platform build utility based on Lua" +LangString DESC_InstallPath ${LANG_ENGLISH} "Add xmake to PATH" + +; Assign language strings to sections +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN +!insertmacro MUI_DESCRIPTION_TEXT ${InstallExeutable} $(DESC_InstallExeutable) +!insertmacro MUI_DESCRIPTION_TEXT ${InstallPath} $(DESC_InstallPath) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +;-------------------------------- + +; Uninstaller + +Function un.onInit + ; check if we need uac + ReadRegStr $NOADMIN ${HKLM} ${RegUninstall} "NoAdmin" + IfErrors 0 +2 + ReadRegStr $NOADMIN ${HKCU} ${RegUninstall} "NoAdmin" + + ${IfNot} $NOADMIN == "true" + !insertmacro Init "uninstaller" + ${EndIf} + +FunctionEnd + +Section "Uninstall" + + !macro RemoveReg RootKey + ; Remove registry keys + DeleteRegKey ${RootKey} ${RegUninstall} + + ; Remove the installation path from the $PATH environment variable + ReadRegStr $R0 ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" + ${WordReplace} $R0 ";$InstDir" "" "+" $R1 + ; MessageBox MB_OK|MB_USERICON '$R0 - $InstDir - $R1 ' + WriteRegExpandStr ${RootKey} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1" + !macroend + + ; Remove directories used + RMDir /r "$InstDir" + ${If} $NOADMIN == "false" + !insertmacro RemoveReg ${HKLM} + ${Else} + !insertmacro RemoveReg ${HKCU} + ${EndIf} + +SectionEnd diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 4333e71ca..eb6c5850a 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -261,7 +261,7 @@ function main(outputdir, vsinfo) for _,target in pairs(targets) do target._sub2 = {} local dirs = {} - for _,f in ipairs(target.sourcefiles) do + for _,f in ipairs(table.join(target.sourcefiles, target.headerfiles)) do local dir = path.directory(f) target._sub2[f] = { 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 48428a006..c79ec740a 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 @@ -26,6 +26,9 @@ +#Import(Include)# + + #Import(File.c)# diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) new file mode 100644 index 000000000..17344346b --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/Include(inc) @@ -0,0 +1,3 @@ + + #dir# + diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj index 734c2a9cb..d0e4e94d7 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj @@ -35,6 +35,9 @@ Include="$(XmakeScriptDir)\xmake.lua" /> +#Import(Include)# + + #Import(File.c)# diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) new file mode 100644 index 000000000..0178e0f9a --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/Include(inc) @@ -0,0 +1 @@ + diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 19ec2bfa6..cf91eb40e 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -100,6 +100,8 @@ function _buildparams(info, target, default) elseif args.filerc then local files = info._sub[target].sourcefiles table.insert(r, _filter_files(files, {".rc"})) + elseif args.inc then + table.insert(r, info._sub[target].headerfiles) end return r end -- cgit v1.3.1 From 91b6dd5c47463d3e38514e63d71e305bda4501a5 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 15 Jul 2019 10:29:38 +0800 Subject: fix path resolve --- xmake/plugins/project/vsxmake/vsproj/Xmake.props | 19 ++++++++++--------- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 8 ++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index 02c36e28b..c4677ae71 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -7,10 +7,11 @@ x86 $(Platform) - auto + x86 + - $([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('$(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('$(XmakeProjectDir)')) @@ -131,7 +132,7 @@ - $(XmakeIncludeDir);$(XmakeConfigFileDir);$(IncludePath) + $(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 e87012146..c3ce99b64 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -30,8 +30,11 @@ <_XmakeCommonFlags>$(_XmakeCommonFlags.Trim()) <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)\xmake.exe'))" - <_XmakeEnv>pushd "$(XmakeProjectDir)" -set XMAKE_CONFIGDIR=$(XmakeConfigDir) + <_XmakeEnv> + pushd "$(XmakeProjectDir)" + set XMAKE_CONFIGDIR=$(XmakeConfigDir) + set XMAKE_PROGRAM_DIR=$(XmakeProgramDir) + @@ -153,6 +156,7 @@ MSBuild Properties: + Date: Mon, 15 Jul 2019 11:18:35 +0800 Subject: fix resolve path --- xmake/plugins/project/vsxmake/vsproj/Xmake.props | 17 +++++++++-------- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index c4677ae71..0198714f3 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -49,13 +49,14 @@ $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeRunDir)')) - $([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)')) + $([MSBuild]::NormalizeDirectory('$(XmakeProgramDir)')) + $([MSBuild]::NormalizeDirectory('$(XmakeProjectDir)')) + $([MSBuild]::NormalizeDirectory('$(XmakeScriptDir)')) + $([MSBuild]::NormalizeDirectory('$(XmakeBuilDir)')) + $([MSBuild]::NormalizeDirectory('$(XmakeTargetDir)')) + $([MSBuild]::NormalizeDirectory('$(XmakeConfigDir)')) + $([MSBuild]::NormalizeDirectory('$(XmakeConfigFileDir)')) + $([MSBuild]::NormalizeDirectory('$(XmakeRunDir)')) @@ -135,6 +136,6 @@ $(XmakeIncludeDir);$(IncludePath) $(XmakeLinkDir);$(LibraryPath) $(XmakeTargetDir) - $(XmakeBuilDir)\.vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\ + $(XmakeBuilDir).vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\ diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index c3ce99b64..65cf4a77b 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -17,7 +17,7 @@ <_XmakeCommonFlags>$(_XmakeCommonFlags) $(_XmakeProjectFlag) <_XmakeConfigFlags>$(XmakeConfigFlags.Trim()) - <_XmakeConfigFlags>$(_XmakeConfigFlags) -p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)'))" + <_XmakeConfigFlags>$(_XmakeConfigFlags) -p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)').TrimEnd('/\'.ToCharArray()))" <_XmakeBuildFlags>$(XmakeBuildFlags.Trim()) <_XmakeBuildFlags Condition="$(XmakeWarning)">$(_XmakeBuildFlags) -w @@ -29,7 +29,7 @@ <_XmakeConfigFlags>$(_XmakeConfigFlags.Trim()) <_XmakeCommonFlags>$(_XmakeCommonFlags.Trim()) - <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)\xmake.exe'))" + <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)xmake.exe'))" <_XmakeEnv> pushd "$(XmakeProjectDir)" set XMAKE_CONFIGDIR=$(XmakeConfigDir) -- cgit v1.3.1 From ea562ec13fb60393d6b3c1c60c7c51cf159a6512 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 15 Jul 2019 13:30:18 +0800 Subject: fix dump --- xmake/core/base/dump.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xmake/core/base/dump.lua b/xmake/core/base/dump.lua index 1fe5f1f20..cfa25918b 100644 --- a/xmake/core/base/dump.lua +++ b/xmake/core/base/dump.lua @@ -29,7 +29,7 @@ local table = require("base/table") function dump._format(fmtkey, fmtdefault, ...) local theme = colors.theme() if theme then - return colors.translate(string.format(theme:get(fmtkey), ...)) + return colors.translate(string.format(theme:get(fmtkey), ...), { patch_reset = false, ignore_unknown = true }) else return string.format(fmtdefault, ...) end @@ -82,17 +82,17 @@ end -- print value with default format function dump._print_default(value) - io.write(dump._translate("${color.dump.default}"), dump._format("text.dump.default_format", "%s", value), dump._translate("${reset}")) + io.write(dump._translate("${reset}${color.dump.default}"), dump._format("text.dump.default_format", "<%s>", value), dump._translate("${reset}")) end -- print udata value with scalar format function dump._print_udata_scalar(value) - io.write(dump._translate("${color.dump.udata}"), dump._format("text.dump.udata_format", "%s", value), dump._translate("${reset}")) + io.write(dump._translate("${reset}${color.dump.udata}"), dump._format("text.dump.udata_format", "[%s]", value), dump._translate("${reset}")) end -- print table value with scalar format function dump._print_table_scalar(value) - io.write(dump._translate("${color.dump.table}"), dump._format("text.dump.table_format", "%s", value), dump._translate("${reset}")) + io.write(dump._translate("${reset}${color.dump.table}"), dump._format("text.dump.table_format", "{%s}", value), dump._translate("${reset}")) end -- print scalar value -- cgit v1.3.1 From 2f687640d02b4ea1a912037de6e3affb5987e8f1 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 15 Jul 2019 20:45:30 +0800 Subject: improve output --- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 65cf4a77b..947251b97 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -16,8 +16,10 @@ <_XmakeCommonFlags Condition="$(XmakeDiagnosis)">$(_XmakeCommonFlags) -D <_XmakeCommonFlags>$(_XmakeCommonFlags) $(_XmakeProjectFlag) + <_XmakeBuilDir>$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)').TrimEnd('/\'.ToCharArray())) + <_XmakeConfigFlags>$(XmakeConfigFlags.Trim()) - <_XmakeConfigFlags>$(_XmakeConfigFlags) -p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$([MSBuild]::MakeRelative('$(XmakeProjectDir)', '$(XmakeBuilDir)').TrimEnd('/\'.ToCharArray()))" + <_XmakeConfigFlags>$(_XmakeConfigFlags) -p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) -o "$(_XmakeBuilDir)" <_XmakeBuildFlags>$(XmakeBuildFlags.Trim()) <_XmakeBuildFlags Condition="$(XmakeWarning)">$(_XmakeBuildFlags) -w -- cgit v1.3.1 From 8cd138e181b63fa327b4b3caa3250fb1dce4b407 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 15 Jul 2019 20:49:21 +0800 Subject: add configfiles --- xmake/plugins/project/vsxmake/getinfo.lua | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index eb6c5850a..4567adb1e 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -29,6 +29,7 @@ import("core.tool.compiler") import("core.tool.linker") 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()}) function _make_dirs(dir) if dir == nil then @@ -196,25 +197,25 @@ function main(outputdir, vsinfo) print("checking for the %s.%s ...", mode, arch) -- reload config, project and platform - if mode ~= config.mode() or arch ~= config.arch() then + -- modify config + config.set("as", nil, {force = true}) -- force to re-check as for ml/ml64 + config.set("mode", mode, {readonly = true, force = true}) + config.set("arch", arch, {readonly = true, force = true}) - -- modify config - config.set("as", nil, {force = true}) -- force to re-check as for ml/ml64 - config.set("mode", mode, {readonly = true, force = true}) - config.set("arch", arch, {readonly = true, force = true}) + -- clear project to reload and recheck it + project.clear() - -- clear project to reload and recheck it - project.clear() + -- check project options + project.check() - -- check project options - project.check() + -- reload platform + platform.load(config.plat()) - -- reload platform - platform.load(config.plat()) + -- re-generate configheader + generate_configheader() - -- re-generate configheader - generate_configheader() - end + -- re-generate configfiles + generate_configfiles() -- ensure to enter project directory os.cd(project.directory()) -- cgit v1.3.1