xmake-io / xmake

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

_os_find 等函数应该判断工具本身的版本,而不是判断系统 #5654

Closed rennsax closed 1 month ago

rennsax commented 1 month ago

Xmake 版本

2.9.5

操作系统版本和架构

macOS

描述问题

xmake 的 configure 脚本通过判断当前系统来决定要给出什么参数。

https://github.com/xmake-io/xmake/blob/b4260845f7949f52d74c7de3c9b36f473594fe13/configure#L241-L254

但是,在 macOS 上安装 GNU findutils 并设为默认的 find 是很常见的事情。这会导致 _os_find 无法使用正确的参数。

类似的还有 _os_date

期待的结果

不应该使用系统来作为判断依据。我认为 Zsh 的做法比较好:

_pick_variant -r variant gnu=GNU $OSTYPE -version

意思是,通过匹配 find -version 的输出来确定当前工具的版本。类似的还有

_pick_variant gnu="Free Software Foundation" unix --version

匹配 date --version 的输出。

工程配置

附加信息和错误日志

rennsax commented 1 month ago

这个问题在 tbox 上也有。

waruqi commented 1 month ago

也不算常见,目前也就你这第一次遇到。当初不这么弄,主要是考虑到每次调用,都要起进程太慢,要做缓存优化,我嫌麻烦,暂时也没时间处理。

可以直接提个 pr 过来改进。

Issues-translate-bot commented 1 month ago

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


Title: _os_find should determine the version of the tool itself, not the system

Issues-translate-bot commented 1 month ago

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


This problem also exists on tbox.

Issues-translate-bot commented 1 month ago

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


It's not very common, and this is the first time you've encountered it. I didn't do it this way at first, mainly because it was too slow to start the process every time I called it. It was too troublesome for me to optimize the cache, and I didn't have time to deal with it for the time being.

You can directly submit a PR for improvement.

rennsax commented 1 month ago

目前也就你这第一次遇到

可能很少人尝试过在 OSX 上编译 xmake 吧...

可以直接提个 pr 过来改进。

OK,谢谢回复!

Issues-translate-bot commented 1 month ago

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


So far, this is the first time you have met

Maybe few people have tried compiling xmake on OSX...

You can submit a PR directly for improvement.

OK, thanks for the reply!

waruqi commented 1 month ago

目前也就你这第一次遇到

可能很少人尝试过在 OSX 上编译 xmake 吧...

很多,我日常开发也都是 macos

Issues-translate-bot commented 1 month ago

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


So far, this is the first time you have met

Probably few people have tried compiling xmake on OSX...

A lot. I also use macos for daily development.