Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve requires #2690

Merged
merged 3 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 修复

Expand Down
24 changes: 14 additions & 10 deletions xmake/modules/private/action/require/impl/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -466,19 +466,21 @@ 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")

-- 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
requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime")
requireinfo.configs.toolchains = requireinfo.configs.toolchains or get_config("toolchain")
end
requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto")
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

Expand All @@ -487,6 +489,8 @@ 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"
Expand Down