summaryrefslogtreecommitdiff
path: root/tests/plugins
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-07-16 12:36:01 +0800
committerOpportunityLiu <[email protected]>2019-07-16 12:36:01 +0800
commitc63d5c42136e92ad16eb81cc1b01db34d29792d1 (patch)
tree173c276d22a9de46b8b491a28092969e43db27bc /tests/plugins
parent1ab3e1b602a12a95d91433e8b91c2aec8146940f (diff)
add ut
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/project/c/src/main.c7
-rw-r--r--tests/plugins/project/c/xmake.lua77
-rw-r--r--tests/plugins/project/test.lua33
3 files changed, 117 insertions, 0 deletions
diff --git a/tests/plugins/project/c/src/main.c b/tests/plugins/project/c/src/main.c
new file mode 100644
index 000000000..9ae580511
--- /dev/null
+++ b/tests/plugins/project/c/src/main.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("hello world!\n");
+ return 0;
+}
diff --git a/tests/plugins/project/c/xmake.lua b/tests/plugins/project/c/xmake.lua
new file mode 100644
index 000000000..72c4eb5f7
--- /dev/null
+++ b/tests/plugins/project/c/xmake.lua
@@ -0,0 +1,77 @@
+
+-- add modes: debug and release
+add_rules("mode.debug", "mode.release")
+
+-- add target
+target("project")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add files
+ add_files("src/*.c")
+
+
+--
+-- FAQ
+--
+-- You can enter the project directory firstly before building project.
+--
+-- $ cd projectdir
+--
+-- 1. How to build project?
+--
+-- $ xmake
+--
+-- 2. How to configure project?
+--
+-- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release]
+--
+-- 3. Where is the build output directory?
+--
+-- The default output directory is `./build` and you can configure the output directory.
+--
+-- $ xmake f -o outputdir
+-- $ xmake
+--
+-- 4. How to run and debug target after building project?
+--
+-- $ xmake run [targetname]
+-- $ xmake run -d [targetname]
+--
+-- 5. How to install target to the system directory or other output directory?
+--
+-- $ xmake install
+-- $ xmake install -o installdir
+--
+-- 6. Add some frequently-used compilation flags in xmake.lua
+--
+-- @code
+-- -- add macro defination
+-- add_defines("NDEBUG", "_GNU_SOURCE=1")
+--
+-- -- set warning all as error
+-- set_warnings("all", "error")
+--
+-- -- set language: c99, c++11
+-- set_languages("c99", "cxx11")
+--
+-- -- set optimization: none, faster, fastest, smallest
+-- set_optimize("fastest")
+--
+-- -- add include search directories
+-- add_includedirs("/usr/include", "/usr/local/include")
+--
+-- -- add link libraries and search directories
+-- add_links("tbox", "z", "pthread")
+-- add_linkdirs("/usr/local/lib", "/usr/lib")
+--
+-- -- add compilation and link flags
+-- add_cxflags("-stdnolib", "-fno-strict-aliasing")
+-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
+--
+-- @endcode
+--
+-- 7. If you want to known more usage about xmake, please see http://xmake.io/#/home
+--
+
diff --git a/tests/plugins/project/test.lua b/tests/plugins/project/test.lua
new file mode 100644
index 000000000..a9f1fa37e
--- /dev/null
+++ b/tests/plugins/project/test.lua
@@ -0,0 +1,33 @@
+import("detect.sdks.find_vstudio")
+import("core.project.config")
+import("core.platform.environment")
+
+function test_vsxmake(t)
+
+ if os.host() ~= "windows" then
+ return t:skip("wrong host platform")
+ end
+
+ -- build project
+ local vs = find_vstudio()
+ local arch = os.getenv("platform") or "x86"
+
+ os.cd("c")
+
+ for name, data in pairs(vs) do
+ local vstype = "vsxmake" .. name
+ local path = os.getenv("path")
+ os.setenv("path", data.vcvarsall[arch].path)
+ environment.enter("toolchains")
+ os.execv("xmake", {"project", "-k", vstype, "-a", arch})
+ os.cd(vstype)
+ os.exec("msbuild /t:show")
+ os.exec("msbuild")
+ environment.leave("toolchains")
+ os.setenv("path", path)
+ os.cd("..")
+ os.tryrm(vstype)
+ end
+
+ os.cd("..")
+end