diff options
Diffstat (limited to 'xmake/core/base/install.lua')
| -rw-r--r-- | xmake/core/base/install.lua | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/xmake/core/base/install.lua b/xmake/core/base/install.lua index 5da8e55d1..38b2933c8 100644 --- a/xmake/core/base/install.lua +++ b/xmake/core/base/install.lua @@ -30,6 +30,7 @@ local rule = require("base/rule") local path = require("base/path") local utils = require("base/utils") local config = require("base/config") +local sandbox = require("base/sandbox") local platform = require("base/platform") -- install target from the project script @@ -38,19 +39,24 @@ 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 + -- no script? continue + if target.installscript == nil then + return 0 + end - -- remove it - target.installscript = nil + -- get script + local script = target.installscript + target.installscript = nil - -- install it - return installscript(target) + -- install it using the project script first + local ok, results = sandbox.load(script, target) + if not ok then + utils.error(results) + return -1 end - -- continue - return 0 + -- ok? + return results end -- install target from the platform script @@ -59,30 +65,21 @@ 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 + -- no script? continue + local scriptfile = path.join(platform.directory(), "install.lua") + if not os.isfile(scriptfile) then + return 0 end - -- install it - if type(installscript) == "function" then - return installscript(target) + -- the platform install script file + local ok, results = sandbox.load(scriptfile, target) + if not ok then + utils.error(results) + return -1 end - -- continue - return 0 + -- ok? + return results end -- install target from the given target configure |
