summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-03 17:16:49 +0800
committerruki <[email protected]>2016-03-03 17:16:49 +0800
commitc617361644a1856ffda5b0201b50f933d1f2f6cb (patch)
tree4a00fa915dd959fd13e8f2614f61f872d1c7f455
parentb331a6e94a0ed82938a626b8aa82d3c8eb6a5199 (diff)
add storage
-rw-r--r--xmake/core/base/io.lua4
-rw-r--r--xmake/core/base/os.lua4
-rw-r--r--xmake/core/base/storage.lua72
-rw-r--r--xmake/core/base/utils.lua4
-rw-r--r--xmake/core/sandbox/modules/os.lua11
5 files changed, 89 insertions, 6 deletions
diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua
index 685b05bf8..14b6e37a3 100644
--- a/xmake/core/base/io.lua
+++ b/xmake/core/base/io.lua
@@ -20,7 +20,7 @@
-- @file io.lua
--
--- define module: io
+-- define module
local io = io or {}
-- load modules
@@ -304,5 +304,5 @@ function io.tail(filepath, linecount)
end
end
--- return module: io
+-- return module
return io
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 78542d72f..46771cb9d 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -20,7 +20,7 @@
-- @file os.lua
--
--- define module: os
+-- define module
local os = os or {}
-- load modules
@@ -248,5 +248,5 @@ function os.raise(msg, ...)
end
--- return module: os
+-- return module
return os
diff --git a/xmake/core/base/storage.lua b/xmake/core/base/storage.lua
new file mode 100644
index 000000000..e633fd43d
--- /dev/null
+++ b/xmake/core/base/storage.lua
@@ -0,0 +1,72 @@
+--!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 storage.lua
+--
+
+-- define module
+local storage = storage or {}
+
+-- load modules
+local os = require("base/os")
+local io = require("base/io")
+local path = require("base/path")
+local utils = require("base/utils")
+
+-- init the storage instance
+--
+-- global: ~/.xmake
+-- output: projectdir/output
+-- project: projectdir/.xmake
+-- temporary: tmpdir/.xmake
+function storage._init(rootdir)
+
+end
+
+-- the global storage instance
+function storage.global()
+
+ -- get it
+ return storage._init(path.translate("~/.xmake"))
+end
+
+-- the output storage instance
+function storage.output()
+
+ -- TODO
+ -- get it
+ return storage._init(path.join(xmake._PROJECT_DIR, "output"))
+end
+
+-- the project storage instance
+function storage.project()
+
+ -- get it
+ return storage._init(path.join(xmake._PROJECT_DIR, ".xmake"))
+end
+
+-- the temporary storage instance
+function storage.temporary()
+
+ -- get it
+ return storage._init(path.join(os.tmpdir(), ".xmake"))
+end
+
+-- return module
+return storage
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua
index 8e6aacd5f..36ff0718c 100644
--- a/xmake/core/base/utils.lua
+++ b/xmake/core/base/utils.lua
@@ -20,7 +20,7 @@
-- @file utils.lua
--
--- define module: utils
+-- define module
local utils = utils or {}
-- load modules
@@ -288,5 +288,5 @@ function utils.call(funcs, pred, ...)
return true
end
--- return module: utils
+-- return module
return utils
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 857ab0cf8..c4903b2c0 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -144,6 +144,17 @@ function sandbox_os.curdir()
return curdir
end
+-- get the temporary directory
+function sandbox_os.tmpdir()
+
+ -- get it
+ local tmpdir = os.tmpdir()
+ assert(tmpdir)
+
+ -- ok
+ return tmpdir
+end
+
-- run shell
function sandbox_os.run(cmd, ...)