diff options
| author | ruki <[email protected]> | 2016-03-04 11:46:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-03-04 11:46:59 +0800 |
| commit | e355270ef136ec6b559a6477b218b077f502a05b (patch) | |
| tree | 0f8f5276aea1f256b6d219eff6689009f7157005 | |
| parent | ca29fd0cc42da28c3ded41973ca5cc5b1c3e7ff9 (diff) | |
add global and config modules for sandbox
| -rwxr-xr-x | xmake/actions/global/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/base/task.lua | 3 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/config.lua | 93 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/global.lua | 57 |
4 files changed, 154 insertions, 1 deletions
diff --git a/xmake/actions/global/xmake.lua b/xmake/actions/global/xmake.lua index 24bd90fb2..b74d07315 100755 --- a/xmake/actions/global/xmake.lua +++ b/xmake/actions/global/xmake.lua @@ -30,7 +30,7 @@ task("global") on_task_run(function () printf("$(tmpdir)") - printf("$(buildir)") + printf("$(curdir)") printf("$(configdir)") printf("$(globaldir)") printf("$(projectdir)") diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index 69886339f..873215660 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -83,9 +83,12 @@ function task._interpreter() { host = xmake._HOST , tmpdir = os.tmpdir() + , curdir = os.curdir() , globaldir = global.directory() , configdir = config.directory() , projectdir = xmake._PROJECT_DIR + -- TODO + -- buildir } -- map it diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua new file mode 100644 index 000000000..6fb601961 --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -0,0 +1,93 @@ +--!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 config.lua +-- + +-- define module +local sandbox_core_project_config = sandbox_core_project_config or {} + +-- load modules +local rule = require("project/rule") +local config = require("project/config") +local project = require("project/project") + +-- get the build directory +function sandbox_core_project_config.buildir() + + -- get it + return config.get("buildir") +end + +-- get the project directory +function sandbox_core_project_config.projectdir() + + -- get it + return xmake._PROJECT_DIR +end + +-- get the current platform +function sandbox_core_project_config.plat() + + -- get it + return config.get("plat") +end + +-- get the current architecture +function sandbox_core_project_config.arch() + + -- get it + return config.get("arch") +end + +-- get the current mode +function sandbox_core_project_config.mode() + + -- get it + return config.get("mode") +end + +-- get the configure directory +function sandbox_core_project_global.directory() + + -- get it + local dir = config.directory() + assert(dir) + + -- ok? + return dir +end + +-- get the given configure from the current +function sandbox_core_project_config.get(name) + + -- get it + return config.get(name) +end + +-- set the given configure to the current +function sandbox_core_project_config.set(name, value) + + -- set it + return config.set(name, value) +end + + +-- return module +return sandbox_core_project_config diff --git a/xmake/core/sandbox/modules/import/core/project/global.lua b/xmake/core/sandbox/modules/import/core/project/global.lua new file mode 100644 index 000000000..210df52a3 --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/project/global.lua @@ -0,0 +1,57 @@ +--!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 global.lua +-- + +-- define module +local sandbox_core_project_global = sandbox_core_project_global or {} + +-- load modules +local global = require("project/global") +local raise = require("sandbox/modules/raise") + +-- get the configure +function sandbox_core_project_global.get(name) + + -- get it + return global.get(name) +end + +-- set the configure +function sandbox_core_project_global.set(name, value) + + -- set it + global.set(name, value) +end + +-- get the configure directory +function sandbox_core_project_global.directory() + + -- get it + local dir = global.directory() + assert(dir) + + -- ok? + return dir +end + + +-- return module +return sandbox_core_project_global |
