summaryrefslogtreecommitdiff
path: root/xmake/core/base/interpreter.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-03 10:18:09 +0800
committerruki <[email protected]>2016-05-03 10:18:09 +0800
commit33cd1abcf4aa733ac68f619dac0183f547d787c3 (patch)
tree2c8f669eb26b8484654aa39efeea26d9ec84282f /xmake/core/base/interpreter.lua
parent6acc7c9d410f46d804a8f278badf14e7e99ea1be (diff)
fix find tool bug
Diffstat (limited to 'xmake/core/base/interpreter.lua')
-rw-r--r--xmake/core/base/interpreter.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 47b4d02a7..066acf5d9 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -756,6 +756,54 @@ function interpreter:api_register_on_script(scope_kind, prefix, ...)
self:_api_register_xxx_values(scope_kind, "on", prefix, implementation, ...)
end
+-- register api for before_script
+function interpreter:api_register_before_script(scope_kind, prefix, ...)
+
+ -- check
+ assert(self)
+
+ -- define implementation
+ local implementation = function (self, scope, name, script)
+
+ -- make sandbox instance with the given script
+ local instance, errors = sandbox.new(script, self:filter(), self:rootdir())
+ if not instance then
+ os.raise("before_%s(): %s", name, errors)
+ end
+
+ -- update script?
+ scope[name] = {}
+ table.insert(scope[name], instance:script())
+ end
+
+ -- register implementation
+ self:_api_register_xxx_values(scope_kind, "before", prefix, implementation, ...)
+end
+
+-- register api for after_script
+function interpreter:api_register_after_script(scope_kind, prefix, ...)
+
+ -- check
+ assert(self)
+
+ -- define implementation
+ local implementation = function (self, scope, name, script)
+
+ -- make sandbox instance with the given script
+ local instance, errors = sandbox.new(script, self:filter(), self:rootdir())
+ if not instance then
+ os.raise("after_%s(): %s", name, errors)
+ end
+
+ -- update script?
+ scope[name] = {}
+ table.insert(scope[name], instance:script())
+ end
+
+ -- register implementation
+ self:_api_register_xxx_values(scope_kind, "after", prefix, implementation, ...)
+end
+
-- register api for set_keyvalues
function interpreter:api_register_set_keyvalues(scope_kind, prefix, ...)