diff options
| author | ruki <[email protected]> | 2026-05-14 22:51:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-05-14 22:51:13 +0800 |
| commit | a4beaf9875423783c9776017970c4b39eea30744 (patch) | |
| tree | dabae325a3ee54f0447b5db2cc2399210643ce23 /tests | |
| parent | 1f661ce90b9f3184f8fc1d0159db30b27f81393d (diff) | |
improve merge archive from packages
Diffstat (limited to 'tests')
8 files changed, 61 insertions, 0 deletions
diff --git a/tests/projects/other/merge_archive_deps/src/add.c b/tests/projects/other/merge_archive_deps/src/add.c new file mode 100644 index 000000000..59aab4983 --- /dev/null +++ b/tests/projects/other/merge_archive_deps/src/add.c @@ -0,0 +1,3 @@ +int add(int a, int b) { + return a + b; +} diff --git a/tests/projects/other/merge_archive_deps/src/main.c b/tests/projects/other/merge_archive_deps/src/main.c new file mode 100644 index 000000000..df9eef6ac --- /dev/null +++ b/tests/projects/other/merge_archive_deps/src/main.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int add(int a, int b); +int sub(int a, int b); +int mul(int a, int b); +int subdir_add(int a, int b); +int subdir_sub(int a, int b); + +int main(int argc, char** argv) { + printf("%d\n", add(1, 1)); + printf("%d\n", sub(1, 1)); + printf("%d\n", mul(1, 1)); + printf("%d\n", subdir_add(1, 1)); + printf("%d\n", subdir_sub(1, 1)); + return 0; +} diff --git a/tests/projects/other/merge_archive_deps/src/mul.c b/tests/projects/other/merge_archive_deps/src/mul.c new file mode 100644 index 000000000..0c01379d4 --- /dev/null +++ b/tests/projects/other/merge_archive_deps/src/mul.c @@ -0,0 +1,3 @@ +int mul(int a, int b) { + return a * b; +} diff --git a/tests/projects/other/merge_archive_deps/src/sub.c b/tests/projects/other/merge_archive_deps/src/sub.c new file mode 100644 index 000000000..a6ffbba20 --- /dev/null +++ b/tests/projects/other/merge_archive_deps/src/sub.c @@ -0,0 +1,3 @@ +int sub(int a, int b) { + return a - b; +} diff --git a/tests/projects/other/merge_archive_deps/src/subdir/add.c b/tests/projects/other/merge_archive_deps/src/subdir/add.c new file mode 100644 index 000000000..318ed98f8 --- /dev/null +++ b/tests/projects/other/merge_archive_deps/src/subdir/add.c @@ -0,0 +1,4 @@ +int subdir_add(int a, int b) +{ + return a + b; +} diff --git a/tests/projects/other/merge_archive_deps/src/subdir/sub.c b/tests/projects/other/merge_archive_deps/src/subdir/sub.c new file mode 100644 index 000000000..68c4d13ae --- /dev/null +++ b/tests/projects/other/merge_archive_deps/src/subdir/sub.c @@ -0,0 +1,4 @@ +int subdir_sub(int a, int b) +{ + return a - b; +} diff --git a/tests/projects/other/merge_archive_deps/test.lua b/tests/projects/other/merge_archive_deps/test.lua new file mode 100644 index 000000000..88594b1d5 --- /dev/null +++ b/tests/projects/other/merge_archive_deps/test.lua @@ -0,0 +1,7 @@ +function main(t) + -- Solaris ar does not support merging archives with duplicate object file names + if is_host("solaris") then + return + end + t:build() +end diff --git a/tests/projects/other/merge_archive_deps/xmake.lua b/tests/projects/other/merge_archive_deps/xmake.lua new file mode 100644 index 000000000..be1f45de0 --- /dev/null +++ b/tests/projects/other/merge_archive_deps/xmake.lua @@ -0,0 +1,21 @@ +add_rules("mode.debug", "mode.release") + +target("add") + set_kind("static") + add_files("src/add.c") + add_files("src/subdir/add.c") + +target("sub") + set_kind("static") + add_files("src/sub.c") + add_files("src/subdir/sub.c") + +target("mul") + set_kind("static") + add_deps("add", "sub") + add_files("src/mul.c") + set_policy("build.merge_archive", true) + +target("test") + add_deps("mul") + add_files("src/main.c") |
