summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-01 23:41:55 +0800
committerruki <[email protected]>2016-03-01 23:41:55 +0800
commitef399ea6c252456e3f0ccb125412ced6d7735377 (patch)
tree5f6aa9aab1992ff323b60bfc31e16dfbcb245e3c
parent33cf83635ed21a2e39f09f2a28dceaf6f6abd5cd (diff)
import module name for task
-rwxr-xr-xxmake/actions/config/main.lua11
-rwxr-xr-xxmake/actions/config/test.lua36
-rwxr-xr-xxmake/actions/config/xmake.lua12
-rw-r--r--xmake/core/base/sandbox.lua11
4 files changed, 52 insertions, 18 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 19686aa4f..68f100cc2 100755
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -20,18 +20,21 @@
-- @file main.lua
--
+import("test")
import("core")
import("core.project")
print("global")
print(project)
print(core.project)
+print("test", test)
-function test()
+function hello()
- print("test")
+ print("hello")
print(project)
print(core.project)
+ test.test2()
end
function main()
@@ -40,7 +43,7 @@ function main()
print(project)
print(core.project)
- -- test
- test()
+ -- hello
+ hello()
end
diff --git a/xmake/actions/config/test.lua b/xmake/actions/config/test.lua
new file mode 100755
index 000000000..1c02385eb
--- /dev/null
+++ b/xmake/actions/config/test.lua
@@ -0,0 +1,36 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file test.lua
+--
+
+import("core")
+import("core.project")
+
+print("global")
+print(project)
+print(core.project)
+
+function test2()
+
+ print("test2")
+ print(project)
+ print(core.project)
+end
+
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index effe5d3d7..9efde3222 100755
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -27,17 +27,7 @@ task("config")
set_task_category("action")
-- on run
- on_task_run(function ()
-
- import("main")
- import("core.project")
-
- print(main)
- print(main.print)
- print(project)
- print(main.main())
-
- end)
+ on_task_run("main")
-- set menu
set_task_menu({
diff --git a/xmake/core/base/sandbox.lua b/xmake/core/base/sandbox.lua
index 252241e2f..3c4d1aceb 100644
--- a/xmake/core/base/sandbox.lua
+++ b/xmake/core/base/sandbox.lua
@@ -159,11 +159,16 @@ function sandbox.make(script, interp)
-- save root directory
self._PRIVATE._ROOTDIR = interp:rootdir()
- -- this script is file? load it first
+ -- this script is module name? import it first
if type(script) == "string" then
- -- TODO
- assert(false)
+ -- import module as script
+ local modulename = script
+ script = function ()
+
+ -- import it
+ import(modulename).main()
+ end
end
-- no script?