xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.14k stars 782 forks source link

无法通过 is_config() 对 plat/arch/toolchain 进行配置后,应用于 add_requires() 和 各 target() 的编译 #5832

Open yflin1 opened 2 hours ago

yflin1 commented 2 hours ago

Xmake 版本

xmake v2.9.6+HEAD.abd15c2

操作系统版本和架构

Ubuntu 22.04

描述问题

想要通过 xmake 命令行参数(device),如 xmake f --device=pc,统一对不同的设备的 arch/plat/toolchain 等等进行配置,但达不到效果。

期待的结果

如果执行 xmake f --device=pc,那么对 add_require() 引入的第三方库 和 各个 target 的编译时都自动使用 arch=x86_64, plat=linux, toolchain=mygcc9; 如果 xmake f --device=dev1,那么对 第三方库 和 各个 target 的编译都自动使用 arch=arm64, plat=linux, toolchain=my-dev1-gcc; ...

工程配置

options.lua: option("device") set_default("pc") set_showmenu(true) set_values("pc", "dev1", "dev2) set_description("Set target device")

xmake.lua: if is_config("device", "dev1") then set_toolchains("my-dev1-gcc") set_plat("linux") set_arch("aarch64") elseif is_config("device", "dev2") then set_toolchains("my-dev2-gcc") set_plat("linux") set_arch("aarch64") elseif is_config("device", "pc") then set_toolchains("gcc9") set_plat("linux") set_arch("x86_64") end

附加信息和错误日志

Issues-translate-bot commented 2 hours ago

Bot detected the issue body's language is not English, translate it automatically.


Title: After plat/arch/toolchain cannot be configured through is_config(), it is applied to the compilation of add_requires() and each target()

Xmake version

xmake v2.9.6+HEAD.abd15c2

Operating system version and architecture

Ubuntu 22.04

Describe the problem

I want to use xmake command line parameters (device), such as xmake f --device=pc, to uniformly configure the arch/plat/toolchain, etc. of different devices, but the effect is not achieved.

Expected results

If you execute xmake f --device=pc, the third-party libraries introduced by add_require() and each target will automatically be compiled using arch=x86_64, plat=linux, toolchain=mygcc9; If xmake f --device=dev1, then the compilation of third-party libraries and each target will automatically use arch=arm64, plat=linux, toolchain=my-dev1-gcc; ...

Project configuration

options.lua: option("device") set_default("pc") set_showmenu(true) set_values("pc", "dev1", "dev2) set_description("Set target device")

xmake.lua: if is_config("device", "dev1") then set_toolchains("my-dev1-gcc") set_plat("linux") set_arch("aarch64") elseif is_config("device", "dev2") then set_toolchains("my-dev2-gcc") set_plat("linux") set_arch("aarch64") elseif is_config("device", "pc") then set_toolchains("gcc9") set_plat("linux") set_arch("x86_64") end

Additional information and error logs

None