diff options
| author | ruki <[email protected]> | 2015-07-10 15:00:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-07-10 15:00:20 +0800 |
| commit | ebd3cf08de2fea05bbf32d095f5a5c5a3c38a4f1 (patch) | |
| tree | bcca6719ce4572f6c6d668de49ea33524bfeb8ab /xmake/scripts | |
| parent | 6381c698b6f253b2ae19330d0363213dd904fe26 (diff) | |
add install interfaces
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/action/_install.lua | 75 | ||||
| -rw-r--r-- | xmake/scripts/action/_package.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/base/install.lua | 49 | ||||
| -rw-r--r-- | xmake/scripts/base/package.lua | 19 |
4 files changed, 139 insertions, 8 deletions
diff --git a/xmake/scripts/action/_install.lua b/xmake/scripts/action/_install.lua index 41d59e483..5223da678 100644 --- a/xmake/scripts/action/_install.lua +++ b/xmake/scripts/action/_install.lua @@ -26,14 +26,81 @@ local _install = _install or {} -- load modules local utils = require("base/utils") local config = require("base/config") +local global = require("base/global") +local install = require("base/install") +local package = require("base/package") local platform = require("platform/platform") - + +-- need access to the given file? +function _install.need(name) + + -- no accessors + return false +end + +-- package target +function _install._package(target_name) + + -- get the target name + if not target_name or target_name == "all" then + target_name = "" + end + + -- package it + if os.execute(string.format("xmake p -P %s -f %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, target_name)) ~= 0 then + return false + end + + -- ok + return true +end + + -- done function _install.done() - -- TODO - print("not implement!") - + -- the options + local options = xmake._OPTIONS + assert(options) + + -- trace + print("install: ...") + + -- load the global configure first + global.load() + + -- enter the project directory + if not os.cd(xmake._PROJECT_DIR) then + -- errors + utils.error("not found project: %s!", xmake._PROJECT_DIR) + return false + end + + -- package the given target first + if not _install._package(options.target) then + -- errors + utils.error("package: failed!") + return false + end + + -- load the package configure + local configs, errors = package.load() + if not configs then + -- errors + utils.error(errors) + return false + end + + -- done package + if not install.done(configs) then + -- errors + utils.error("install: failed!") + return false + end + + -- trace + print("install: ok!") + -- ok return true end diff --git a/xmake/scripts/action/_package.lua b/xmake/scripts/action/_package.lua index 18d7d5024..1860b931b 100644 --- a/xmake/scripts/action/_package.lua +++ b/xmake/scripts/action/_package.lua @@ -62,8 +62,8 @@ function _package._build(arch, target_name) -- configure it first if not _package._config(arch, target_name) then return false end - -- rebuild it - if os.execute(string.format("xmake -r -P %s %s", xmake._PROJECT_DIR, target_name)) ~= 0 then + -- build it + if os.execute(string.format("xmake -P %s %s", xmake._PROJECT_DIR, target_name)) ~= 0 then -- errors utils.error("build failed!") return false diff --git a/xmake/scripts/base/install.lua b/xmake/scripts/base/install.lua new file mode 100644 index 000000000..f0ccd92af --- /dev/null +++ b/xmake/scripts/base/install.lua @@ -0,0 +1,49 @@ +--!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) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file install.lua +-- + +-- define module: install +local install = install or {} + +-- load modules +local os = require("base/os") +local io = require("base/io") +local rule = require("base/rule") +local path = require("base/path") +local utils = require("base/utils") +local config = require("base/config") +local platform = require("platform/platform") + +-- done install from the configure +function install.done(configs) + + -- check + assert(configs) + + -- dump + utils.dump(configs) + + -- ok + return true +end + +-- return module: install +return install diff --git a/xmake/scripts/base/package.lua b/xmake/scripts/base/package.lua index 412f3b8c4..32f1ef759 100644 --- a/xmake/scripts/base/package.lua +++ b/xmake/scripts/base/package.lua @@ -25,6 +25,7 @@ local package = package or {} -- load modules local os = require("base/os") +local io = require("base/io") local rule = require("base/rule") local path = require("base/path") local utils = require("base/utils") @@ -251,6 +252,13 @@ function package._done_from_platform(target) return 0 end +-- get the configure file +function package._file() + + -- get it + return config.directory() .. "/package.conf" +end + -- package target from the given target configure function package._done(target) @@ -291,8 +299,15 @@ function package.done(configs) end - -- ok - return true + -- save to the configure file + return io.save(package._file(), configs) +end + +-- load the package configure +function package.load() + + -- load it + return io.load(package._file()) end -- return module: package |
