diff options
| author | ruki <[email protected]> | 2016-09-01 17:33:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-09-01 17:33:45 +0800 |
| commit | 314a1cd63b8efe3e3f897cedabc3c73789ff117f (patch) | |
| tree | 2e95e6f3d5b89b9c9ddc671ecc6d3c42e07f7d6f | |
| parent | 3a069cb96018c3074044c26f9a42b9457467a926 (diff) | |
fix script directory interface
| -rw-r--r-- | xmake/core/base/interpreter.lua | 16 |
1 files changed, 13 insertions, 3 deletions
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 |
