diff options
| author | ruki <[email protected]> | 2019-09-04 10:09:50 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-09-04 10:09:50 +0800 |
| commit | 1a1eac4f9e099eed250d72f309cf479efbb15a1c (patch) | |
| tree | bd0341661b3db9fc2f557b6b4186d5193671371d /tests | |
| parent | c97ee9d0ba48ac615caa9f239436645bc2e0af5a (diff) | |
| parent | 3d72809db048911efec3d52106dd6968349ef4d1 (diff) | |
Merge pull request #563 from xmake-io/buildrules
Separate build rules for specific language files from action/build
Diffstat (limited to 'tests')
19 files changed, 121 insertions, 107 deletions
diff --git a/tests/projects/c/shared_library/xmake.lua b/tests/projects/c/shared_library/xmake.lua index 50bad8879..48ccc67b3 100644 --- a/tests/projects/c/shared_library/xmake.lua +++ b/tests/projects/c/shared_library/xmake.lua @@ -1,45 +1,12 @@ --- the debug mode -if is_mode("debug") then - - -- enable the debug symbols - set_symbols("debug") +add_rules("mode.release", "mode.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.c") --- add target target("test") - - -- set kind set_kind("binary") - - -- add deps add_deps("shared_library_c") - - -- add files add_files("src/test.c") diff --git a/tests/projects/c/static_library/xmake.lua b/tests/projects/c/static_library/xmake.lua index 842921894..c3cc56e1a 100644 --- a/tests/projects/c/static_library/xmake.lua +++ b/tests/projects/c/static_library/xmake.lua @@ -1,45 +1,12 @@ --- the debug mode -if is_mode("debug") then - - -- enable the debug symbols - set_symbols("debug") +add_rules("mode.release", "mode.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("static_library_c") - - -- set kind set_kind("static") - - -- add files add_files("src/interface.c") --- add target target("test") - - -- set kind set_kind("binary") - - -- add deps add_deps("static_library_c") - - -- add files add_files("src/test.c") diff --git a/tests/projects/hybrid/static_library/src/main.cpp b/tests/projects/hybrid/static_library/src/main.cpp new file mode 100644 index 000000000..effbee53a --- /dev/null +++ b/tests/projects/hybrid/static_library/src/main.cpp @@ -0,0 +1,12 @@ +#include "test.h" + +int main(int argc, char** argv) +{ + test1(); +#ifdef MACOSX + test2(); + test3(); +#endif + test4(); + return 0; +} diff --git a/tests/projects/hybrid/static_library/src/main2.cpp b/tests/projects/hybrid/static_library/src/main2.cpp new file mode 100644 index 000000000..73890bc01 --- /dev/null +++ b/tests/projects/hybrid/static_library/src/main2.cpp @@ -0,0 +1,7 @@ +#include "test.h" + +int main(int argc, char** argv) +{ + test5(); + return 0; +} diff --git a/tests/projects/hybrid/static_library/src/test.h b/tests/projects/hybrid/static_library/src/test.h new file mode 100644 index 000000000..f794a69c7 --- /dev/null +++ b/tests/projects/hybrid/static_library/src/test.h @@ -0,0 +1,13 @@ +#ifdef __cplusplus +extern "C" { +#endif + +void test1(void); +void test2(void); +void test3(void); +void test4(void); +int test5(void); + +#ifdef __cplusplus +} +#endif diff --git a/tests/projects/hybrid/static_library/src/test1.c b/tests/projects/hybrid/static_library/src/test1.c new file mode 100644 index 000000000..8e0c1e021 --- /dev/null +++ b/tests/projects/hybrid/static_library/src/test1.c @@ -0,0 +1,5 @@ +#include "test.h" + +void test1() +{ +} diff --git a/tests/projects/hybrid/static_library/src/test2.m b/tests/projects/hybrid/static_library/src/test2.m new file mode 100644 index 000000000..2164a8bf5 --- /dev/null +++ b/tests/projects/hybrid/static_library/src/test2.m @@ -0,0 +1,5 @@ +#include "test.h" + +void test2() +{ +} diff --git a/tests/projects/hybrid/static_library/src/test3.mm b/tests/projects/hybrid/static_library/src/test3.mm new file mode 100644 index 000000000..ea33c33d5 --- /dev/null +++ b/tests/projects/hybrid/static_library/src/test3.mm @@ -0,0 +1,5 @@ +#include "test.h" + +void test3() +{ +} diff --git a/tests/projects/hybrid/static_library/src/test4.cpp b/tests/projects/hybrid/static_library/src/test4.cpp new file mode 100644 index 000000000..3cdf598a2 --- /dev/null +++ b/tests/projects/hybrid/static_library/src/test4.cpp @@ -0,0 +1,5 @@ +#include "test.h" + +void test4() +{ +} diff --git a/tests/projects/hybrid/static_library/src/test5.d b/tests/projects/hybrid/static_library/src/test5.d new file mode 100644 index 000000000..d6519665d --- /dev/null +++ b/tests/projects/hybrid/static_library/src/test5.d @@ -0,0 +1,5 @@ + +extern(C) int test5() +{ + return 5; +} diff --git a/tests/projects/other/merge_static_library/test.lua b/tests/projects/hybrid/static_library/test.lua index b76241be2..b76241be2 100644 --- a/tests/projects/other/merge_static_library/test.lua +++ b/tests/projects/hybrid/static_library/test.lua diff --git a/tests/projects/hybrid/static_library/xmake.lua b/tests/projects/hybrid/static_library/xmake.lua new file mode 100644 index 000000000..bc382c7c3 --- /dev/null +++ b/tests/projects/hybrid/static_library/xmake.lua @@ -0,0 +1,24 @@ +add_rules("mode.release", "mode.debug") + +target("test") + set_kind("static") + add_files("src/*.c", "src/*.cpp") + if is_plat("macosx") then + add_files("src/*.m", "src/*.mm") + end + +target("demo") + set_kind("binary") + add_deps("test") + add_files("src/main.cpp") + if is_plat("macosx") then + add_defines("MACOSX") + end + +target("demo2") + set_kind("binary") + add_files("src/main2.cpp", "src/*.d") + if not is_plat("macosx") then + set_enabled(false) + end + diff --git a/tests/projects/other/merge_static_library/src/add.c b/tests/projects/other/merge_archive/src/add.c index be1e084fc..be1e084fc 100644 --- a/tests/projects/other/merge_static_library/src/add.c +++ b/tests/projects/other/merge_archive/src/add.c diff --git a/tests/projects/other/merge_static_library/src/mul.c b/tests/projects/other/merge_archive/src/mul.c index c4292f9aa..c4292f9aa 100644 --- a/tests/projects/other/merge_static_library/src/mul.c +++ b/tests/projects/other/merge_archive/src/mul.c diff --git a/tests/projects/other/merge_static_library/src/sub.c b/tests/projects/other/merge_archive/src/sub.c index b151ec4bc..b151ec4bc 100644 --- a/tests/projects/other/merge_static_library/src/sub.c +++ b/tests/projects/other/merge_archive/src/sub.c diff --git a/tests/projects/other/merge_archive/test.lua b/tests/projects/other/merge_archive/test.lua new file mode 100644 index 000000000..b76241be2 --- /dev/null +++ b/tests/projects/other/merge_archive/test.lua @@ -0,0 +1,6 @@ +-- main entry +function main(t) + + -- build project + t:build() +end diff --git a/tests/projects/other/merge_archive/xmake.lua b/tests/projects/other/merge_archive/xmake.lua new file mode 100644 index 000000000..81b22c5e0 --- /dev/null +++ b/tests/projects/other/merge_archive/xmake.lua @@ -0,0 +1,22 @@ +add_rules("mode.debug", "mode.release") + +target("add") + set_kind("static") + add_files("src/add.c") + set_targetdir("$(buildir)/merge_archive") + +target("sub") + set_kind("static") + add_files("src/sub.c") + set_targetdir("$(buildir)/merge_archive") + +target("mul") + set_kind("static") + add_deps("add", "sub") + add_files("src/mul.c") + if is_plat("windows") then + add_files("$(buildir)/merge_archive/*.lib") + else + add_files("$(buildir)/merge_archive/*.a") + end + diff --git a/tests/projects/other/merge_object/xmake.lua b/tests/projects/other/merge_object/xmake.lua index 39e41be3e..772bc2c18 100644 --- a/tests/projects/other/merge_object/xmake.lua +++ b/tests/projects/other/merge_object/xmake.lua @@ -10,6 +10,11 @@ target("merge_object") -- add files add_files("src/interface.c") + -- save object file + after_build_file(function (target, sourcefile) + os.cp(target:objectfile(sourcefile), "$(buildir)/merge_object/") + end) + -- add target target("test") @@ -21,5 +26,9 @@ target("test") -- add files add_files("src/test.c") - add_files("build/.objs/merge_object/src/interface.c.o") + if is_plat("windows") then + add_files("$(buildir)/merge_object/interface.c.obj") + else + add_files("$(buildir)/merge_object/interface.c.o") + end diff --git a/tests/projects/other/merge_static_library/xmake.lua b/tests/projects/other/merge_static_library/xmake.lua deleted file mode 100644 index 729648ca2..000000000 --- a/tests/projects/other/merge_static_library/xmake.lua +++ /dev/null @@ -1,38 +0,0 @@ --- add rules -add_rules("mode.debug", "mode.release") - --- add target -target("add") - - -- set kind - set_kind("static") - - -- add files - add_files("src/add.c") - --- add target -target("sub") - - -- set kind - set_kind("static") - - -- add files - add_files("src/sub.c") - --- add target -target("mul") - - -- set kind - set_kind("static") - - -- add deps - add_deps("add", "sub") - - -- add files - add_files("src/mul.c") - add_files("build/libadd.a") - add_files("build/libsub.a") - - -- add link directory - add_linkdirs("$(buildir)") - |
