summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-30 09:21:58 +0800
committerruki <[email protected]>2016-05-30 09:21:58 +0800
commit23acb023758b0b47cb5083d0d800fc48fc96d920 (patch)
treeec5af9f5185aafb2dd7f7d6d46494f838a602b75 /xmake/core
parent4b86a4104d8076636ffa9a778b244f698aec5a49 (diff)
impl install action
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/base/os.lua8
-rw-r--r--xmake/core/project/package.lua42
-rw-r--r--xmake/core/project/project.lua8
-rw-r--r--xmake/core/project/task.lua3
-rw-r--r--xmake/core/sandbox/modules/import/core/project/package.lua38
5 files changed, 96 insertions, 3 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index bb73b6c43..91dba1524 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -106,7 +106,7 @@ function os.cp(src, dst)
-- the destination is directory? append the filename
if os.isdir(dst) then
- dst = string.format("%s/%s", dst, path.filename(src))
+ dst = path.join(dst, path.filename(src))
end
-- copy file
@@ -115,6 +115,12 @@ function os.cp(src, dst)
end
-- is directory?
elseif os.isdir(src) then
+
+ -- the destination directory exists? append the filename
+ if os.isdir(dst) then
+ dst = path.join(dst, path.filename(path.translate(src)))
+ end
+
-- copy directory
if not os.cpdir(src, dst) then
return false, string.format("cannot copy directory %s to %s %s", src, dst, os.strerror())
diff --git a/xmake/core/project/package.lua b/xmake/core/project/package.lua
new file mode 100644
index 000000000..95828a9d9
--- /dev/null
+++ b/xmake/core/project/package.lua
@@ -0,0 +1,42 @@
+--!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 package.lua
+--
+
+-- define module: package
+local package = package or {}
+
+-- load modules
+local os = require("base/os")
+local io = require("base/io")
+local path = require("base/path")
+local table = require("base/table")
+local utils = require("base/utils")
+local string = require("base/string")
+
+-- the package directory
+function package.directory()
+
+ -- the global directory
+ return path.translate("~/.xmake/packages")
+end
+
+-- return module: package
+return package
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index a76756d08..9d10717f3 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -33,7 +33,9 @@ local filter = require("base/filter")
local interpreter = require("base/interpreter")
local target = require("project/target")
local config = require("project/config")
+local global = require("project/global")
local option = require("project/option")
+local package = require("project/package")
local deprecated_project = require("project/deprecated/project")
local platform = require("platform/platform")
local environment = require("platform/environment")
@@ -489,12 +491,16 @@ function project._interpreter()
os = platform.os()
, host = xmake._HOST
, prefix = "$(prefix)"
+ , tmpdir = os.tmpdir()
+ , curdir = os.curdir()
+ , globaldir = global.directory()
+ , configdir = config.directory()
, projectdir = xmake._PROJECT_DIR
+ , packagedir = package.directory()
}
-- map it
result = maps[variable]
-
end
-- ok?
diff --git a/xmake/core/project/task.lua b/xmake/core/project/task.lua
index dd7eabf2c..a50f4e6e2 100644
--- a/xmake/core/project/task.lua
+++ b/xmake/core/project/task.lua
@@ -34,6 +34,7 @@ local sandbox = require("sandbox/sandbox")
local global = require("project/global")
local config = require("project/config")
local project = require("project/project")
+local package = require("project/package")
-- the directories of tasks
function task._directories()
@@ -194,11 +195,11 @@ function task._interpreter()
, globaldir = global.directory()
, configdir = config.directory()
, projectdir = xmake._PROJECT_DIR
+ , packagedir = package.directory()
}
-- map it
result = maps[variable]
-
end
-- ok?
diff --git a/xmake/core/sandbox/modules/import/core/project/package.lua b/xmake/core/sandbox/modules/import/core/project/package.lua
new file mode 100644
index 000000000..ca8f963b2
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/project/package.lua
@@ -0,0 +1,38 @@
+--!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 package.lua
+--
+
+-- define module
+local sandbox_core_project_package = sandbox_core_project_package or {}
+
+-- load modules
+local package = require("project/package")
+local raise = require("sandbox/modules/raise")
+
+-- run the given package
+function sandbox_core_project_package.directory()
+
+ -- get it
+ return package.directory()
+end
+
+-- return module
+return sandbox_core_project_package