diff options
| author | ruki <[email protected]> | 2023-07-25 22:43:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-07-25 22:43:11 +0800 |
| commit | 0a246a6718da31872cdedf48b3f430c8c6eb9caa (patch) | |
| tree | 294c19b4f04558d9e0c1c50d73319603e0f16c9d /tests/projects | |
| parent | af51876bc9ff2c76b76eb4c4fc01c8220e61f248 (diff) | |
add soname test example
Diffstat (limited to 'tests/projects')
6 files changed, 61 insertions, 0 deletions
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..b76241be2 --- /dev/null +++ b/tests/projects/c++/shared_library_with_soname/test.lua @@ -0,0 +1,6 @@ +-- main entry +function main(t) + + -- build project + 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") + |
