diff options
| author | ruki <[email protected]> | 2015-07-10 16:59:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-07-10 16:59:16 +0800 |
| commit | e2b2d08d459dc0c3459befb443c9c76520bcf61d (patch) | |
| tree | 5a031da80823f8aade87c7d9896170d6202310c0 /xmake/scripts | |
| parent | ebd3cf08de2fea05bbf32d095f5a5c5a3c38a4f1 (diff) | |
add install for macosx
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/action/_install.lua | 29 | ||||
| -rw-r--r-- | xmake/scripts/action/_package.lua | 16 | ||||
| -rw-r--r-- | xmake/scripts/base/install.lua | 84 | ||||
| -rw-r--r-- | xmake/scripts/base/package.lua | 26 | ||||
| -rw-r--r-- | xmake/scripts/base/project.lua | 3 | ||||
| -rw-r--r-- | xmake/scripts/platform/macosx/install.lua | 77 |
6 files changed, 211 insertions, 24 deletions
diff --git a/xmake/scripts/action/_install.lua b/xmake/scripts/action/_install.lua index 5223da678..b7e392bb3 100644 --- a/xmake/scripts/action/_install.lua +++ b/xmake/scripts/action/_install.lua @@ -29,6 +29,7 @@ local config = require("base/config") local global = require("base/global") local install = require("base/install") local package = require("base/package") +local project = require("base/project") local platform = require("platform/platform") -- need access to the given file? @@ -91,6 +92,33 @@ function _install.done() return false end + -- reload configure + local errors = config.reload() + if errors then + -- error + utils.error(errors) + return false + end + + -- make the platform configure + if not platform.make() then + utils.error("make platform configure: %s failed!", config.get("plat")) + return false + end + + -- reload project + local errors = project.reload() + if errors then + -- error + utils.error(errors) + return false + end + + -- update the outputdir + for _, target in pairs(configs) do + target.outputdir = options.installdir + end + -- done package if not install.done(configs) then -- errors @@ -127,6 +155,7 @@ function _install.menu() , " 1. The Given Command Argument" , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR" , " 3. The Current Directory" } + , {'o', "installdir", "kv", nil, "Set the install directory." } , {} , {'v', "verbose", "k", nil, "Print lots of verbose information." } diff --git a/xmake/scripts/action/_package.lua b/xmake/scripts/action/_package.lua index 1860b931b..e39604a33 100644 --- a/xmake/scripts/action/_package.lua +++ b/xmake/scripts/action/_package.lua @@ -150,24 +150,24 @@ function _package._makeconf(target_name, target) configs_arch.targetfile = _package._backup(configs_arch.targetdir, rule.targetfile(target_name, target)) -- save the package script - local pkgscript = target.pkgscript - if type(pkgscript) == "string" and os.isfile(pkgscript) then - local script, errors = loadfile(pkgscript) + local packagescript = target.packagescript + if type(packagescript) == "string" and os.isfile(packagescript) then + local script, errors = loadfile(packagescript) if script then - pkgscript = script() - if type(pkgscript) == "table" and pkgscript.main then - pkgscript = pkgscript.main + packagescript = script() + if type(packagescript) == "table" and packagescript.main then + packagescript = packagescript.main end else utils.error(errors) return false end end - if target.pkgscript and type(pkgscript) ~= "function" then + if target.packagescript and type(packagescript) ~= "function" then utils.error("invalid package script!") return false end - configs_target.pkgscript = pkgscript + configs_target.packagescript = packagescript -- ok return true diff --git a/xmake/scripts/base/install.lua b/xmake/scripts/base/install.lua index f0ccd92af..4f4eef18f 100644 --- a/xmake/scripts/base/install.lua +++ b/xmake/scripts/base/install.lua @@ -32,14 +32,94 @@ local utils = require("base/utils") local config = require("base/config") local platform = require("platform/platform") +-- install target from the project script +function install._done_from_project(target) + + -- check + assert(target) + + -- install it using the project script first + local installscript = target.installscript + if type(installscript) == "function" then + + -- remove it + target.installscript = nil + + -- install it + return installscript(target) + end + + -- continue + return 0 +end + +-- install target from the platform script +function install._done_from_platform(target) + + -- check + assert(target) + + -- the platform install script file + local installscript = nil + local scriptfile = platform.directory() .. "/install.lua" + if os.isfile(scriptfile) then + + -- load the install script + local script, errors = loadfile(scriptfile) + if script then + installscript = script() + if type(installscript) == "table" and installscript.main then + installscript = installscript.main + end + else + utils.error(errors) + end + end + + -- install it + if type(installscript) == "function" then + return installscript(target) + end + + -- continue + return 0 +end + +-- install target from the given target configure +function install._done(target) + + -- check + assert(target) + + -- install it from the project script + local ok = install._done_from_project(target) + if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end + + -- install it from the platform script + local ok = install._done_from_platform(target) + if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end + + -- ok + return true +end + -- done install from the configure function install.done(configs) -- check assert(configs) - -- dump - utils.dump(configs) + -- install targets + for _, target in pairs(configs) do + + -- install it + if not install._done(target) then + -- errors + utils.error("install %s failed!", target.name) + return false + end + + end -- ok return true diff --git a/xmake/scripts/base/package.lua b/xmake/scripts/base/package.lua index 32f1ef759..12565e8c1 100644 --- a/xmake/scripts/base/package.lua +++ b/xmake/scripts/base/package.lua @@ -184,7 +184,7 @@ function package._done_from_default(target) assert(target.kind) -- the package scripts - local pkgscripts = + local packagescripts = { static = package._done_library , shared = package._done_library @@ -192,8 +192,8 @@ function package._done_from_default(target) } -- package it - local pkgscript = pkgscripts[target.kind] - if pkgscript then return pkgscript(target) end + local packagescript = packagescripts[target.kind] + if packagescript then return packagescript(target) end -- continue return 0 @@ -206,14 +206,14 @@ function package._done_from_project(target) assert(target) -- package it using the project script first - local pkgscript = target.pkgscript - if type(pkgscript) == "function" then + local packagescript = target.packagescript + if type(packagescript) == "function" then -- remove it - target.pkgscript = nil + target.packagescript = nil -- package it - return pkgscript(target) + return packagescript(target) end -- continue @@ -227,16 +227,16 @@ function package._done_from_platform(target) assert(target) -- the platform package script file - local pkgscript = nil + local packagescript = nil local scriptfile = platform.directory() .. "/package.lua" if os.isfile(scriptfile) then -- load the package script local script, errors = loadfile(scriptfile) if script then - pkgscript = script() - if type(pkgscript) == "table" and pkgscript.main then - pkgscript = pkgscript.main + packagescript = script() + if type(packagescript) == "table" and packagescript.main then + packagescript = packagescript.main end else utils.error(errors) @@ -244,8 +244,8 @@ function package._done_from_platform(target) end -- package it - if type(pkgscript) == "function" then - return pkgscript(target) + if type(packagescript) == "function" then + return packagescript(target) end -- continue diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index 5df41cfe5..1cd8b5f25 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -1088,7 +1088,8 @@ function project._load_targets(file) , "warnings" , "optimize" , "languages" - , "pkgscript"} + , "installscript" + , "packagescript"} for _, interface in ipairs(interfaces) do newenv["set_" .. interface] = function (...) return project._api_set_values(newenv._TARGET or newenv._CONFIGS._SET, interface, ...) end diff --git a/xmake/scripts/platform/macosx/install.lua b/xmake/scripts/platform/macosx/install.lua new file mode 100644 index 000000000..0f8b981eb --- /dev/null +++ b/xmake/scripts/platform/macosx/install.lua @@ -0,0 +1,77 @@ +--!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 path = require("base/path") +local rule = require("base/rule") +local utils = require("base/utils") +local string = require("base/string") +local platform = require("platform/platform") + +-- install target for the library file +function install._done_library(target) + + -- dump + utils.dump(target) + + -- ok + return 1 +end + +-- install target for the binary file +function install._done_binary(target) + + -- dump + utils.dump(target) + + -- ok + return 1 +end + +-- install target +function install.main(target) + + -- check + assert(target and target.kind) + + -- the install scripts + local installscripts = + { + static = install._done_library + , shared = install._done_library + , binary = install._done_binary + } + + -- install it + local installscript = installscripts[target.kind] + if installscript then return installscript(target) end + + -- continue + return 0 +end + +-- return module: install +return install |
