diff options
| author | ruki <[email protected]> | 2015-06-26 11:35:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-26 11:35:29 +0800 |
| commit | 37247cc86d31c6134deca9819f9ffe8cfe253797 (patch) | |
| tree | 7787052bb60bfa86bab771513ef7015d9b7c8660 /xmake/scripts | |
| parent | cd530f704a361fecba459bc8e3dc27cb1c6522c8 (diff) | |
set package script to project
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/action/_package.lua | 42 | ||||
| -rw-r--r-- | xmake/scripts/base/package.lua | 30 | ||||
| -rw-r--r-- | xmake/scripts/base/project.lua | 3 |
3 files changed, 53 insertions, 22 deletions
diff --git a/xmake/scripts/action/_package.lua b/xmake/scripts/action/_package.lua index fcaa658d6..590d071bc 100644 --- a/xmake/scripts/action/_package.lua +++ b/xmake/scripts/action/_package.lua @@ -118,16 +118,16 @@ function _package._makeconf(target_name, target) if not arch then return false end -- init configs for targets - configs._TARGETS = configs._TARGETS or {} - configs._TARGETS[target_name] = configs._TARGETS[target_name] or {} - local configs_target = configs._TARGETS[target_name] + configs[target_name] = configs[target_name] or {} + local configs_target = configs[target_name] - -- init configs for architecture - configs_target[arch] = configs_target[arch] or {} - local configs_arch = configs_target[arch] + -- init configs for kinds + configs_target[target.kind] = configs_target[target.kind] or {} + local configs_kind = configs_target[target.kind] - -- save the target kind - configs_arch.kind = target.kind + -- init configs for architecture + configs_kind[arch] = configs_kind[arch] or {} + local configs_arch = configs_kind[arch] -- save the root directory configs_arch.rootdir = rule.packagedir(target_name, arch) @@ -147,6 +147,22 @@ function _package._makeconf(target_name, target) -- save the header directory configs_arch.headerdir = target.headerdir + -- save the package script + configs_arch.pkgscript = target.pkgscript + if type(configs_arch.pkgscript) == "string" and os.isfile(configs_arch.pkgscript) then + local script, errors = loadfile(configs_arch.pkgscript) + if script then + configs_arch.pkgscript = script() + else + utils.error(errors) + return false + end + end + if target.pkgscript and type(configs_arch.pkgscript) ~= "function" then + utils.error("invalid package script!") + return false + end + -- ok return true end @@ -269,16 +285,6 @@ function _package.done() return false end - -- save platform - configs.plat = config.get("plat") - assert(configs.plat) - - -- save build directory - configs.buildir = config.get("buildir") - - -- save project directory - configs.projectdir = xmake._PROJECT_DIR - -- done package if not package.done(configs) then -- errors diff --git a/xmake/scripts/base/package.lua b/xmake/scripts/base/package.lua index d07f6590a..d2018573d 100644 --- a/xmake/scripts/base/package.lua +++ b/xmake/scripts/base/package.lua @@ -27,6 +27,21 @@ local package = package or {} local os = require("base/os") local path = require("base/path") local utils = require("base/utils") +local config = require("base/config") +local platform = require("platform/platform") + +-- package info from the given info configure +function package._done_target(name, info) + + -- check + assert(name and info) + + -- dump + utils.dump(info) + + -- ok + return true +end -- done package from the configure function package.done(configs) @@ -34,9 +49,18 @@ function package.done(configs) -- check assert(configs) - -- dump - utils.dump(configs) - + -- package targets + for name, info in pairs(configs) do + + -- package it + if not package._done_target(name, info) then + -- errors + utils.error("package %s failed!", name) + return false + end + + end + -- ok return true end diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index c5052dd19..b424c8988 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -1061,7 +1061,8 @@ function project._load_targets(file) , "symbols" , "warnings" , "optimize" - , "languages"} + , "languages" + , "pkgscript"} for _, interface in ipairs(interfaces) do newenv["set_" .. interface] = function (...) return project._api_set_values(newenv._TARGET or newenv._CONFIGS._SET, interface, ...) end |
