diff options
4 files changed, 52 insertions, 0 deletions
diff --git a/tests/projects/package/compatibility/sync_requires_to_deps/src/main.c b/tests/projects/package/compatibility/sync_requires_to_deps/src/main.c new file mode 100755 index 000000000..113930e1a --- /dev/null +++ b/tests/projects/package/compatibility/sync_requires_to_deps/src/main.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(int argc, char** argv) { + printf("hello world!\n"); + return 0; +} diff --git a/tests/projects/package/compatibility/sync_requires_to_deps/test.lua b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua new file mode 100644 index 000000000..a6690754b --- /dev/null +++ b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua @@ -0,0 +1,10 @@ +function main(t) + -- freebsd ci is slower + if is_host("bsd") then + return + end + -- 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/compatibility/sync_requires_to_deps/xmake.lua b/tests/projects/package/compatibility/sync_requires_to_deps/xmake.lua new file mode 100644 index 000000000..2d3d0b029 --- /dev/null +++ b/tests/projects/package/compatibility/sync_requires_to_deps/xmake.lua @@ -0,0 +1,33 @@ + +package("foo") + add_deps("zlib >=1.2.13") + set_policy("package.install_locally", true) + on_install(function () end) +package_end() + +package("bar") + add_deps("zlib 1.2.x") + set_policy("package.install_locally", true) + on_install(function () end) +package_end() + +package("zoo") + set_policy("package.install_locally", true) + on_install(function () end) +package_end() + +package("test") + add_deps("foo", "bar", "zoo") + set_policy("package.install_locally", true) + on_install(function () end) +package_end() + +set_policy("package.sync_requires_to_deps", true) + +add_requires("test") +add_requires("zlib", {system = false, configs = {shared = true}}) + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("test") diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 0646bd3bc..b20a576b4 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -139,6 +139,9 @@ function policy.policies() -- Resolve package dependencies conflict automatically -- @see https://github.com/xmake-io/xmake/issues/5745 ["package.resolve_depconflict"] = {description = "Automatically resolve package dependencies conflict.", default = true, type = "boolean"}, + -- Synchronize add_requires configuration in toplevel to all package dependencies for this package + -- @see https://github.com/xmake-io/xmake/issues/5745 + ["package.sync_requires_to_deps"] = {description = "Synchronize requires configuration to all package dependencies.", default = false, type = "boolean"}, -- Automatically passes dependency configuration for inner xmake package -- @see https://github.com/xmake-io/xmake/issues/3952 ["package.xmake.pass_depconfs"] = {description = "Automatically passes dependency configuration for inner xmake package", default = true, type = "boolean"}, |
