From 435a897299d6ce5ded52c4a6f6c38ee771b0b1a3 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 18 Aug 2022 23:38:22 +0800 Subject: [PATCH 1/3] improve requires --- .../private/action/require/impl/package.lua | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index aa7fc9b96d7..7a18e1684f5 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -466,19 +466,6 @@ function _init_requireinfo(requireinfo, package, opt) requireinfo.configs = requireinfo.configs or {} if opt.is_toplevel then requireinfo.is_toplevel = true - if not package:is_headeronly() then - if package:is_library() then - requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") - if project.policy("package.inherit_external_configs") then - requireinfo.configs.toolchains = requireinfo.configs.toolchains or get_config("toolchain") - end - end - requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes") - if project.policy("package.inherit_external_configs") then - requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime") - end - requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto") - end end end @@ -488,8 +475,19 @@ function _finish_requireinfo(requireinfo, package) if package:is_headeronly() then requireinfo.configs.vs_runtime = nil else - if requireinfo.configs.vs_runtime == nil and package:is_plat("windows") then - requireinfo.configs.vs_runtime = "MT" + if package:is_library() then + requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") + if project.policy("package.inherit_external_configs") then + requireinfo.configs.toolchains = requireinfo.configs.toolchains or get_config("toolchain") + end + end + requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes") + if project.policy("package.inherit_external_configs") then + requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime") + end + requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto") + if package:is_plat("windows") then + requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or "MT" end end -- we need ensure readonly configs From 91aad5568b16ffcbef11dec173028ab6c0123af9 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 19 Aug 2022 00:44:36 +0800 Subject: [PATCH 2/3] improve requires --- .../private/action/require/impl/package.lua | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 7a18e1684f5..e90922171d8 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -466,15 +466,10 @@ function _init_requireinfo(requireinfo, package, opt) requireinfo.configs = requireinfo.configs or {} if opt.is_toplevel then requireinfo.is_toplevel = true - end -end --- finish requireinfo -function _finish_requireinfo(requireinfo, package) - requireinfo.configs = requireinfo.configs or {} - if package:is_headeronly() then - requireinfo.configs.vs_runtime = nil - else + -- we always pass some configurations from toplevel even it's headeronly, because it's library deps need inherit them + -- but we will reset it for headeronly package after finishing requireinfo + -- @see https://github.com/xmake-io/xmake/issues/2688 if package:is_library() then requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") if project.policy("package.inherit_external_configs") then @@ -486,8 +481,19 @@ function _finish_requireinfo(requireinfo, package) requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime") end requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto") - if package:is_plat("windows") then - requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or "MT" + end +end + +-- finish requireinfo +function _finish_requireinfo(requireinfo, package) + requireinfo.configs = requireinfo.configs or {} + if package:is_headeronly() then + requireinfo.configs.vs_runtime = nil + requireinfo.configs.toolchains = nil + requireinfo.configs.lto = nil + else + if requireinfo.configs.vs_runtime == nil and package:is_plat("windows") then + requireinfo.configs.vs_runtime = "MT" end end -- we need ensure readonly configs From cbdb0c221f9ae5cc09ec5f2dfe4b8d86974dd454 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 19 Aug 2022 00:45:57 +0800 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 764e0ae1193..b764ef4b97c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * [#2580](https://github.com/xmake-io/xmake/issues/2580): Set stdout to line buffering * [#2571](https://github.com/xmake-io/xmake/issues/2571): Improve task scheduling for parallel and distributed compilation based on memory/cpu usage * [#2410](https://github.com/xmake-io/xmake/issues/2410): Improve cmakelists generator +* [#2690](https://github.com/xmake-io/xmake/issues/2690): Improve to pass toolchains to packages ### Bugs fixed @@ -1373,6 +1374,7 @@ * [#2580](https://github.com/xmake-io/xmake/issues/2580): 设置 stdout 到 line 缓冲输出 * [#2571](https://github.com/xmake-io/xmake/issues/2571): 改进分布式编译的调度算法,增加 cpu/memory 状态权重 * [#2410](https://github.com/xmake-io/xmake/issues/2410): 改进 cmakelists 生成 +* [#2690](https://github.com/xmake-io/xmake/issues/2690): 改机传递 toolchains 到包 ### Bugs 修复