summaryrefslogtreecommitdiff
path: root/tests/projects/c++
diff options
context:
space:
mode:
authorruki <[email protected]>2023-07-25 12:57:22 +0800
committerGitHub <[email protected]>2023-07-25 12:57:22 +0800
commit841c94b81a39dbb360ffb6fb140b2e8241aadb42 (patch)
tree7ffd12ece3ea73a6d2a34bccab3d3cd6ec656c6a /tests/projects/c++
parent6bece03efd07829d4e59f53de36a219a2397c0e1 (diff)
parent3160045851a53d4ae014f7827e5cd34ac88fe647 (diff)
Merge pull request #4003 from xmake-io/soname
Add soname support
Diffstat (limited to 'tests/projects/c++')
-rw-r--r--tests/projects/c++/console/test.lua3
-rw-r--r--tests/projects/c++/shared_library/test.lua3
-rw-r--r--tests/projects/c++/shared_library_export_all/test.lua3
-rw-r--r--tests/projects/c++/shared_library_with_soname/.gitignore8
-rw-r--r--tests/projects/c++/shared_library_with_soname/src/foo.cpp5
-rw-r--r--tests/projects/c++/shared_library_with_soname/src/foo.h17
-rw-r--r--tests/projects/c++/shared_library_with_soname/src/main.cpp9
-rw-r--r--tests/projects/c++/shared_library_with_soname/test.lua3
-rw-r--r--tests/projects/c++/shared_library_with_soname/xmake.lua16
-rw-r--r--tests/projects/c++/static_library/test.lua3
-rw-r--r--tests/projects/c++/test(brackets)/test.lua3
-rw-r--r--tests/projects/c++/unity_build/test.lua3
12 files changed, 58 insertions, 18 deletions
diff --git a/tests/projects/c++/console/test.lua b/tests/projects/c++/console/test.lua
index b76241be2..b57362078 100644
--- a/tests/projects/c++/console/test.lua
+++ b/tests/projects/c++/console/test.lua
@@ -1,6 +1,3 @@
--- main entry
function main(t)
-
- -- build project
t:build()
end
diff --git a/tests/projects/c++/shared_library/test.lua b/tests/projects/c++/shared_library/test.lua
index b76241be2..b57362078 100644
--- a/tests/projects/c++/shared_library/test.lua
+++ b/tests/projects/c++/shared_library/test.lua
@@ -1,6 +1,3 @@
--- main entry
function main(t)
-
- -- build project
t:build()
end
diff --git a/tests/projects/c++/shared_library_export_all/test.lua b/tests/projects/c++/shared_library_export_all/test.lua
index b76241be2..b57362078 100644
--- a/tests/projects/c++/shared_library_export_all/test.lua
+++ b/tests/projects/c++/shared_library_export_all/test.lua
@@ -1,6 +1,3 @@
--- main entry
function main(t)
-
- -- build project
t:build()
end
diff --git a/tests/projects/c++/shared_library_with_soname/.gitignore b/tests/projects/c++/shared_library_with_soname/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/tests/projects/c++/shared_library_with_soname/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/tests/projects/c++/shared_library_with_soname/src/foo.cpp b/tests/projects/c++/shared_library_with_soname/src/foo.cpp
new file mode 100644
index 000000000..1a1fb3425
--- /dev/null
+++ b/tests/projects/c++/shared_library_with_soname/src/foo.cpp
@@ -0,0 +1,5 @@
+#include "foo.h"
+
+int add(int a, int b) {
+ return a + b;
+}
diff --git a/tests/projects/c++/shared_library_with_soname/src/foo.h b/tests/projects/c++/shared_library_with_soname/src/foo.h
new file mode 100644
index 000000000..20df0baa4
--- /dev/null
+++ b/tests/projects/c++/shared_library_with_soname/src/foo.h
@@ -0,0 +1,17 @@
+#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
+
+__export int add(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/projects/c++/shared_library_with_soname/src/main.cpp b/tests/projects/c++/shared_library_with_soname/src/main.cpp
new file mode 100644
index 000000000..ed1924789
--- /dev/null
+++ b/tests/projects/c++/shared_library_with_soname/src/main.cpp
@@ -0,0 +1,9 @@
+#include "foo.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_with_soname/test.lua b/tests/projects/c++/shared_library_with_soname/test.lua
new file mode 100644
index 000000000..b57362078
--- /dev/null
+++ b/tests/projects/c++/shared_library_with_soname/test.lua
@@ -0,0 +1,3 @@
+function main(t)
+ t:build()
+end
diff --git a/tests/projects/c++/shared_library_with_soname/xmake.lua b/tests/projects/c++/shared_library_with_soname/xmake.lua
new file mode 100644
index 000000000..4ebc1c501
--- /dev/null
+++ b/tests/projects/c++/shared_library_with_soname/xmake.lua
@@ -0,0 +1,16 @@
+add_rules("mode.debug", "mode.release")
+
+set_version("1.0.1", {soname = true})
+
+target("foo")
+ set_kind("shared")
+ add_files("src/foo.cpp")
+ after_build(function (target)
+ print(target:soname())
+ end)
+
+target("tests")
+ set_kind("binary")
+ add_deps("foo")
+ add_files("src/main.cpp")
+
diff --git a/tests/projects/c++/static_library/test.lua b/tests/projects/c++/static_library/test.lua
index b76241be2..b57362078 100644
--- a/tests/projects/c++/static_library/test.lua
+++ b/tests/projects/c++/static_library/test.lua
@@ -1,6 +1,3 @@
--- main entry
function main(t)
-
- -- build project
t:build()
end
diff --git a/tests/projects/c++/test(brackets)/test.lua b/tests/projects/c++/test(brackets)/test.lua
index b76241be2..b57362078 100644
--- a/tests/projects/c++/test(brackets)/test.lua
+++ b/tests/projects/c++/test(brackets)/test.lua
@@ -1,6 +1,3 @@
--- main entry
function main(t)
-
- -- build project
t:build()
end
diff --git a/tests/projects/c++/unity_build/test.lua b/tests/projects/c++/unity_build/test.lua
index b76241be2..b57362078 100644
--- a/tests/projects/c++/unity_build/test.lua
+++ b/tests/projects/c++/unity_build/test.lua
@@ -1,6 +1,3 @@
--- main entry
function main(t)
-
- -- build project
t:build()
end