From 6c5fbedfe26db54b0bbb95fa9154ed759c7ad98f Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 4 Jun 2015 15:46:43 +0800 Subject: rebuild compiler and linker --- xmake/scripts/compiler/_msvc.lua | 75 -------- xmake/scripts/linker/_msvc.lua | 85 --------- xmake/scripts/platform/android/android.lua | 36 ++-- xmake/scripts/platform/android/prober.lua | 16 +- xmake/scripts/platform/iphoneos/iphoneos.lua | 58 +++--- xmake/scripts/platform/iphoneos/prober.lua | 24 +-- .../platform/iphonesimulator/iphonesimulator.lua | 60 +++--- xmake/scripts/platform/iphonesimulator/prober.lua | 24 +-- xmake/scripts/platform/linux/linux.lua | 36 ++-- xmake/scripts/platform/linux/prober.lua | 16 +- xmake/scripts/platform/macosx/macosx.lua | 26 +-- xmake/scripts/platform/macosx/prober.lua | 24 +-- xmake/scripts/platform/msvc/msvc.lua | 81 ++++++++ xmake/scripts/platform/msvc/prober.lua | 203 +++++++++++++++++++++ xmake/scripts/platform/msvc/tools/cl.lua | 78 ++++++++ xmake/scripts/platform/msvc/tools/link.lua | 90 +++++++++ xmake/scripts/platform/msvc/tools/nmake.lua | 112 ++++++++++++ xmake/scripts/platform/windows/prober.lua | 203 --------------------- xmake/scripts/platform/windows/tools/nmake.lua | 112 ------------ xmake/scripts/platform/windows/windows.lua | 87 --------- 20 files changed, 722 insertions(+), 724 deletions(-) delete mode 100644 xmake/scripts/compiler/_msvc.lua delete mode 100644 xmake/scripts/linker/_msvc.lua create mode 100644 xmake/scripts/platform/msvc/msvc.lua create mode 100644 xmake/scripts/platform/msvc/prober.lua create mode 100644 xmake/scripts/platform/msvc/tools/cl.lua create mode 100644 xmake/scripts/platform/msvc/tools/link.lua create mode 100644 xmake/scripts/platform/msvc/tools/nmake.lua delete mode 100644 xmake/scripts/platform/windows/prober.lua delete mode 100644 xmake/scripts/platform/windows/tools/nmake.lua delete mode 100644 xmake/scripts/platform/windows/windows.lua diff --git a/xmake/scripts/compiler/_msvc.lua b/xmake/scripts/compiler/_msvc.lua deleted file mode 100644 index aa1968f7e..000000000 --- a/xmake/scripts/compiler/_msvc.lua +++ /dev/null @@ -1,75 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see http://www.gnu.org/licenses/ --- --- Copyright (C) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file _msvc.lua --- - --- define module: _msvc -local _msvc = _msvc or {} - --- load modules -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") - --- init the compiler -function _msvc._init(configs) - - -- the architecture - local arch = config.get("arch") - assert(arch) - - -- init cflags - configs.cflags = "-nologo" - - -- init cxxflags - configs.cxxflags = "-nologo" - -end - --- make the compiler command -function _msvc._make(configs, srcfile, objfile, flags) - - -- make it - return string.format("%s -c %s -Fo%s %s", configs.name, flags, objfile, srcfile) -end - --- make the define flag -function _msvc._make_define(configs, define) - - -- make it - return "-D" .. define -end - --- make the includedir flag -function _msvc._make_includedir(configs, includedir) - - -- make it - return "-I" .. includedir -end - --- map gcc flag to the current compiler flag -function _msvc._mapflag(configs, flag) - - -- ok - return flag -end - --- return module: _msvc -return _msvc diff --git a/xmake/scripts/linker/_msvc.lua b/xmake/scripts/linker/_msvc.lua deleted file mode 100644 index 94ee00349..000000000 --- a/xmake/scripts/linker/_msvc.lua +++ /dev/null @@ -1,85 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see http://www.gnu.org/licenses/ --- --- Copyright (C) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file _msvc.lua --- - --- define module: _msvc -local _msvc = _msvc or {} - --- load modules -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") - --- init the linker -function _msvc._init(configs) - - -- the architecture - local arch = config.get("arch") - assert(arch) - - -- init flags for architecture - local flags_arch = "" - if arch == "x86" then flags_arch = "-machine:x86" - elseif arch == "x64" then flags_arch = "-machine:x86_64" - end - - -- init ldflags - configs.ldflags = "-nologo -dynamicbase -nxcompat -manifest -manifestuac:\"level='asInvoker' uiAccess='false'\" " .. flags_arch - - -- init arflags - configs.arflags = "-lib -nologo " .. flags_arch - - -- init shflags - configs.shflags = "-dll -nologo " .. flags_arch - -end - --- make the command -function _msvc._make(configs, objfiles, targetfile, flags) - - -- make it - return string.format("%s %s -out:%s %s", configs.name, flags, targetfile, objfiles) -end - --- make the link flag -function _msvc._make_link(configs, link) - - -- make it - return link .. ".lib" -end - --- make the linkdir flag -function _msvc._make_linkdir(configs, linkdir) - - -- make it - return "-libpath:" .. linkdir -end - --- map gcc flag to the current linker flag -function _msvc._mapflag(configs, flag) - - -- ok - return flag -end - --- return module: _msvc -return _msvc diff --git a/xmake/scripts/platform/android/android.lua b/xmake/scripts/platform/android/android.lua index ba180d87d..b8e91a09f 100644 --- a/xmake/scripts/platform/android/android.lua +++ b/xmake/scripts/platform/android/android.lua @@ -17,44 +17,44 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _android.lua +-- @file android.lua -- --- define module: _android -local _android = _android or {} +-- define module: android +local android = android or {} -- load modules local config = require("base/config") -- init host -_android._HOST = xmake._HOST +android._HOST = xmake._HOST -- init architectures -_android._ARCHS = {"armv5te", "armv6", "armv7-a"} +android._ARCHS = {"armv5te", "armv6", "armv7-a"} -- make configure -function _android.make(configs) +function android.make(configs) - -- init the file name format - configs.format = {} - configs.format.static = {"lib", ".a"} - configs.format.object = {"", ".o"} - configs.format.shared = {"lib", ".so"} + -- init the file formats + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".so"} end -- get the option menu for action: xmake config or global -function _android.menu(action) +function android.menu(action) -- init config option menu - _android._MENU_CONFIG = _android._MENU_CONFIG or + android._MENU_CONFIG = android._MENU_CONFIG or { {} , {nil, "ndk", "kv", nil, "The NDK Directory" } , {nil, "ndk_sdkver", "kv", "auto", "The SDK Version for NDK" } , } -- init global option menu - _android._MENU_GLOBAL = _android._MENU_GLOBAL or + android._MENU_GLOBAL = android._MENU_GLOBAL or { {} , {nil, "ndk", "kv", nil, "The NDK Directory" } , {nil, "ndk_sdkver", "kv", "auto", "The SDK Version for NDK" } @@ -62,11 +62,11 @@ function _android.menu(action) -- get the option menu if action == "config" then - return _android._MENU_CONFIG + return android._MENU_CONFIG elseif action == "global" then - return _android._MENU_GLOBAL + return android._MENU_GLOBAL end end --- return module: _android -return _android +-- return module: android +return android diff --git a/xmake/scripts/platform/android/prober.lua b/xmake/scripts/platform/android/prober.lua index 28ccc3e9f..67078f244 100644 --- a/xmake/scripts/platform/android/prober.lua +++ b/xmake/scripts/platform/android/prober.lua @@ -17,7 +17,7 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _prober.lua +-- @file prober.lua -- -- load modules @@ -26,11 +26,11 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") --- define module: _prober -local _prober = _prober or {} +-- define module: prober +local prober = prober or {} -- probe the architecture -function _prober._probe_arch(configs) +function prober._probe_arch(configs) -- get the architecture local arch = configs.arch @@ -46,12 +46,12 @@ function _prober._probe_arch(configs) end -- probe the configure -function _prober.done(configs, is_global) +function prober.done(configs, is_global) -- probe the architecture - if not _prober._probe_arch(configs) then return end + if not prober._probe_arch(configs) then return end end --- return module: _prober -return _prober +-- return module: prober +return prober diff --git a/xmake/scripts/platform/iphoneos/iphoneos.lua b/xmake/scripts/platform/iphoneos/iphoneos.lua index 872f7c2e1..7c6567416 100644 --- a/xmake/scripts/platform/iphoneos/iphoneos.lua +++ b/xmake/scripts/platform/iphoneos/iphoneos.lua @@ -17,42 +17,40 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _iphoneos.lua +-- @file iphoneos.lua -- --- define module: _iphoneos -local _iphoneos = _iphoneos or {} +-- define module: iphoneos +local iphoneos = iphoneos or {} -- load modules local config = require("base/config") -- init host -_iphoneos._HOST = "macosx" +iphoneos._HOST = "macosx" -- init architectures -_iphoneos._ARCHS = {"armv7", "armv7s", "arm64"} +iphoneos._ARCHS = {"armv7", "armv7s", "arm64"} -- make configure -function _iphoneos.make(configs) +function iphoneos.make(configs) - -- init the file name format - configs.format = {} - configs.format.static = {"lib", ".a"} - configs.format.object = {"", ".o"} - configs.format.shared = {"lib", ".dylib"} - - -- init the compiler - configs.compiler = {} - configs.compiler.cc = config.get("cc") or "xcrun -sdk iphoneos clang" - configs.compiler.cxx = config.get("cxx") or "xcrun -sdk iphoneos clang++" - configs.compiler.mm = config.get("mm") or configs.compiler.cc - configs.compiler.mxx = config.get("mxx") or configs.compiler.cxx + -- init the file formats + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".dylib"} - -- init the linker - configs.linker = {} - configs.linker.binary = config.get("ld") or "xcrun -sdk iphoneos clang++" - configs.linker.static = config.get("ar") or "xcrun -sdk iphoneos ar" - configs.linker.shared = config.get("sh") or "xcrun -sdk iphoneos clang++" + -- init the toolchains + configs.tools = {} + configs.tools.make = "make" + configs.tools.cc = config.get("cc") or "xcrun -sdk iphoneos clang" + configs.tools.cxx = config.get("cxx") or "xcrun -sdk iphoneos clang++" + configs.tools.mm = config.get("mm") or configs.tools.cc + configs.tools.mxx = config.get("mxx") or configs.tools.cxx + configs.tools.ld = config.get("ld") or "xcrun -sdk iphoneos clang++" + configs.tools.ar = config.get("ar") or "xcrun -sdk iphoneos ar" + configs.tools.sh = config.get("sh") or "xcrun -sdk iphoneos clang++" -- init xcode sdk directory configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" .. config.get("xcode_sdkver") .. ".sdk" @@ -60,10 +58,10 @@ function _iphoneos.make(configs) end -- get the option menu for action: xmake config or global -function _iphoneos.menu(action) +function iphoneos.menu(action) -- init config option menu - _iphoneos._MENU_CONFIG = _iphoneos._MENU_CONFIG or + iphoneos._MENU_CONFIG = iphoneos._MENU_CONFIG or { {} , {nil, "mm", "kv", nil, "The Objc Compiler" } , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } @@ -80,7 +78,7 @@ function _iphoneos.menu(action) , } -- init global option menu - _iphoneos._MENU_GLOBAL = _iphoneos._MENU_GLOBAL or + iphoneos._MENU_GLOBAL = iphoneos._MENU_GLOBAL or { {} , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } , {} @@ -91,12 +89,12 @@ function _iphoneos.menu(action) -- get the option menu if action == "config" then - return _iphoneos._MENU_CONFIG + return iphoneos._MENU_CONFIG elseif action == "global" then - return _iphoneos._MENU_GLOBAL + return iphoneos._MENU_GLOBAL end end --- return module: _iphoneos -return _iphoneos +-- return module: iphoneos +return iphoneos diff --git a/xmake/scripts/platform/iphoneos/prober.lua b/xmake/scripts/platform/iphoneos/prober.lua index f28d0a672..d8a1c5330 100644 --- a/xmake/scripts/platform/iphoneos/prober.lua +++ b/xmake/scripts/platform/iphoneos/prober.lua @@ -17,7 +17,7 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _prober.lua +-- @file prober.lua -- -- load modules @@ -26,11 +26,11 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") --- define module: _prober -local _prober = _prober or {} +-- define module: prober +local prober = prober or {} -- probe the architecture -function _prober._probe_arch(configs) +function prober._probe_arch(configs) -- get the architecture local arch = configs.arch @@ -46,7 +46,7 @@ function _prober._probe_arch(configs) end -- probe the xcode application directory -function _prober._probe_xcode(configs) +function prober._probe_xcode(configs) -- get the xcode directory local xcode_dir = configs.xcode_dir @@ -88,7 +88,7 @@ function _prober._probe_xcode(configs) end -- probe the xcode sdk version -function _prober._probe_xcode_sdkver(configs) +function prober._probe_xcode_sdkver(configs) -- get the xcode sdk version local xcode_sdkver = configs.xcode_sdkver @@ -126,18 +126,18 @@ function _prober._probe_xcode_sdkver(configs) end -- probe the configure -function _prober.done(configs, is_global) +function prober.done(configs, is_global) -- probe the architecture - if not _prober._probe_arch(configs) then return end + if not prober._probe_arch(configs) then return end -- probe the xcode application directory - if not _prober._probe_xcode(configs) then return end + if not prober._probe_xcode(configs) then return end -- probe the xcode sdk version - if not is_global and not _prober._probe_xcode_sdkver(configs) then return end + if not is_global and not prober._probe_xcode_sdkver(configs) then return end end --- return module: _prober -return _prober +-- return module: prober +return prober diff --git a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua index 4a814691d..a7b0a99ff 100644 --- a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua +++ b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua @@ -17,42 +17,40 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _iphonesimulator.lua +-- @file iphonesimulator.lua -- --- define module: _iphonesimulator -local _iphonesimulator = _iphonesimulator or {} +-- define module: iphonesimulator +local iphonesimulator = iphonesimulator or {} -- load modules local config = require("base/config") -- init host -_iphonesimulator._HOST = "macosx" +iphonesimulator._HOST = "macosx" -- init architectures -_iphonesimulator._ARCHS = {"x86", "x64"} +iphonesimulator._ARCHS = {"x86", "x64"} -- make configure -function _iphonesimulator.make(configs) +function iphonesimulator.make(configs) - -- init the file name format - configs.format = {} - configs.format.static = {"lib", ".a"} - configs.format.object = {"", ".o"} - configs.format.shared = {"lib", ".dylib"} - - -- init the compiler - configs.compiler = {} - configs.compiler.cc = config.get("cc") or "xcrun -sdk iphonesimulator clang" - configs.compiler.cxx = config.get("cxx") or "xcrun -sdk iphonesimulator clang++" - configs.compiler.mm = config.get("mm") or configs.compiler.cc - configs.compiler.mxx = config.get("mxx") or configs.compiler.cxx - - -- init the linker - configs.linker = {} - configs.linker.binary = config.get("ld") or "xcrun -sdk iphonesimulator clang++" - configs.linker.static = config.get("ar") or "xcrun -sdk iphonesimulator ar" - configs.linker.shared = config.get("sh") or "xcrun -sdk iphonesimulator clang++" + -- init the file formats + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".dylib"} + + -- init the toolchains + configs.tools = {} + configs.tools.make = "make" + configs.tools.cc = config.get("cc") or "xcrun -sdk iphonesimulator clang" + configs.tools.cxx = config.get("cxx") or "xcrun -sdk iphonesimulator clang++" + configs.tools.mm = config.get("mm") or configs.tools.cc + configs.tools.mxx = config.get("mxx") or configs.tools.cxx + configs.tools.ld = config.get("ld") or "xcrun -sdk iphonesimulator clang++" + configs.tools.ar = config.get("ar") or "xcrun -sdk iphonesimulator ar" + configs.tools.sh = config.get("sh") or "xcrun -sdk iphonesimulator clang++" -- init xcode sdk directory configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" .. config.get("xcode_sdkver") .. ".sdk" @@ -60,10 +58,10 @@ function _iphonesimulator.make(configs) end -- get the option menu for action: xmake config or global -function _iphonesimulator.menu(action) +function iphonesimulator.menu(action) -- init config option menu - _iphonesimulator._MENU_CONFIG = _iphonesimulator._MENU_CONFIG or + iphonesimulator._MENU_CONFIG = iphonesimulator._MENU_CONFIG or { {} , {nil, "mm", "kv", nil, "The Objc Compiler" } , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } @@ -80,7 +78,7 @@ function _iphonesimulator.menu(action) , } -- init global option menu - _iphonesimulator._MENU_GLOBAL = _iphonesimulator._MENU_GLOBAL or + iphonesimulator._MENU_GLOBAL = iphonesimulator._MENU_GLOBAL or { {} , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } , {} @@ -91,12 +89,12 @@ function _iphonesimulator.menu(action) -- get the option menu if action == "config" then - return _iphonesimulator._MENU_CONFIG + return iphonesimulator._MENU_CONFIG elseif action == "global" then - return _iphonesimulator._MENU_GLOBAL + return iphonesimulator._MENU_GLOBAL end end --- return module: _iphonesimulator -return _iphonesimulator +-- return module: iphonesimulator +return iphonesimulator diff --git a/xmake/scripts/platform/iphonesimulator/prober.lua b/xmake/scripts/platform/iphonesimulator/prober.lua index eeb485b86..5b2321e4e 100644 --- a/xmake/scripts/platform/iphonesimulator/prober.lua +++ b/xmake/scripts/platform/iphonesimulator/prober.lua @@ -17,7 +17,7 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _prober.lua +-- @file prober.lua -- -- load modules @@ -26,11 +26,11 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") --- define module: _prober -local _prober = _prober or {} +-- define module: prober +local prober = prober or {} -- probe the architecture -function _prober._probe_arch(configs) +function prober._probe_arch(configs) -- get the architecture local arch = configs.arch @@ -46,7 +46,7 @@ function _prober._probe_arch(configs) end -- probe the xcode application directory -function _prober._probe_xcode(configs) +function prober._probe_xcode(configs) -- get the xcode directory local xcode_dir = configs.xcode_dir @@ -88,7 +88,7 @@ function _prober._probe_xcode(configs) end -- probe the xcode sdk version -function _prober._probe_xcode_sdkver(configs) +function prober._probe_xcode_sdkver(configs) -- get the xcode sdk version local xcode_sdkver = configs.xcode_sdkver @@ -126,18 +126,18 @@ function _prober._probe_xcode_sdkver(configs) end -- probe the configure -function _prober.done(configs, is_global) +function prober.done(configs, is_global) -- probe the architecture - if not _prober._probe_arch(configs) then return end + if not prober._probe_arch(configs) then return end -- probe the xcode application directory - if not _prober._probe_xcode(configs) then return end + if not prober._probe_xcode(configs) then return end -- probe the xcode sdk version - if not is_global and not _prober._probe_xcode_sdkver(configs) then return end + if not is_global and not prober._probe_xcode_sdkver(configs) then return end end --- return module: _prober -return _prober +-- return module: prober +return prober diff --git a/xmake/scripts/platform/linux/linux.lua b/xmake/scripts/platform/linux/linux.lua index 57d436eb5..3cc436d39 100644 --- a/xmake/scripts/platform/linux/linux.lua +++ b/xmake/scripts/platform/linux/linux.lua @@ -17,51 +17,51 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _linux.lua +-- @file linux.lua -- --- define module: _linux -local _linux = _linux or {} +-- define module: linux +local linux = linux or {} -- load modules local config = require("base/config") -- init host -_linux._HOST = "linux" +linux._HOST = "linux" -- init architectures -_linux._ARCHS = {"x86", "x64"} +linux._ARCHS = {"x86", "x64"} -- make configure -function _linux.make(configs) +function linux.make(configs) - -- init the file name format - configs.format = {} - configs.format.static = {"lib", ".a"} - configs.format.object = {"", ".o"} - configs.format.shared = {"lib", ".so"} + -- init the file formats + configs.formats = {} + configs.formats.static = {"lib", ".a"} + configs.formats.object = {"", ".o"} + configs.formats.shared = {"lib", ".so"} end -- get the option menu for action: xmake config or global -function _linux.menu(action) +function linux.menu(action) -- init config option menu - _linux._MENU_CONFIG = _linux._MENU_CONFIG or + linux._MENU_CONFIG = linux._MENU_CONFIG or { {} , {nil, "ar", "kv", nil, "The Library Creator" } , {nil, "arflags", "kv", nil, "The Library Creator Flags" } } -- init global option menu - _linux._MENU_GLOBAL = _linux._MENU_GLOBAL or {} + linux._MENU_GLOBAL = linux._MENU_GLOBAL or {} -- get the option menu if action == "config" then - return _linux._MENU_CONFIG + return linux._MENU_CONFIG elseif action == "global" then - return _linux._MENU_GLOBAL + return linux._MENU_GLOBAL end end --- return module: _linux -return _linux +-- return module: linux +return linux diff --git a/xmake/scripts/platform/linux/prober.lua b/xmake/scripts/platform/linux/prober.lua index 717bd71fe..f8418ff12 100644 --- a/xmake/scripts/platform/linux/prober.lua +++ b/xmake/scripts/platform/linux/prober.lua @@ -17,7 +17,7 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _prober.lua +-- @file prober.lua -- -- load modules @@ -26,11 +26,11 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") --- define module: _prober -local _prober = _prober or {} +-- define module: prober +local prober = prober or {} -- probe the architecture -function _prober._probe_arch(configs) +function prober._probe_arch(configs) -- get the architecture local arch = configs.arch @@ -46,12 +46,12 @@ function _prober._probe_arch(configs) end -- probe the configure -function _prober.done(configs, is_global) +function prober.done(configs, is_global) -- probe the architecture - if not _prober._probe_arch(configs) then return end + if not prober._probe_arch(configs) then return end end --- return module: _prober -return _prober +-- return module: prober +return prober diff --git a/xmake/scripts/platform/macosx/macosx.lua b/xmake/scripts/platform/macosx/macosx.lua index bad818081..9483f2f24 100644 --- a/xmake/scripts/platform/macosx/macosx.lua +++ b/xmake/scripts/platform/macosx/macosx.lua @@ -17,23 +17,23 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _macosx.lua +-- @file macosx.lua -- --- define module: _macosx -local _macosx = _macosx or {} +-- define module: macosx +local macosx = macosx or {} -- load modules local config = require("base/config") -- init host -_macosx._HOST = "macosx" +macosx._HOST = "macosx" -- init architectures -_macosx._ARCHS = {"x86", "x64"} +macosx._ARCHS = {"x86", "x64"} -- make configure -function _macosx.make(configs) +function macosx.make(configs) -- init the file formats configs.formats = {} @@ -57,10 +57,10 @@ function _macosx.make(configs) end -- get the option menu for action: xmake config or global -function _macosx.menu(action) +function macosx.menu(action) -- init config option menu - _macosx._MENU_CONFIG = _macosx._MENU_CONFIG or + macosx._MENU_CONFIG = macosx._MENU_CONFIG or { {} , {nil, "mm", "kv", nil, "The Objc Compiler" } , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } @@ -73,18 +73,18 @@ function _macosx.menu(action) , } -- init global option menu - _macosx._MENU_GLOBAL = _macosx._MENU_GLOBAL or + macosx._MENU_GLOBAL = macosx._MENU_GLOBAL or { {} , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } , } -- get the option menu if action == "config" then - return _macosx._MENU_CONFIG + return macosx._MENU_CONFIG elseif action == "global" then - return _macosx._MENU_GLOBAL + return macosx._MENU_GLOBAL end end --- return module: _macosx -return _macosx +-- return module: macosx +return macosx diff --git a/xmake/scripts/platform/macosx/prober.lua b/xmake/scripts/platform/macosx/prober.lua index 9e722d4d0..0c6aa4a67 100644 --- a/xmake/scripts/platform/macosx/prober.lua +++ b/xmake/scripts/platform/macosx/prober.lua @@ -17,7 +17,7 @@ -- Copyright (C) 2009 - 2015, ruki All rights reserved. -- -- @author ruki --- @file _prober.lua +-- @file prober.lua -- -- load modules @@ -26,11 +26,11 @@ local path = require("base/path") local utils = require("base/utils") local string = require("base/string") --- define module: _prober -local _prober = _prober or {} +-- define module: prober +local prober = prober or {} -- probe the architecture -function _prober._probe_arch(configs) +function prober._probe_arch(configs) -- get the architecture local arch = configs.arch @@ -46,7 +46,7 @@ function _prober._probe_arch(configs) end -- probe the xcode application directory -function _prober._probe_xcode(configs) +function prober._probe_xcode(configs) -- get the xcode directory local xcode_dir = configs.xcode_dir @@ -88,7 +88,7 @@ function _prober._probe_xcode(configs) end -- probe the xcode sdk version -function _prober._probe_xcode_sdkver(configs) +function prober._probe_xcode_sdkver(configs) -- get the xcode sdk version local xcode_sdkver = configs.xcode_sdkver @@ -126,18 +126,18 @@ function _prober._probe_xcode_sdkver(configs) end -- probe the configure -function _prober.done(configs, is_global) +function prober.done(configs, is_global) -- probe the architecture - if not _prober._probe_arch(configs) then return end + if not prober._probe_arch(configs) then return end -- probe the xcode application directory - if not _prober._probe_xcode(configs) then return end + if not prober._probe_xcode(configs) then return end -- probe the xcode sdk version - if not is_global and not _prober._probe_xcode_sdkver(configs) then return end + if not is_global and not prober._probe_xcode_sdkver(configs) then return end end --- return module: _prober -return _prober +-- return module: prober +return prober diff --git a/xmake/scripts/platform/msvc/msvc.lua b/xmake/scripts/platform/msvc/msvc.lua new file mode 100644 index 000000000..332b2b5f7 --- /dev/null +++ b/xmake/scripts/platform/msvc/msvc.lua @@ -0,0 +1,81 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see http://www.gnu.org/licenses/ +-- +-- Copyright (C) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file msvc.lua +-- + +-- define module: msvc +local msvc = msvc or {} + +-- load modules +local config = require("base/config") + +-- init host +msvc._HOST = "windows" + +-- init architectures +msvc._ARCHS = {"x86", "x64"} + +-- make configure +function msvc.make(configs) + + -- init the file formats + configs.formats = {} + configs.formats.static = {"", ".lib"} + configs.formats.object = {"", ".obj"} + configs.formats.shared = {"", ".dll"} + configs.formats.binary = {"", ".exe"} + + -- init the toolchains + configs.tools = {} + configs.tools.make = "nmake" + configs.tools.cc = config.get("cc") or "cl" + configs.tools.cxx = config.get("cxx") or "cl" + configs.tools.ld = config.get("ld") or "link" + configs.tools.ar = config.get("ar") or "link" + configs.tools.sh = config.get("sh") or "link" + +end + +-- get the option menu for action: xmake config or global +function msvc.menu(action) + + -- init config option menu + msvc._MENU_CONFIG = msvc._MENU_CONFIG or + { {} + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } + , } + + -- init global option menu + msvc._MENU_GLOBAL = msvc._MENU_GLOBAL or + { {} + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } + , } + + -- get the option menu + if action == "config" then + return msvc._MENU_CONFIG + elseif action == "global" then + return msvc._MENU_GLOBAL + end +end + + +-- return module: msvc +return msvc diff --git a/xmake/scripts/platform/msvc/prober.lua b/xmake/scripts/platform/msvc/prober.lua new file mode 100644 index 000000000..b5d2947af --- /dev/null +++ b/xmake/scripts/platform/msvc/prober.lua @@ -0,0 +1,203 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see http://www.gnu.org/licenses/ +-- +-- Copyright (C) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file prober.lua +-- + +-- load modules +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") +local string = require("base/string") + +-- define module: prober +local prober = prober or {} + +-- probe the architecture +function prober._probe_arch(configs) + + -- get the architecture + local arch = configs.arch + + -- ok? + if arch then return true end + + -- init the default architecture + configs.arch = xmake._ARCH + + -- ok + return true +end + +-- probe the vs version +function prober._probe_vs_version(configs) + + -- get the vs version + local vs = configs.vs + + -- ok? + if vs then return true end + + -- clear it first + vs = nil + + -- make the map table + local map = + { + VS120COMNTOOLS = "2013" + , VS110COMNTOOLS = "2012" + , VS100COMNTOOLS = "2010" + , VS90COMNTOOLS = "2008" + , VS80COMNTOOLS = "2005" + , VS71COMNTOOLS = "2003" + , VS70COMNTOOLS = "7.0" + , VS60COMNTOOLS = "6.0" + , VS50COMNTOOLS = "5.0" + , VS42COMNTOOLS = "4.2" + } + + -- attempt to get it from the envirnoment variable + if not vs then + for k, v in pairs(map) do + if os.getenv(k) then + vs = v + break + end + end + end + + -- probe ok? update it + if vs then + configs.vs = vs + else + -- failed + utils.error("The Microsoft Visual Studio is unknown now, please config it first!") + utils.error(" - xmake config --vs=xxx") + utils.error("or - xmake global --vs=xxx") + return false + end + + -- ok + return true +end + +-- probe the vs path +function prober._probe_vs_path(configs) + + -- ok? + if configs.__vsenv_path then return true end + + -- get the vs version + local vs = configs.vs + assert(vs) + + -- make the map table + local map = + { + ["2013"] = "VS120COMNTOOLS" + , ["2012"] = "VS110COMNTOOLS" + , ["2010"] = "VS100COMNTOOLS" + , ["2008"] = "VS90COMNTOOLS" + , ["2005"] = "VS80COMNTOOLS" + , ["2003"] = "VS71COMNTOOLS" + , ["7.0"] = "VS70COMNTOOLS" + , ["6.0"] = "VS60COMNTOOLS" + , ["5.0"] = "VS50COMNTOOLS" + , ["4.2"] = "VS42COMNTOOLS" + } + + -- attempt to get the tools directory from the envirnoment variable + local toolsdir = map[vs] + if toolsdir then + toolsdir = os.getenv(toolsdir) + end + + -- the vsvars32.bat path + local vsvars32 = toolsdir .. "\\vsvars32.bat" + if not os.isfile(vsvars32) then + -- error + utils.error("not found %s", vsvars32) + return false + end + + -- get the temporary directory + local tmpdir = os.tmpdir() + assert(tmpdir) + + -- make the call(vsvars32.bat) file + local callpath = tmpdir .. "\\call_vsvars32.bat" + local callfile = io.open(callpath, "w") + assert(callfile) + + -- make call scripts + callfile:write("@echo off\n") + callfile:write(string.format("call \"%s\" > nul\n", vsvars32)) + callfile:write("echo return \n") + callfile:write("echo { \n") + callfile:write("echo path = \"%path%\"\n") + callfile:write("echo , lib = \"%lib%\"\n") + callfile:write("echo , libpath = \"%libpath%\"\n") + callfile:write("echo , include = \"%include%\"\n") + callfile:write("echo , devenvdir = \"%devenvdir%\"\n") + callfile:write("echo , vsinstalldir = \"%vsinstalldir%\"\n") + callfile:write("echo , vcinstalldir = \"%vcinstalldir%\"\n") + callfile:write("echo } \n") + + -- close the file + callfile:close() + + -- execute the call(vsvars32.bat) file and get all envirnoment variables + local cmd = io.popen(callpath) + local results = cmd:read("*all") + cmd:close() + + -- translate '\' => '\\' + results = results:gsub("\\", "\\\\") + + -- get all envirnoment variables + local variables = assert(loadstring(results))() + if not variables or not variables.path then + return false + end + + -- save the variables + for k, v in pairs(variables) do + configs["__vsenv_" .. k] = v + end + + -- ok + return true +end + +-- probe the configure +function prober.done(configs, is_global) + + -- probe the architecture + if not prober._probe_arch(configs) then return end + + -- probe the vs version + if not prober._probe_vs_version(configs) then return end + + -- probe the vs path + if not prober._probe_vs_path(configs) then return end + +end + +-- return module: prober +return prober diff --git a/xmake/scripts/platform/msvc/tools/cl.lua b/xmake/scripts/platform/msvc/tools/cl.lua new file mode 100644 index 000000000..a8ab807a7 --- /dev/null +++ b/xmake/scripts/platform/msvc/tools/cl.lua @@ -0,0 +1,78 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see http://www.gnu.org/licenses/ +-- +-- Copyright (C) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file cl.lua +-- + +-- define module: cl +local cl = cl or {} + +-- load modules +local utils = require("base/utils") +local string = require("base/string") +local config = require("base/config") + +-- init the compiler +function cl.init(name) + + -- init cflags + cl.cflags = "-nologo" + + -- init cxxflags + cl.cxxflags = "-nologo" + +end + +-- make the compiler command +function cl.command_compile(srcfile, objfile, flags) + + -- make it + return string.format("cl.exe -c %s -Fo%s %s", flags, objfile, srcfile) +end + +-- make the define flag +function cl.flag_define(define) + + -- make it + return "-D" .. define +end + +-- make the includedir flag +function cl.flag_includedir(includedir) + + -- make it + return "-I" .. includedir +end + +-- map gcc flag to the current compiler flag +function cl.flag_map(flag) + + -- ok + return flag +end + +-- the main function +function cl.main(...) + + -- ok + return true +end + +-- return module: cl +return cl diff --git a/xmake/scripts/platform/msvc/tools/link.lua b/xmake/scripts/platform/msvc/tools/link.lua new file mode 100644 index 000000000..52528ca6c --- /dev/null +++ b/xmake/scripts/platform/msvc/tools/link.lua @@ -0,0 +1,90 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see http://www.gnu.org/licenses/ +-- +-- Copyright (C) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file link.lua +-- + +-- define module: link +local link = link or {} + +-- load modules +local utils = require("base/utils") +local string = require("base/string") +local config = require("base/config") + +-- init the compiler +function link.init(name) + + -- the architecture + local arch = config.get("arch") + assert(arch) + + -- init flags for architecture + local flags_arch = "" + if arch == "x86" then flags_arch = "-machine:x86" + elseif arch == "x64" then flags_arch = "-machine:x86_64" + end + + -- init ldflags + link.ldflags = "-nologo -dynamicbase -nxcompat -manifest -manifestuac:\"level='asInvoker' uiAccess='false'\" " .. flags_arch + + -- init arflags + link.arflags = "-lib -nologo " .. flags_arch + + -- init shflags + link.shflags = "-dll -nologo " .. flags_arch +end + +-- make the linker command +function link.command_link(objfiles, targetfile, flags) + + -- make it + return string.format("link.exe %s -out:%s %s", flags, targetfile, objfiles) +end + +-- make the link flag +function link.flag_link(link) + + -- make it + return link .. ".lib" +end + +-- make the linkdir flag +function link.flag_linkdir(linkdir) + + -- make it + return "-libpath:" .. linkdir +end + +-- map gcc flag to the current compiler flag +function link.flag_map(flag) + + -- ok + return flag +end + +-- the main function +function link.main(...) + + -- ok + return true +end + +-- return module: link +return link diff --git a/xmake/scripts/platform/msvc/tools/nmake.lua b/xmake/scripts/platform/msvc/tools/nmake.lua new file mode 100644 index 000000000..6d6b21258 --- /dev/null +++ b/xmake/scripts/platform/msvc/tools/nmake.lua @@ -0,0 +1,112 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see http://www.gnu.org/licenses/ +-- +-- Copyright (C) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file nmake.lua +-- + +-- load modules +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") +local string = require("base/string") +local config = require("base/config") + +-- define module: nmake +local nmake = nmake or {} + +-- enter the given environment +function nmake._enter(name) + + -- check + assert(name) + + -- get the pathes for the vs environment + local old = nil + local new = config.get("__vsenv_" .. name) + if new then + + -- get the current pathes + old = os.getenv(name) or "" + + -- append the current pathes + new = new .. ";" .. old + + -- update the pathes for the environment + os.setenv(name, new) + end + + -- return the previous environment + return old; +end + +-- leave the given environment +function nmake._leave(name, old) + + -- check + assert(name) + + -- restore the previous environment + if old then + os.setenv(name, old) + end +end + +-- the init function +function nmake.init(name) + + -- save name + nmake._NAME = name or "nmake.exe" + + -- is verbose? + nmake._VERBOSE = utils.ifelse(xmake._OPTIONS.verbose, "-v", "") + +end + +-- the main function +function nmake.main(mkfile, target) + + -- enter the vs environment + local pathes = nmake._enter("path") + local libs = nmake._enter("lib") + local includes = nmake._enter("include") + local libpathes = nmake._enter("libpath") + + -- make command + local cmd = nil + if mkfile and os.isfile(mkfile) then + cmd = string.format("%s /f %s %s VERBOSE=%s 2> nul", nmake._NAME, mkfile, target or "", nmake._VERBOSE) + else + cmd = string.format("%s %s VERBOSE=%s 2> nul", nmake._NAME, target or "", nmake._VERBOSE) + end + + -- done + local ok = os.execute(cmd) + + -- leave the vs environment + nmake._leave("path", pathes) + nmake._leave("lib", libs) + nmake._leave("include", includes) + nmake._leave("libpath", libpathes) + + -- ok? + return utils.ifelse(ok == 0, true, false) +end + +-- return module: nmake +return nmake diff --git a/xmake/scripts/platform/windows/prober.lua b/xmake/scripts/platform/windows/prober.lua deleted file mode 100644 index 0eb5d0157..000000000 --- a/xmake/scripts/platform/windows/prober.lua +++ /dev/null @@ -1,203 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see http://www.gnu.org/licenses/ --- --- Copyright (C) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file _prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") - --- define module: _prober -local _prober = _prober or {} - --- probe the architecture -function _prober._probe_arch(configs) - - -- get the architecture - local arch = configs.arch - - -- ok? - if arch then return true end - - -- init the default architecture - configs.arch = xmake._ARCH - - -- ok - return true -end - --- probe the vs version -function _prober._probe_vs_version(configs) - - -- get the vs version - local vs = configs.vs - - -- ok? - if vs then return true end - - -- clear it first - vs = nil - - -- make the map table - local map = - { - VS120COMNTOOLS = "2013" - , VS110COMNTOOLS = "2012" - , VS100COMNTOOLS = "2010" - , VS90COMNTOOLS = "2008" - , VS80COMNTOOLS = "2005" - , VS71COMNTOOLS = "2003" - , VS70COMNTOOLS = "7.0" - , VS60COMNTOOLS = "6.0" - , VS50COMNTOOLS = "5.0" - , VS42COMNTOOLS = "4.2" - } - - -- attempt to get it from the envirnoment variable - if not vs then - for k, v in pairs(map) do - if os.getenv(k) then - vs = v - break - end - end - end - - -- probe ok? update it - if vs then - configs.vs = vs - else - -- failed - utils.error("The Microsoft Visual Studio is unknown now, please config it first!") - utils.error(" - xmake config --vs=xxx") - utils.error("or - xmake global --vs=xxx") - return false - end - - -- ok - return true -end - --- probe the vs path -function _prober._probe_vs_path(configs) - - -- ok? - if configs.__vsenv_path then return true end - - -- get the vs version - local vs = configs.vs - assert(vs) - - -- make the map table - local map = - { - ["2013"] = "VS120COMNTOOLS" - , ["2012"] = "VS110COMNTOOLS" - , ["2010"] = "VS100COMNTOOLS" - , ["2008"] = "VS90COMNTOOLS" - , ["2005"] = "VS80COMNTOOLS" - , ["2003"] = "VS71COMNTOOLS" - , ["7.0"] = "VS70COMNTOOLS" - , ["6.0"] = "VS60COMNTOOLS" - , ["5.0"] = "VS50COMNTOOLS" - , ["4.2"] = "VS42COMNTOOLS" - } - - -- attempt to get the tools directory from the envirnoment variable - local toolsdir = map[vs] - if toolsdir then - toolsdir = os.getenv(toolsdir) - end - - -- the vsvars32.bat path - local vsvars32 = toolsdir .. "\\vsvars32.bat" - if not os.isfile(vsvars32) then - -- error - utils.error("not found %s", vsvars32) - return false - end - - -- get the temporary directory - local tmpdir = os.tmpdir() - assert(tmpdir) - - -- make the call(vsvars32.bat) file - local callpath = tmpdir .. "\\call_vsvars32.bat" - local callfile = io.open(callpath, "w") - assert(callfile) - - -- make call scripts - callfile:write("@echo off\n") - callfile:write(string.format("call \"%s\" > nul\n", vsvars32)) - callfile:write("echo return \n") - callfile:write("echo { \n") - callfile:write("echo path = \"%path%\"\n") - callfile:write("echo , lib = \"%lib%\"\n") - callfile:write("echo , libpath = \"%libpath%\"\n") - callfile:write("echo , include = \"%include%\"\n") - callfile:write("echo , devenvdir = \"%devenvdir%\"\n") - callfile:write("echo , vsinstalldir = \"%vsinstalldir%\"\n") - callfile:write("echo , vcinstalldir = \"%vcinstalldir%\"\n") - callfile:write("echo } \n") - - -- close the file - callfile:close() - - -- execute the call(vsvars32.bat) file and get all envirnoment variables - local cmd = io.popen(callpath) - local results = cmd:read("*all") - cmd:close() - - -- translate '\' => '\\' - results = results:gsub("\\", "\\\\") - - -- get all envirnoment variables - local variables = assert(loadstring(results))() - if not variables or not variables.path then - return false - end - - -- save the variables - for k, v in pairs(variables) do - configs["__vsenv_" .. k] = v - end - - -- ok - return true -end - --- probe the configure -function _prober.done(configs, is_global) - - -- probe the architecture - if not _prober._probe_arch(configs) then return end - - -- probe the vs version - if not _prober._probe_vs_version(configs) then return end - - -- probe the vs path - if not _prober._probe_vs_path(configs) then return end - -end - --- return module: _prober -return _prober diff --git a/xmake/scripts/platform/windows/tools/nmake.lua b/xmake/scripts/platform/windows/tools/nmake.lua deleted file mode 100644 index 6d6b21258..000000000 --- a/xmake/scripts/platform/windows/tools/nmake.lua +++ /dev/null @@ -1,112 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see http://www.gnu.org/licenses/ --- --- Copyright (C) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file nmake.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") - --- define module: nmake -local nmake = nmake or {} - --- enter the given environment -function nmake._enter(name) - - -- check - assert(name) - - -- get the pathes for the vs environment - local old = nil - local new = config.get("__vsenv_" .. name) - if new then - - -- get the current pathes - old = os.getenv(name) or "" - - -- append the current pathes - new = new .. ";" .. old - - -- update the pathes for the environment - os.setenv(name, new) - end - - -- return the previous environment - return old; -end - --- leave the given environment -function nmake._leave(name, old) - - -- check - assert(name) - - -- restore the previous environment - if old then - os.setenv(name, old) - end -end - --- the init function -function nmake.init(name) - - -- save name - nmake._NAME = name or "nmake.exe" - - -- is verbose? - nmake._VERBOSE = utils.ifelse(xmake._OPTIONS.verbose, "-v", "") - -end - --- the main function -function nmake.main(mkfile, target) - - -- enter the vs environment - local pathes = nmake._enter("path") - local libs = nmake._enter("lib") - local includes = nmake._enter("include") - local libpathes = nmake._enter("libpath") - - -- make command - local cmd = nil - if mkfile and os.isfile(mkfile) then - cmd = string.format("%s /f %s %s VERBOSE=%s 2> nul", nmake._NAME, mkfile, target or "", nmake._VERBOSE) - else - cmd = string.format("%s %s VERBOSE=%s 2> nul", nmake._NAME, target or "", nmake._VERBOSE) - end - - -- done - local ok = os.execute(cmd) - - -- leave the vs environment - nmake._leave("path", pathes) - nmake._leave("lib", libs) - nmake._leave("include", includes) - nmake._leave("libpath", libpathes) - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: nmake -return nmake diff --git a/xmake/scripts/platform/windows/windows.lua b/xmake/scripts/platform/windows/windows.lua deleted file mode 100644 index 5a7b48c72..000000000 --- a/xmake/scripts/platform/windows/windows.lua +++ /dev/null @@ -1,87 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see http://www.gnu.org/licenses/ --- --- Copyright (C) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file _windows.lua --- - --- define module: _windows -local _windows = _windows or {} - --- load modules -local config = require("base/config") - --- init host -_windows._HOST = "windows" - --- init architectures -_windows._ARCHS = {"x86", "x64"} - --- make configure -function _windows.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"", ".lib"} - configs.formats.object = {"", ".obj"} - configs.formats.shared = {"", ".dll"} - configs.formats.binary = {"", ".exe"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = "nmake" - - -- init the compiler - configs.compiler = {} - configs.compiler.cc = config.get("cc") or "cl.exe" - configs.compiler.cxx = config.get("cxx") or "cl.exe" - - -- init the linker - configs.linker = {} - configs.linker.binary = config.get("ld") or "link.exe" - configs.linker.static = config.get("ar") or "link.exe" - configs.linker.shared = config.get("sh") or "link.exe" - -end - --- get the option menu for action: xmake config or global -function _windows.menu(action) - - -- init config option menu - _windows._MENU_CONFIG = _windows._MENU_CONFIG or - { {} - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , } - - -- init global option menu - _windows._MENU_GLOBAL = _windows._MENU_GLOBAL or - { {} - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , } - - -- get the option menu - if action == "config" then - return _windows._MENU_CONFIG - elseif action == "global" then - return _windows._MENU_GLOBAL - end -end - - --- return module: _windows -return _windows -- cgit v1.3.1