summaryrefslogtreecommitdiff
path: root/tests/c++_static_library
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-15 09:32:38 +0800
committerruki <[email protected]>2016-02-15 19:10:28 +0800
commitb78baf22ac0e25d2b18add81d42f733e0cd35620 (patch)
treed950c7c372227e300c8bfd780eea6371a4633692 /tests/c++_static_library
parent202ceb6b071c7a1e95482dcb8bb7b48f24cd5bdc (diff)
add some tests
Diffstat (limited to 'tests/c++_static_library')
-rwxr-xr-xtests/c++_static_library/src/interface.cpp6
-rwxr-xr-xtests/c++_static_library/src/interface.h16
-rwxr-xr-xtests/c++_static_library/src/test.cpp10
-rwxr-xr-xtests/c++_static_library/xmake.lua50
4 files changed, 82 insertions, 0 deletions
diff --git a/tests/c++_static_library/src/interface.cpp b/tests/c++_static_library/src/interface.cpp
new file mode 100755
index 000000000..598d07560
--- /dev/null
+++ b/tests/c++_static_library/src/interface.cpp
@@ -0,0 +1,6 @@
+#include "interface.h"
+
+int add(int a, int b)
+{
+ return a + b;
+}
diff --git a/tests/c++_static_library/src/interface.h b/tests/c++_static_library/src/interface.h
new file mode 100755
index 000000000..4a41e9597
--- /dev/null
+++ b/tests/c++_static_library/src/interface.h
@@ -0,0 +1,16 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! calculate add(a, b)
+ *
+ * @param a the first argument
+ * @param b the second argument
+ *
+ * @return the result
+ */
+int add(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/c++_static_library/src/test.cpp b/tests/c++_static_library/src/test.cpp
new file mode 100755
index 000000000..72e03272b
--- /dev/null
+++ b/tests/c++_static_library/src/test.cpp
@@ -0,0 +1,10 @@
+#include "interface.h"
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "add(1, 2) = " << add(1, 2) << endl;
+ return 0;
+}
diff --git a/tests/c++_static_library/xmake.lua b/tests/c++_static_library/xmake.lua
new file mode 100755
index 000000000..9fc5b6026
--- /dev/null
+++ b/tests/c++_static_library/xmake.lua
@@ -0,0 +1,50 @@
+-- the debug mode
+if modes("debug") then
+
+ -- enable the debug symbols
+ set_symbols("debug")
+
+ -- disable optimization
+ set_optimize("none")
+end
+
+-- the release mode
+if modes("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
+def_target("cpp_static_library")
+
+ -- set kind
+ set_kind("static")
+
+ -- add files
+ add_files("src/interface.cpp")
+
+-- add target
+def_target("test")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("cpp_static_library")
+
+ -- add files
+ add_files("src/test.cpp")
+
+ -- add links
+ add_links("cpp_static_library")
+
+ -- add link directory
+ add_linkdirs("$(buildir)")
+