summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-09-01 18:36:17 +0800
committerruki <[email protected]>2016-09-01 18:36:17 +0800
commiteb7401f0cf3d3039f3670c86ad05acbc7c042c39 (patch)
treebadb6faeee2a90147c49e6ba638e1b8f20421867
parent314a1cd63b8efe3e3f897cedabc3c73789ff117f (diff)
bind sandbox for project task
-rw-r--r--xmake/core/project/project.lua4
-rw-r--r--xmake/core/project/task.lua21
2 files changed, 19 insertions, 6 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 7d8b0fecc..3d5abb485 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -622,7 +622,7 @@ function project.tasks()
-- the project file is not found?
if not os.isfile(xmake._PROJECT_FILE) then
- return {}
+ return {}, nil
end
-- load the tasks from the the project file
@@ -632,7 +632,7 @@ function project.tasks()
end
-- ok?
- return results
+ return results, interp
end
-- get the mtimes
diff --git a/xmake/core/project/task.lua b/xmake/core/project/task.lua
index 1c513439e..b94685066 100644
--- a/xmake/core/project/task.lua
+++ b/xmake/core/project/task.lua
@@ -214,13 +214,13 @@ function task._interpreter()
end
-- bind tasks for menu with an sandbox instance
-function task._bind(tasks)
+function task._bind(tasks, interp)
-- check
assert(tasks)
-- get interpreter
- local interp = task._interpreter()
+ interp = interp or task._interpreter()
assert(interp)
-- bind sandbox for menus
@@ -306,14 +306,14 @@ function task._load(filepath)
local tasks, errors = interp:load(filepath, "task", true, true)
if not tasks and os.isfile(filepath) then
-- trace
- utils.error(errors)
+ os.raise(errors)
end
-- bind tasks for menu with an sandbox instance
local ok, errors = task._bind(tasks)
if not ok then
-- trace
- utils.error(errors)
+ os.raise(errors)
return
end
@@ -353,6 +353,19 @@ function task.tasks()
-- merge project tasks if exists
local projectasks, errors = project.tasks()
if projectasks then
+
+ -- the project interpreter
+ local interp = errors
+
+ -- bind tasks for menu with an sandbox instance
+ local ok, errors = task._bind(projectasks, interp)
+ if not ok then
+ -- trace
+ os.raise(errors)
+ return
+ end
+
+ -- save tasks
for taskname, taskinfo in pairs(projectasks) do
if tasks[taskname] == nil then
tasks[taskname] = taskinfo