From 314a1cd63b8efe3e3f897cedabc3c73789ff117f Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 1 Sep 2016 17:33:45 +0800 Subject: fix script directory interface --- xmake/core/base/interpreter.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'xmake/core/base/interpreter.lua') diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 75700e201..35acb59ef 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -617,6 +617,16 @@ function interpreter:rootdir_set(rootdir) self._PRIVATE._ROOTDIR = rootdir end +-- get script directory +function interpreter:scriptdir() + + -- check + assert(self and self._PRIVATE and self._PRIVATE._CURFILE) + + -- get it + return path.directory(self._PRIVATE._CURFILE) +end + -- set root scope kind -- -- the root api will affect these scopes @@ -882,7 +892,7 @@ function interpreter:api_register_on_script(scope_kind, ...) local implementation = function (self, scope, name, script) -- make sandbox instance with the given script - local instance, errors = sandbox.new(script, self:filter(), self:rootdir()) + local instance, errors = sandbox.new(script, self:filter(), self:scriptdir()) if not instance then os.raise("on_%s(): %s", name, errors) end @@ -905,7 +915,7 @@ function interpreter:api_register_before_script(scope_kind, ...) local implementation = function (self, scope, name, script) -- make sandbox instance with the given script - local instance, errors = sandbox.new(script, self:filter(), self:rootdir()) + local instance, errors = sandbox.new(script, self:filter(), self:scriptdir()) if not instance then os.raise("before_%s(): %s", name, errors) end @@ -928,7 +938,7 @@ function interpreter:api_register_after_script(scope_kind, ...) local implementation = function (self, scope, name, script) -- make sandbox instance with the given script - local instance, errors = sandbox.new(script, self:filter(), self:rootdir()) + local instance, errors = sandbox.new(script, self:filter(), self:scriptdir()) if not instance then os.raise("after_%s(): %s", name, errors) end -- cgit v1.3.1