summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2015-05-08 16:12:09 +0800
committerruki <[email protected]>2015-05-08 16:12:41 +0800
commitf2313cc0c48b37b7aa6222457325a23ad62e1fd8 (patch)
tree1f31fee66737defb1a241643af6ee5f8a5381b17
parent00cd7e605400a459822294f3ceff5194cf9b56d5 (diff)
modify tests for console
-rw-r--r--tests/console/src/demo/demo.c7
-rw-r--r--tests/console/src/demo/demo.cpp7
-rw-r--r--tests/console/src/demo/demo.m7
-rw-r--r--tests/console/src/demo/demo.mm7
-rw-r--r--tests/console/src/hello1/hello1.c6
-rw-r--r--tests/console/src/hello1/hello1.h10
-rw-r--r--tests/console/src/hello2/hello2.c6
-rw-r--r--tests/console/src/hello2/hello2.h10
-rw-r--r--tests/console/src/hello3/hello3.c6
-rw-r--r--tests/console/src/hello3/hello3.h10
-rw-r--r--tests/console/xmake.lua57
-rw-r--r--xmake/scripts/action/action.lua38
-rw-r--r--xmake/scripts/action/config.lua33
-rw-r--r--xmake/scripts/base/main.lua67
14 files changed, 232 insertions, 39 deletions
diff --git a/tests/console/src/demo/demo.c b/tests/console/src/demo/demo.c
new file mode 100644
index 000000000..9ae580511
--- /dev/null
+++ b/tests/console/src/demo/demo.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("hello world!\n");
+ return 0;
+}
diff --git a/tests/console/src/demo/demo.cpp b/tests/console/src/demo/demo.cpp
new file mode 100644
index 000000000..9ae580511
--- /dev/null
+++ b/tests/console/src/demo/demo.cpp
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("hello world!\n");
+ return 0;
+}
diff --git a/tests/console/src/demo/demo.m b/tests/console/src/demo/demo.m
new file mode 100644
index 000000000..9ae580511
--- /dev/null
+++ b/tests/console/src/demo/demo.m
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("hello world!\n");
+ return 0;
+}
diff --git a/tests/console/src/demo/demo.mm b/tests/console/src/demo/demo.mm
new file mode 100644
index 000000000..9ae580511
--- /dev/null
+++ b/tests/console/src/demo/demo.mm
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("hello world!\n");
+ return 0;
+}
diff --git a/tests/console/src/hello1/hello1.c b/tests/console/src/hello1/hello1.c
new file mode 100644
index 000000000..b946071f0
--- /dev/null
+++ b/tests/console/src/hello1/hello1.c
@@ -0,0 +1,6 @@
+#include "hello1.h"
+
+char const* hello1()
+{
+ return "hello1";
+}
diff --git a/tests/console/src/hello1/hello1.h b/tests/console/src/hello1/hello1.h
new file mode 100644
index 000000000..328f996c3
--- /dev/null
+++ b/tests/console/src/hello1/hello1.h
@@ -0,0 +1,10 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char const* hello1();
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/tests/console/src/hello2/hello2.c b/tests/console/src/hello2/hello2.c
new file mode 100644
index 000000000..1124ab563
--- /dev/null
+++ b/tests/console/src/hello2/hello2.c
@@ -0,0 +1,6 @@
+#include "hello2.h"
+
+char const* hello2()
+{
+ return "hello2";
+}
diff --git a/tests/console/src/hello2/hello2.h b/tests/console/src/hello2/hello2.h
new file mode 100644
index 000000000..080c37c66
--- /dev/null
+++ b/tests/console/src/hello2/hello2.h
@@ -0,0 +1,10 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char const* hello2();
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/tests/console/src/hello3/hello3.c b/tests/console/src/hello3/hello3.c
new file mode 100644
index 000000000..0ccc5015f
--- /dev/null
+++ b/tests/console/src/hello3/hello3.c
@@ -0,0 +1,6 @@
+#include "hello3.h"
+
+char const* hello3()
+{
+ return "hello3";
+}
diff --git a/tests/console/src/hello3/hello3.h b/tests/console/src/hello3/hello3.h
new file mode 100644
index 000000000..0404a4381
--- /dev/null
+++ b/tests/console/src/hello3/hello3.h
@@ -0,0 +1,10 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char const* hello3();
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/tests/console/xmake.lua b/tests/console/xmake.lua
new file mode 100644
index 000000000..eda4779fc
--- /dev/null
+++ b/tests/console/xmake.lua
@@ -0,0 +1,57 @@
+project "console"
+
+ target "hello1"
+ kind "static"
+ files { "src/hello1/*.c" }
+
+ target "hello2"
+ kind "shared"
+ files { "$(projectdir)/src/hello2/*.c" }
+
+ target "hello3"
+ kind "static"
+ files { "src/hello3/*.c" }
+ headers { "src/hello3/*.h" }
+ headerdir "$(buildir)/inc"
+ targetdir "$(buildir)/lib"
+ objectdir "$(buildir)/obj"
+
+ target "demo_c"
+ kind "console"
+ files { "src/demo/*.c" }
+ links { "hello1" }
+ linkdirs { "src/hello1" }
+ includedirs { "src/hello1" }
+ cflags { "-DHELLO1" }
+
+ target "demo_cpp"
+ kind "console"
+ files { "src/demo/*.cpp" }
+ links { "hello2" }
+ linkdirs { "src/hello2" }
+ includedirs { "src/hello2" }
+ cxxflags { "-DHELLO1" }
+
+ target "demo_objc"
+ kind "console"
+ files { "src/demo/*.m" }
+ links { "hello3" }
+ linkdirs { "$(buildir)/lib" }
+ includedirs { "$(buildir)/inc" }
+ mflags { "-DHELLO3" }
+
+ target "demo_objcpp"
+ kind "console"
+ files { "src/demo/*.mm" }
+ mxflags { "-DHELLO3" }
+ ldflags { "-lhello3", "-L$(buildir)/lib" }
+
+ plarforms { "linux" }
+ defines { "PLAT=linux" }
+
+ plarforms { "windows" }
+ defines { "PLAT=windows" }
+
+ plarforms { "macosx", "ios" }
+ ldflags { "-framework Cocoa", "-framework IOKit" }
+
diff --git a/xmake/scripts/action/action.lua b/xmake/scripts/action/action.lua
new file mode 100644
index 000000000..dbb00a5b2
--- /dev/null
+++ b/xmake/scripts/action/action.lua
@@ -0,0 +1,38 @@
+--!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) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file action.lua
+--
+
+-- define module: action
+local action = action or {}
+
+-- done the given action
+function action.done(name)
+
+ -- load the given action
+ local a = require("action/" .. name)
+ if not a then return false end
+
+ -- done the given action
+ return a.done()
+end
+
+-- return module: action
+return action
diff --git a/xmake/scripts/action/config.lua b/xmake/scripts/action/config.lua
new file mode 100644
index 000000000..51c6f8d66
--- /dev/null
+++ b/xmake/scripts/action/config.lua
@@ -0,0 +1,33 @@
+--!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) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file config.lua
+--
+
+-- define module: config
+local config = config or {}
+
+-- done the given config
+function config.done()
+ print("config")
+ return true
+end
+
+-- return module: config
+return config
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua
index a0e94634a..e9d3d2af9 100644
--- a/xmake/scripts/base/main.lua
+++ b/xmake/scripts/base/main.lua
@@ -27,6 +27,7 @@ local main = main or {}
local path = require("base/path")
local utils = require("base/utils")
local option = require("base/option")
+local action = require("action/action")
-- init the option menu
local menu =
@@ -66,8 +67,8 @@ local menu =
, {}
- , {nil, "verbose", "k", nil, "Print lots of verbose information." }
- , {'v', "version", "k", nil, "Print the version number and exit." }
+ , {'v', "verbose", "k", nil, "Print lots of verbose information." }
+ , {nil, "version", "k", nil, "Print the version number and exit." }
, {'h', "help", "k", nil, "Print this help message and exit." }
, {}
@@ -113,8 +114,8 @@ local menu =
, " - game" }
, {}
- , {nil, "verbose", "k", nil, "Print lots of verbose information." }
- , {'v', "version", "k", nil, "Print the version number and exit." }
+ , {'v', "verbose", "k", nil, "Print lots of verbose information." }
+ , {nil, "version", "k", nil, "Print the version number and exit." }
, {'h', "help", "k", nil, "Print this help message and exit." }
, {}
@@ -145,7 +146,7 @@ local menu =
, {nil, "profile", "k", nil, "Compile for the profiling mode and disable the debugging mode."}
, {}
- , {'o', "output", "kv", "build", "Set the build output directory" }
+ , {'o', "output", "kv", "build", "Set the build directory" }
, {'k', "packages", "kv", "pkg", "Set the packages directory" }
, {}
@@ -178,8 +179,8 @@ local menu =
, {}
- , {nil, "verbose", "k", nil, "Print lots of verbose information." }
- , {'v', "version", "k", nil, "Print the version number and exit." }
+ , {'v', "verbose", "k", nil, "Print lots of verbose information." }
+ , {nil, "version", "k", nil, "Print the version number and exit." }
, {'h', "help", "k", nil, "Print this help message and exit." }
, {}
@@ -212,8 +213,8 @@ local menu =
, {}
- , {nil, "verbose", "k", nil, "Print lots of verbose information." }
- , {'v', "version", "k", nil, "Print the version number and exit." }
+ , {'v', "verbose", "k", nil, "Print lots of verbose information." }
+ , {nil, "version", "k", nil, "Print the version number and exit." }
, {'h', "help", "k", nil, "Print this help message and exit." }
, {}
@@ -237,12 +238,7 @@ local menu =
-- options
, options =
{
- {nil, "verbose", "k", nil, "Print lots of verbose information." }
- , {'v', "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
+ {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
, {'P', "project", "kv", nil, "Change to the given project directory."
, "Search priority:"
, " 1. the given command argument"
@@ -250,6 +246,11 @@ local menu =
, " 3. the current directory" }
, {}
+ , {'v', "verbose", "k", nil, "Print lots of verbose information." }
+ , {nil, "version", "k", nil, "Print the version number and exit." }
+ , {'h', "help", "k", nil, "Print this help message and exit." }
+
+ , {}
, {nil, "target", "v", nil, "Clean for the given target."
, "Clean all targets if not exists." }
}
@@ -257,26 +258,24 @@ local menu =
}
-- done option
-function main.done_action()
+function main.done_option()
-- the options
local options = xmake._OPTIONS
assert(options)
- -- the action
- local action = options._ACTION or "build"
-
-
- -- ok
- return true
-end
+ -- init the project directory
+ options.project = options.project or _PROJECT_DIR
+ options.project = path.absolute(options.project)
+ assert(options.project)
--- done option
-function main.done_option()
+ -- init the xmake.lua file path
+ options.file = options.file or "xmake.lua"
+ options.file = path.absolute(options.file, options.project)
+ assert(options.file)
- -- the options
- local options = xmake._OPTIONS
- assert(options)
+ -- load and execute the xmake.lua script of the given project
+ dofile(options.file)
-- done help
if options.help then
@@ -304,18 +303,8 @@ function main.done_option()
return true
end
- -- init the project directory
- options.project = options.project or _PROJECT_DIR
- options.project = path.absolute(options.project)
- assert(options.project)
-
- -- init the xmake.lua file path
- options.file = options.file or "xmake.lua"
- options.file = path.absolute(options.file, options.project)
- assert(options.file)
-
-- done action
- return main.done_action()
+ return action.done(options._ACTION or "build")
end
-- the main function