diff options
| author | ruki <[email protected]> | 2018-12-15 00:41:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-12-14 22:09:54 +0800 |
| commit | 95f46b973794b37ccd62edbcc3bfb010b0f23dcc (patch) | |
| tree | abbd878e0e78c0511c7da072ad43b70f03eeea47 /xmake/core/base | |
| parent | 107f81a48da61d37ecbffac4e2f816b9cfedb21c (diff) | |
improve interpreter
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/interpreter.lua | 17 | ||||
| -rw-r--r-- | xmake/core/base/task.lua | 10 |
2 files changed, 16 insertions, 11 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 9c2d35450..d45640064 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -662,8 +662,8 @@ function interpreter.new() return instance end --- load results -function interpreter:load(file, scope_kind, remove_repeat, enable_filter) +-- load script file, e.g. xmake.lua +function interpreter:load(file) -- check assert(self and self._PUBLIC and self._PRIVATE and file) @@ -691,18 +691,17 @@ function interpreter:load(file, scope_kind, remove_repeat, enable_filter) setfenv(script, self._PUBLIC) -- do interpreter - local ok, errors = xpcall(script, interpreter._traceback) - if not ok then - return nil, errors - end + return xpcall(script, interpreter._traceback) +end - -- make results +-- make results +function interpreter:make(scope_kind, remove_repeat, enable_filter) + + -- get the results with the given scope local ok, results = xpcall(interpreter._make, interpreter._traceback, self, scope_kind, remove_repeat, enable_filter) if not ok then return nil, results end - - -- ok return results end diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index b2b5b25a0..d42609756 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -317,9 +317,15 @@ function task._load(filepath) local interp = task._interpreter() assert(interp) + -- load script + local ok, errors = interp:load(filepath) + if not ok and os.isfile(filepath) then + return nil, errors + end + -- load tasks - local tasks, errors = interp:load(filepath, "task", true, true) - if not tasks and os.isfile(filepath) then + local tasks, errors = interp:make("task", true, true) + if not tasks then return nil, errors end |
