summaryrefslogtreecommitdiff
path: root/tests/static_library_c
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-22 08:49:20 +0800
committerruki <[email protected]>2016-02-22 08:49:20 +0800
commitec6fd4eeca3fa468cffb25b472eb349c1fed06aa (patch)
tree3dbbb42e44310d8ae80ba2361a9f34bbbb90da13 /tests/static_library_c
parent762f3cd87615acbed339931bfb56c2b75c44cfa0 (diff)
modify tests script
Diffstat (limited to 'tests/static_library_c')
-rwxr-xr-xtests/static_library_c/src/interface.c6
-rwxr-xr-xtests/static_library_c/src/interface.h8
-rwxr-xr-xtests/static_library_c/src/test.c8
-rwxr-xr-xtests/static_library_c/xmake.lua50
4 files changed, 72 insertions, 0 deletions
diff --git a/tests/static_library_c/src/interface.c b/tests/static_library_c/src/interface.c
new file mode 100755
index 000000000..598d07560
--- /dev/null
+++ b/tests/static_library_c/src/interface.c
@@ -0,0 +1,6 @@
+#include "interface.h"
+
+int add(int a, int b)
+{
+ return a + b;
+}
diff --git a/tests/static_library_c/src/interface.h b/tests/static_library_c/src/interface.h
new file mode 100755
index 000000000..10ec0f856
--- /dev/null
+++ b/tests/static_library_c/src/interface.h
@@ -0,0 +1,8 @@
+/*! calculate add(a, b)
+ *
+ * @param a the first argument
+ * @param b the second argument
+ *
+ * @return the result
+ */
+int add(int a, int b);
diff --git a/tests/static_library_c/src/test.c b/tests/static_library_c/src/test.c
new file mode 100755
index 000000000..9505a2f75
--- /dev/null
+++ b/tests/static_library_c/src/test.c
@@ -0,0 +1,8 @@
+#include "interface.h"
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("add(1, 2) = %d\n", add(1, 2));
+ return 0;
+}
diff --git a/tests/static_library_c/xmake.lua b/tests/static_library_c/xmake.lua
new file mode 100755
index 000000000..72fd8c4a0
--- /dev/null
+++ b/tests/static_library_c/xmake.lua
@@ -0,0 +1,50 @@
+-- the debug mode
+if is_mode("debug") then
+
+ -- enable the debug symbols
+ set_symbols("debug")
+
+ -- disable optimization
+ set_optimize("none")
+end
+
+-- the release mode
+if is_mode("release") then
+
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
+
+ -- enable fastest optimization
+ set_optimize("fastest")
+
+ -- strip all symbols
+ set_strip("all")
+end
+
+-- add target
+target("c_static_library")
+
+ -- set kind
+ set_kind("static")
+
+ -- add files
+ add_files("src/interface.c")
+
+-- add target
+target("test")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("c_static_library")
+
+ -- add files
+ add_files("src/test.c")
+
+ -- add links
+ add_links("c_static_library")
+
+ -- add link directory
+ add_linkdirs("$(buildir)")
+