summaryrefslogtreecommitdiff
path: root/tests/projects/c++/shared_library
diff options
context:
space:
mode:
authorruki <[email protected]>2018-04-28 00:47:39 +0800
committerruki <[email protected]>2018-04-27 22:45:56 +0800
commit119dd6ff5786ef7a390b98b0558554029113f0dd (patch)
tree2fa5d1196a8951c0f8e4ad67c8b443b47280a0ab /tests/projects/c++/shared_library
parent7d486e88c2b3301449974e0e97168bc0f0fd6c64 (diff)
add wdk tests
Diffstat (limited to 'tests/projects/c++/shared_library')
-rw-r--r--tests/projects/c++/shared_library/src/interface.cpp6
-rw-r--r--tests/projects/c++/shared_library/src/interface.h24
-rw-r--r--tests/projects/c++/shared_library/src/test.cpp10
-rw-r--r--tests/projects/c++/shared_library/test.lua9
-rw-r--r--tests/projects/c++/shared_library/xmake.lua45
5 files changed, 94 insertions, 0 deletions
diff --git a/tests/projects/c++/shared_library/src/interface.cpp b/tests/projects/c++/shared_library/src/interface.cpp
new file mode 100644
index 000000000..598d07560
--- /dev/null
+++ b/tests/projects/c++/shared_library/src/interface.cpp
@@ -0,0 +1,6 @@
+#include "interface.h"
+
+int add(int a, int b)
+{
+ return a + b;
+}
diff --git a/tests/projects/c++/shared_library/src/interface.h b/tests/projects/c++/shared_library/src/interface.h
new file mode 100644
index 000000000..ef24ba3ce
--- /dev/null
+++ b/tests/projects/c++/shared_library/src/interface.h
@@ -0,0 +1,24 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32)
+# define __export __declspec(dllexport)
+#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+# define __export __attribute__((visibility("default")))
+#else
+# define __export
+#endif
+
+/*! calculate add(a, b)
+ *
+ * @param a the first argument
+ * @param b the second argument
+ *
+ * @return the result
+ */
+__export int add(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/projects/c++/shared_library/src/test.cpp b/tests/projects/c++/shared_library/src/test.cpp
new file mode 100644
index 000000000..72e03272b
--- /dev/null
+++ b/tests/projects/c++/shared_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/projects/c++/shared_library/test.lua b/tests/projects/c++/shared_library/test.lua
new file mode 100644
index 000000000..1ff9219ba
--- /dev/null
+++ b/tests/projects/c++/shared_library/test.lua
@@ -0,0 +1,9 @@
+-- imports
+import("..build")
+
+-- main entry
+function main()
+
+ -- build project
+ build()
+end
diff --git a/tests/projects/c++/shared_library/xmake.lua b/tests/projects/c++/shared_library/xmake.lua
new file mode 100644
index 000000000..6c2d4deea
--- /dev/null
+++ b/tests/projects/c++/shared_library/xmake.lua
@@ -0,0 +1,45 @@
+-- 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("shared_library_c++")
+
+ -- set kind
+ set_kind("shared")
+
+ -- add files
+ add_files("src/interface.cpp")
+
+-- add target
+target("test")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("shared_library_c++")
+
+ -- add files
+ add_files("src/test.cpp")
+
+