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

windows环境wasm目标,package.tools.cmake模块有bug #5146

Open
jingkaimori opened this issue May 25, 2024 · 2 comments
Open

windows环境wasm目标,package.tools.cmake模块有bug #5146

jingkaimori opened this issue May 25, 2024 · 2 comments
Labels

Comments

@jingkaimori
Copy link
Contributor

Xmake 版本

2.9.2

操作系统版本和架构

Windows 10 22H2

描述问题

在windows环境下,以wasm为目标,从xrepo安装任意一个调用package.tools.cmake模块的包(例如cubeb),都会报以下错误:

找不到mingw32-make

checking for the c++ compiler (cxx) ... emcc.bat
checkinfo: cannot runv(ninja.exe --version), No such file or directory
checking for ninja ... no
checkinfo: cannot runv(ninja.exe --version), No such file or directory
checking for ninja ... no
checkinfo: cannot runv(ninja.exe --version), No such file or directory
checking for ninja ... no
error: @programdir\modules\package\tools\cmake.lua:514: mingw32-make not found!

这是由于emsdk工具链下,cmake 的下游构建程序只能是ninjamingw32-make,而这些包没有添加ninja依赖,所以报错。

找不到make命令

如果为调用package.tools.cmake的包加上ninja依赖,上述报错不会出现。但是如果这个包需要用make构建,则会出现下面的报错信息:

-- Configuring done (19.2s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/jingkaimori/AppData/Local/.xmake/cache/packages/2405/m/mimalloc/2.1.7/source/build
make -j18 VERBOSE=1
error: @programdir\core\sandbox\modules\os.lua:378: cannot execv(make -j18 VERBOSE=1), No such file or directory
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [@programdir\core\sandbox\modules\os.lua:378]:
    [@programdir\core\sandbox\modules\os.lua:291]: in function 'vrunv'
    [@programdir\modules\package\tools\cmake.lua:964]: in function '_build_for_make'
    [@programdir\modules\package\tools\cmake.lua:1142]: in function 'build'
    [...ocuments\Source\xmake-repo\packages\m\mimalloc\xmake.lua:61]: in function 'script'
    [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call'
    [...\modules\private\action\require\impl\actions\install.lua:404]:

这是因为_build_for_make函数没处理emsdk工具链下的make

找不到mingw

加上ninja依赖后,package.tools.cmake的包还会报错,说找不到mingw环境,这个报错和_install_for_make函数有关:

-- Configuring done (23.3s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/jingkaimori/AppData/Local/.xmake/cache/packages/2405/c/cubeb/2023.7.31/source/cubeb/build_44ab3bab
error: @programdir\modules\package\tools\cmake.lua:1031: mingw not found!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]: in function 'raiselevel'
    [@programdir\core\sandbox\modules\utils.lua:143]: in function 'assert'
    [@programdir\modules\package\tools\cmake.lua:1031]: in function '_install_for_make'
    [@programdir\modules\package\tools\cmake.lua:1193]: in function 'install'
    [...i\Documents\Source\xmake-repo\packages\c\cubeb\xmake.lua:36]: in function 'script'
    [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call'
    [...\modules\private\action\require\impl\actions\install.lua:404]:

期待的结果

  • 如果检测到当前工具链为emsdk,操作平台为windows,则为cmake包添加ninja依赖;
  • 修改package.tools.cmake模块的_install_for_make_build_for_make等函数,处理emsdk工具链的情况

工程配置

见xmake-repo的cubebemio包,以及 xmake-io/xmake-repo#3215

附加信息和错误日志

参见问题描述

@Issues-translate-bot
Copy link

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


Title: windows environment wasm target, package.tools.cmake module has bugs

@waruqi
Copy link
Member

waruqi commented May 26, 2024

如果检测到当前工具链为emsdk,操作平台为windows,则为cmake包添加ninja依赖;

xmake 不会去自动加依赖,如果要依赖 ninja ,只能包配置里面 显式自己加上。

error: @programdir\modules\package\tools\cmake.lua:514: mingw32-make not found!

因为目前 wasm 在 windows 下的构建,目前只能支持在 msys2/mingw shell 环境跑,不仅依赖里面的 mingw32-make ,而且很多包是 configure 的,里面的 sh 脚本和一些子命令,也都需要依赖 msys2

如果仅仅只是处理 cmake ,理论上可以摆脱 mingw/msys2 的依赖,只是暂时还不支持,因为没 make ,还得用户自己配置上 make,而且大量 configure 包也不支持。。所以建议最好还是不要裸跑 wasm 构建。

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

No branches or pull requests

3 participants