summaryrefslogtreecommitdiff
path: root/xmake/scripts/platform/windows/windows.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-12 12:30:56 +0800
committerruki <[email protected]>2015-06-12 12:30:56 +0800
commit99b9eb72c8db9854311fc0b5a79e07f8cae85242 (patch)
tree837868dffc057d9a987ac4dc0592d98b015563c2 /xmake/scripts/platform/windows/windows.lua
parent1678ef146c122b8a38a4485262f43b816230aa0f (diff)
modify platform and probe toolchains
Diffstat (limited to 'xmake/scripts/platform/windows/windows.lua')
-rw-r--r--xmake/scripts/platform/windows/windows.lua77
1 files changed, 68 insertions, 9 deletions
diff --git a/xmake/scripts/platform/windows/windows.lua b/xmake/scripts/platform/windows/windows.lua
index a3d80c49a..573699d9a 100644
--- a/xmake/scripts/platform/windows/windows.lua
+++ b/xmake/scripts/platform/windows/windows.lua
@@ -24,14 +24,73 @@
local windows = windows or {}
-- load modules
+local os = require("base/os")
local config = require("base/config")
-- init host
-windows._HOST = "windows"
+windows._HOST = "windows"
-- init architectures
-windows._ARCHS = {"x86", "x64"}
+windows._ARCHS = {"x86", "x64"}
+-- enter the given environment
+function windows._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 windows._leave(name, old)
+
+ -- check
+ assert(name)
+
+ -- restore the previous environment
+ if old then
+ os.setenv(name, old)
+ end
+end
+
+-- enter environment
+function windows.enter()
+
+ -- enter the vs environment
+ windows._pathes = windows._enter("path")
+ windows._libs = windows._enter("lib")
+ windows._includes = windows._enter("include")
+ windows._libpathes = windows._enter("libpath")
+
+end
+
+-- leave environment
+function windows.leave()
+
+ -- leave the vs environment
+ windows._leave("path", windows._pathes)
+ windows._leave("lib", windows._libs)
+ windows._leave("include", windows._includes)
+ windows._leave("libpath", windows._libpathes)
+
+end
-- make configure
function windows.make(configs)
@@ -43,13 +102,13 @@ function windows.make(configs)
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"
+ configs.tools = {}
+ configs.tools.make = config.get("make")
+ configs.tools.cc = config.get("cc")
+ configs.tools.cxx = config.get("cxx")
+ configs.tools.ld = config.get("ld")
+ configs.tools.ar = config.get("ar")
+ configs.tools.sh = config.get("sh")
end