summaryrefslogtreecommitdiff
path: root/xmake/scripts/base/install.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-07-10 16:59:16 +0800
committerruki <[email protected]>2015-07-10 16:59:16 +0800
commite2b2d08d459dc0c3459befb443c9c76520bcf61d (patch)
tree5a031da80823f8aade87c7d9896170d6202310c0 /xmake/scripts/base/install.lua
parentebd3cf08de2fea05bbf32d095f5a5c5a3c38a4f1 (diff)
add install for macosx
Diffstat (limited to 'xmake/scripts/base/install.lua')
-rw-r--r--xmake/scripts/base/install.lua84
1 files changed, 82 insertions, 2 deletions
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