summaryrefslogtreecommitdiff
path: root/xmake/scripts/action/_install.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-09-30 15:46:13 +0800
committerruki <[email protected]>2015-09-30 15:46:24 +0800
commit34b6123628ccce51f23207cea7c9c5f025f0a3c1 (patch)
tree37de731493a9af8e30400c9e1946a5d347c1a807 /xmake/scripts/action/_install.lua
parent1f35bb4b02d5cdf16f9a858f8df3d10fcbca94a3 (diff)
fix set_installscript api and add import
Diffstat (limited to 'xmake/scripts/action/_install.lua')
-rw-r--r--xmake/scripts/action/_install.lua54
1 files changed, 53 insertions, 1 deletions
diff --git a/xmake/scripts/action/_install.lua b/xmake/scripts/action/_install.lua
index 300f02f8d..d9aec0b4f 100644
--- a/xmake/scripts/action/_install.lua
+++ b/xmake/scripts/action/_install.lua
@@ -39,6 +39,40 @@ function _install.need(name)
return false
end
+-- make configure for the given target
+function _install._makeconf(configs, target_name, target)
+
+ -- check
+ assert(configs and target_name and target)
+
+ -- init configs for targets
+ configs[target_name] = configs[target_name] or {}
+ local configs_target = configs[target_name]
+
+ -- save the install script
+ local installscript = target.installscript
+ if type(installscript) == "string" and os.isfile(installscript) then
+ local script, errors = loadfile(installscript)
+ if script then
+ installscript = script()
+ if type(installscript) == "table" and installscript.main then
+ installscript = installscript.main
+ end
+ else
+ utils.error(errors)
+ return false
+ end
+ end
+ if target.installscript and type(installscript) ~= "function" then
+ utils.error("invalid package script!")
+ return false
+ end
+ configs_target.installscript = installscript
+
+ -- ok
+ return true
+end
+
-- package target
function _install._package(target_name)
@@ -55,7 +89,6 @@ function _install._package(target_name)
-- ok
return true
end
-
-- done
function _install.done()
@@ -119,6 +152,25 @@ function _install.done()
target.outputdir = options.installdir
end
+ -- the targets
+ local targets = project.targets()
+ assert(targets)
+
+ -- make configure for the given target
+ if target_name and target_name ~= "all" then
+ if not _install._makeconf(configs, target_name, targets[target_name]) then
+ utils.error("make target configure: %s failed!", target_name)
+ return false
+ end
+ else
+ for target_name, target in pairs(targets) do
+ if not _install._makeconf(configs, target_name, target) then
+ utils.error("make target configure: %s failed!", target_name)
+ return false
+ end
+ end
+ end
+
-- done install
if not install.done(configs) then
-- errors