summaryrefslogtreecommitdiff
path: root/xmake/core/platform/environment.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-11 11:23:10 +0800
committerruki <[email protected]>2016-05-11 11:23:10 +0800
commit4b32ac0799e14663522b8b6c42c4343041342183 (patch)
tree72e71305480ff2717a6abc7794b759b936d708ee /xmake/core/platform/environment.lua
parente89130661686f0f3faf4ac87c989865b5fcc4823 (diff)
add environment
Diffstat (limited to 'xmake/core/platform/environment.lua')
-rw-r--r--xmake/core/platform/environment.lua79
1 files changed, 79 insertions, 0 deletions
diff --git a/xmake/core/platform/environment.lua b/xmake/core/platform/environment.lua
new file mode 100644
index 000000000..8c8569674
--- /dev/null
+++ b/xmake/core/platform/environment.lua
@@ -0,0 +1,79 @@
+--!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 <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file environment.lua
+--
+
+-- define module
+local environment = environment or {}
+
+-- load modules
+local platform = require("platform/platform")
+
+-- load the given environment from the given platform
+function environment.load(plat)
+
+ -- load platform
+ local instance, errors = platform.load(plat)
+ if not instance then
+ return nil, errors
+ end
+
+ -- get environment
+ return instance:environment()
+end
+
+-- enter the environment for the current platform
+function environment.enter(name)
+
+ -- load the environment module
+ local module, errors = environment.load(plat)
+ if not module and errors then
+ return false, errors
+ end
+
+ -- enter it
+ if module then
+ module.enter(name)
+ end
+
+ -- ok
+ return true
+end
+
+-- leave the environment for the current platform
+function environment.leave(name)
+
+ -- load the environment module
+ local module, errors = environment.load(plat)
+ if not module and errors then
+ return false, errors
+ end
+
+ -- leave it
+ if module then
+ module.leave(name)
+ end
+
+ -- ok
+ return true
+end
+
+-- return module
+return environment