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

meson build missing environment variables from msvc #1425

Closed
xq114 opened this issue May 25, 2021 · 3 comments
Closed

meson build missing environment variables from msvc #1425

xq114 opened this issue May 25, 2021 · 3 comments
Milestone

Comments

@xq114
Copy link
Contributor

xq114 commented May 25, 2021

注:提问题时若使用不能用/没效果/有问题/报错此类模糊表达,但又没有根据下面的模板给出任何相关辅助信息的,将会直接标记为Invalid。

描述问题

windows上运行

import("package.tools.meson").install(package)

提示找不到编译器cl

期待的结果

meson运行时加载msvc的环境

错误信息

meson.build:25:0: ERROR: Unknown compiler(s): ['icl', 'cl', 'cc', 'gcc', 'clang', 'clang-cl', 'pgcc']
The following exception(s) were encountered:
Running "icl " gave "[WinError 2] The system cannot find the file specified"
Running "cl /?" gave "[WinError 2] The system cannot find the file specified"        
Running "cc --version" gave "[WinError 2] The system cannot find the file specified" 
Running "gcc --version" gave "[WinError 2] The system cannot find the file specified"Running "clang --version" gave "[WinError 2] The system cannot find the file specified"
Running "clang-cl /?" gave "[WinError 2] The system cannot find the file specified"  
Running "pgcc --version" gave "[WinError 2] The system cannot find the file specified"

相关环境

请提供编译和运行环境信息,下面是一些必须填写的基础信息,便于我们针对性排查问题:

  • xmake版本:2.5.4
  • xmake运行平台:windows
  • xmake目标平台:windows

其他信息

请提供其他附加信息帮助我们诊断问题(比如截图,xmake.lua或者可复现的demo),以及你遇到的问题的一些背景信息。

Related pr: #1426

@waruqi
Copy link
Member

waruqi commented May 25, 2021

我更新了下,再试试 dev

@xq114
Copy link
Contributor Author

xq114 commented May 25, 2021

另外meson的变量b_staticpic和b_vscrt也可以设置为默认项
image

meson在windows上为了避免和动态库重名,静态库默认用.a做后缀,非常奇葩,导致xmake的自动库搜索对meson不适用,且链接的时候必须指定全名进行链接。直接用add_links(basename)在这不适用了,必须要加一段

if package:is_plat("windows") and not package:config("shared") then
    for _, lib in ipairs(os.files(package:installdir("lib", "lib*.a"))) do
        os.mv(lib, lib:gsub("(.+)lib(.-)%.a", "%1%2.lib"))
    end
end

但我不确定这一段需不需要内置到meson.lua里面去

meson的原因见mesonbuild/meson#1412

@waruqi
Copy link
Member

waruqi commented May 25, 2021

另外meson的变量b_staticpic和b_vscrt也可以设置为默认项

我win上暂时没装meson,没法测试,你直接这里帮忙改下就好

function generate(package, configs, opt)

meson在windows上为了避免和动态库重名,静态库默认用.a做后缀,非常奇葩,导致xmake的自动库搜索对meson不适用,且链接的时候必须指定全名进行链接。

meson 有选项或者配置可以外部改suffix么?

但我不确定这一段需不需要内置到meson.lua里面去

内置也可以,xmake里面统一还是走的 msvc 的命名,因为 windows 平台包,默认还是走的 msvc

不过脚本上得改进下,先的确认meson每次是否肯定装在 lib目录

还有 package:installdir 里面的参数拼接的路径,如果不存在,会去做 mkdir,所以 "lib*.a" 应该放外面,走 path.join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants