diff options
| author | ruki <[email protected]> | 2021-01-08 11:35:04 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-08 11:35:04 +0800 |
| commit | b5a414be7af97fd058abb5dc5c37a7564da1c1ce (patch) | |
| tree | 6bfcb618892a7ad818eea1b9f642367599078e58 /tests | |
| parent | 8a9dad0bbb9932cf5f5aa5cab10043a784028d53 (diff) | |
| parent | 0ff70c2c239a0857798583650dcd349c24292aa3 (diff) | |
Merge pull request #1175 from xmake-io/deps
Improve package deps
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/projects/package/basic/test.lua | 9 | ||||
| -rw-r--r-- | tests/projects/package/basic/xmake.lua | 4 | ||||
| -rwxr-xr-x | tests/projects/package/depconfigs/src/main.c | 7 | ||||
| -rw-r--r-- | tests/projects/package/depconfigs/test.lua | 6 | ||||
| -rw-r--r-- | tests/projects/package/depconfigs/xmake.lua | 55 | ||||
| -rw-r--r-- | tests/projects/package/multiconfig/test.lua | 9 | ||||
| -rw-r--r-- | tests/projects/package/multiconfig/xmake.lua | 2 | ||||
| -rwxr-xr-x | tests/projects/package/rootconfigs/src/main.c | 7 | ||||
| -rw-r--r-- | tests/projects/package/rootconfigs/test.lua | 6 | ||||
| -rw-r--r-- | tests/projects/package/rootconfigs/xmake.lua | 7 | ||||
| -rw-r--r-- | tests/test_utils/test_build.lua | 4 |
11 files changed, 101 insertions, 15 deletions
diff --git a/tests/projects/package/basic/test.lua b/tests/projects/package/basic/test.lua index a4b905689..8644a2af9 100644 --- a/tests/projects/package/basic/test.lua +++ b/tests/projects/package/basic/test.lua @@ -1,7 +1,6 @@ --- main entry function main(t) - - -- TODO - -- build project --- t:build() + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end end diff --git a/tests/projects/package/basic/xmake.lua b/tests/projects/package/basic/xmake.lua index b71a22c1d..f06d2a199 100644 --- a/tests/projects/package/basic/xmake.lua +++ b/tests/projects/package/basic/xmake.lua @@ -1,11 +1,11 @@ add_requires("tbox master", {debug = true}) add_requires("zlib >=1.2.11") -add_requires("pcre2", "luajit", {system = false, optional = true}) +add_requires("pcre2", {system = false, optional = true}) add_rules("mode.debug", "mode.release") target("console") set_kind("binary") add_files("src/*.c") - add_packages("tbox", "zlib", "pcre2", "luajit") + add_packages("tbox", "zlib", "pcre2") diff --git a/tests/projects/package/depconfigs/src/main.c b/tests/projects/package/depconfigs/src/main.c new file mode 100755 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/depconfigs/src/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char** argv) +{ + printf("hello world!\n"); + return 0; +} diff --git a/tests/projects/package/depconfigs/test.lua b/tests/projects/package/depconfigs/test.lua new file mode 100644 index 000000000..8644a2af9 --- /dev/null +++ b/tests/projects/package/depconfigs/test.lua @@ -0,0 +1,6 @@ +function main(t) + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end +end diff --git a/tests/projects/package/depconfigs/xmake.lua b/tests/projects/package/depconfigs/xmake.lua new file mode 100644 index 000000000..c76e92df5 --- /dev/null +++ b/tests/projects/package/depconfigs/xmake.lua @@ -0,0 +1,55 @@ +add_requires("libpng", "libtiff", {system = false, configs = {vs_runtime = "MD"}}) +add_requires("libwebp") + +add_requireconfs("libwebp", {system = false, configs = {shared = true, vs_runtime = "MD"}}) +add_requireconfs("libpng.zlib", {system = false, override = true, configs = {cxflags = "-DTEST1"}, version = "1.2.10"}) +add_requireconfs("libtiff.*|cmake", {system = false, configs = {cxflags = "-DTEST2"}}) +add_requireconfs("libwebp.**|cmake", {system = false, configs = {cxflags = "-DTEST3"}}) + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("libpng") + before_build(function (target) + if target:pkg("libpng") then + local found + for _, linkdir in ipairs(target:pkg("libpng"):get("linkdirs")) do + if linkdir:find("zlib[/\\]1%.2%.10") then + found = true + end + end + assert(found, "package(zlib 1.2.10) not found!") + end + end) + +target("test2") + set_kind("binary") + add_files("src/*.c") + add_packages("libtiff") + before_build(function (target) + if target:pkg("libtiff") then + local found + for _, linkdir in ipairs(target:pkg("libtiff"):get("linkdirs")) do + if linkdir:find("zlib", 1, true) then + found = true + end + end + assert(found, "package(zlib) not found!") + end + end) + +target("test3") + set_kind("binary") + add_files("src/*.c") + add_packages("libwebp") + before_build(function (target) + if target:pkg("libwebp") then + local found + for _, linkdir in ipairs(target:pkg("libwebp"):get("linkdirs")) do + if linkdir:find("zlib", 1, true) then + found = true + end + end + assert(found, "package(zlib) not found!") + end + end) diff --git a/tests/projects/package/multiconfig/test.lua b/tests/projects/package/multiconfig/test.lua index a4b905689..8644a2af9 100644 --- a/tests/projects/package/multiconfig/test.lua +++ b/tests/projects/package/multiconfig/test.lua @@ -1,7 +1,6 @@ --- main entry function main(t) - - -- TODO - -- build project --- t:build() + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end end diff --git a/tests/projects/package/multiconfig/xmake.lua b/tests/projects/package/multiconfig/xmake.lua index 48d64da13..09121e8d2 100644 --- a/tests/projects/package/multiconfig/xmake.lua +++ b/tests/projects/package/multiconfig/xmake.lua @@ -11,7 +11,7 @@ target("test1") target("test2") set_kind("binary") add_files("src/*.c") - add_packages("zlib#debug") + add_packages("zlib~debug") target("test3") set_kind("binary") diff --git a/tests/projects/package/rootconfigs/src/main.c b/tests/projects/package/rootconfigs/src/main.c new file mode 100755 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/rootconfigs/src/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char** argv) +{ + printf("hello world!\n"); + return 0; +} diff --git a/tests/projects/package/rootconfigs/test.lua b/tests/projects/package/rootconfigs/test.lua new file mode 100644 index 000000000..8644a2af9 --- /dev/null +++ b/tests/projects/package/rootconfigs/test.lua @@ -0,0 +1,6 @@ +function main(t) + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end +end diff --git a/tests/projects/package/rootconfigs/xmake.lua b/tests/projects/package/rootconfigs/xmake.lua new file mode 100644 index 000000000..3e395ab7b --- /dev/null +++ b/tests/projects/package/rootconfigs/xmake.lua @@ -0,0 +1,7 @@ +add_requireconfs("*", {system = false, configs = {debug = false}}) +add_requires("zlib", {system = false, debug = true}) + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("zlib") diff --git a/tests/test_utils/test_build.lua b/tests/test_utils/test_build.lua index 44026200b..2a42e67d8 100644 --- a/tests/test_utils/test_build.lua +++ b/tests/test_utils/test_build.lua @@ -9,7 +9,7 @@ function test_build:build(argv) os.exec("xmake g -c") -- generic? - os.exec("xmake f -c") + os.exec("xmake f -c -D -y") os.exec("xmake") os.exec("xmake p -D") if not is_host("windows") then @@ -17,7 +17,7 @@ function test_build:build(argv) os.exec("xmake uninstall --installdir=$(tmpdir) -D") end os.exec("xmake c -D") - os.exec("xmake f --mode=debug -D") + os.exec("xmake f --mode=debug -D -y") os.exec("xmake m -b") os.exec("xmake -r -a -D") os.exec("xmake m -e buildtest") |
