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

Question: can msys2 be used as a thridparty package source ? #1020

Closed
ImperatorS79 opened this issue Nov 8, 2020 · 25 comments
Closed

Question: can msys2 be used as a thridparty package source ? #1020

ImperatorS79 opened this issue Nov 8, 2020 · 25 comments

Comments

@ImperatorS79
Copy link
Contributor

ImperatorS79 commented Nov 8, 2020

Is your feature request related to a problem? Please describe.

I generally use msys2 to compile and manage my dependencies on windows

Describe the solution you'd like

I saw that xmake generally search in existing package sources like brew or vcpkg and I wondered if support for msys2 mingw package could be also added.

@waruqi
Copy link
Member

waruqi commented Nov 8, 2020

msys2/pacman? I will consider supporting it.

@waruqi waruqi added this to the v2.3.9 milestone Nov 8, 2020
@ImperatorS79
Copy link
Contributor Author

Yes, msys2 's mingw64 and mingw32 packages, and it is indeed using pacman. Thanks for the quick reply!

@waruqi
Copy link
Member

waruqi commented Nov 11, 2020

I have support pacman packages on archlinux and msys2/mingw. you can update to dev branch and try it. xmake update dev

add_requires("pacman::libpng", {alias = "libpng"})
target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_packages("libpng")

On msys2

xmake f -p mingw -a [i386|x86_64] -c
xmake

On archlinux

xmake

@ImperatorS79
Copy link
Contributor Author

ImperatorS79 commented Nov 11, 2020

Okay, so when I use the command add_requires("nlohmann_json"), it tries to download it from xmake-repo rather than using the already installed one from msys2. Maybe it comes from the fact that the package name is mingw-w64-x86_64-nlohmann-json on msys2 ?

Edit: when I use add_requires("pacman::nlohmann-json"), it fails too.

@waruqi
Copy link
Member

waruqi commented Nov 11, 2020

Please try add_requires("pacman::nlohmann-json"), If it fails, please show me the detailed error message.

xmake f -c -vD
xmake

@ImperatorS79
Copy link
Contributor Author

Here you go:

checking for architecture ... x86_64
checking for gcc ... ok
checking for unzip ... ok
checking for git ... ok
checking for gzip ... ok
checking for tar ... ok
checking for ping ... ok
checking for nmap ... no
pinging for the host(gitlab.com) ... 65535 ms
pinging for the host(github.com) ... 38 ms
pinging for the host(gitee.com) ... 238 ms
finding nlohmann-json from pacman ..
checking for pacman ... ok
checking for pacman::nlohmann-json ... no
note: try installing these packages (pass -y to skip confirm)?
in pacman:
  -> pacman::nlohmann-json latest
please input: y (y/n)
y
installing nlohmann-json from pacman ..
Root      : /
Conf File : /etc/pacman.conf
DB Path   : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/
Hook Dirs : /usr/share/libalpm/hooks/  /etc/pacman.d/hooks/
Lock File : /var/lib/pacman/db.lck
Log File  : /var/log/pacman.log
GPG Dir   : /etc/pacman.d/gnupg/
Targets   : nlohmann-json
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
error: target not found: nlohmann-json
error: @programdir\core\sandbox\modules\os.lua:387: execv(pacman -Sy --noconfirm --needed --disable-download-timeout nlohmann-json --verbose) failed(1)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:792]: in function 'raise'
    [@programdir\core\sandbox\modules\os.lua:387]: in function 'runv'
    [@programdir\core\sandbox\modules\os.lua:284]: in function 'vrunv'
    [...amdir\modules\package\manager\pacman\install_package.lua:57]: in function '_install_package'
    [@programdir\modules\package\manager\install_package.lua:109]:
    [@programdir\core\package\package.lua:1339]: in function 'script'
    [...gramdir\actions\require\impl\actions\..\utils\filter.lua:120]: in function 'call'
    [@programdir\actions\require\impl\actions\install.lua:143]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\actions\require\impl\actions\install.lua:127]: in function 'action_install'
    [@programdir\actions\require\impl\package.lua:644]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:188]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:182]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:317]:

  => install pacman::nlohmann-json latest .. failed
error: @programdir\modules\private\async\runjobs.lua:210: @programdir\actions\require\impl\actions\install.lua:250: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:792]: in function 'raise'
    [@programdir\actions\require\impl\actions\install.lua:250]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:127]: in function 'try'
    [@programdir\actions\require\impl\actions\install.lua:127]: in function 'action_install'
    [@programdir\actions\require\impl\package.lua:644]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:188]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:182]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:317]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:792: in function 'raise'
        @programdir\modules\private\async\runjobs.lua:210: in function 'catch'
        @programdir\core\sandbox\modules\try.lua:127: in function 'try'
        @programdir\modules\private\async\runjobs.lua:182: in function 'cotask'
        @programdir\core\base\scheduler.lua:317: in function <@programdir\core\base\scheduler.lua:315>
pacman -Sy --noconfirm --needed --disable-download-timeout nlohmann-json --verbose

@waruqi
Copy link
Member

waruqi commented Nov 11, 2020

try xmake f -p mingw -c -vD

@ImperatorS79
Copy link
Contributor Author

Here you go:

$ xmake f -p mingw -c -vD
checking for architecture ... x86_64
checking for mingw directory ... C:/tools/msys64/mingw64
checking for unzip ... ok
checking for git ... ok
checking for gzip ... ok
checking for tar ... ok
checking for ping ... ok
checking for nmap ... no
pinging for the host(gitlab.com) ... 65535 ms
pinging for the host(github.com) ... 25 ms
pinging for the host(gitee.com) ... 220 ms
finding nlohmann-json from pacman ..
checking for pacman ... ok
checking for pkg-config ... ok
checking for pacman::nlohmann-json ... no
note: try installing these packages (pass -y to skip confirm)?
in pacman:
  -> pacman::nlohmann-json latest
please input: y (y/n)
y
installing nlohmann-json from pacman ..
Root      : /
Conf File : /etc/pacman.conf
DB Path   : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/
Hook Dirs : /usr/share/libalpm/hooks/  /etc/pacman.d/hooks/
Lock File : /var/lib/pacman/db.lck
Log File  : /var/log/pacman.log
GPG Dir   : /etc/pacman.d/gnupg/
Targets   : mingw-w64-x86_64-nlohmann-json
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
warning: mingw-w64-x86_64-nlohmann-json-3.9.1-1 is up to date -- skipping
 there is nothing to do
finding nlohmann-json from pacman ..
checking for pacman::nlohmann-json ... no

error: @programdir\actions\require\impl\actions\install.lua:191: fetch pacman::nlohmann-json-latest failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:792]: in function 'raiselevel'
    [@programdir\core\sandbox\modules\utils.lua:181]: in function 'assert'
    [@programdir\actions\require\impl\actions\install.lua:191]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\actions\require\impl\actions\install.lua:127]: in function 'action_install'
    [@programdir\actions\require\impl\package.lua:644]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:188]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:182]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:317]:

  => install pacman::nlohmann-json latest .. failed
error: @programdir\modules\private\async\runjobs.lua:210: @programdir\actions\require\impl\actions\install.lua:250: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:792]: in function 'raise'
    [@programdir\actions\require\impl\actions\install.lua:250]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:127]: in function 'try'
    [@programdir\actions\require\impl\actions\install.lua:127]: in function 'action_install'
    [@programdir\actions\require\impl\package.lua:644]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:188]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:182]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:317]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:792: in function 'raise'
        @programdir\modules\private\async\runjobs.lua:210: in function 'catch'
        @programdir\core\sandbox\modules\try.lua:127: in function 'try'
        @programdir\modules\private\async\runjobs.lua:182: in function 'cotask'
        @programdir\core\base\scheduler.lua:317: in function <@programdir\core\base\scheduler.lua:315>
pacman -Sy --noconfirm --needed --disable-download-timeout mingw-w64-x86_64-nlohmann-json --verbose

@waruqi
Copy link
Member

waruqi commented Nov 11, 2020

find_package pacman::nlohmann-json fails. Maybe it is because mingw-w64-x86_64-nlohmann-json is a header-only library, so xmake can not find libxxx.a files.

I will improve it.

@waruqi
Copy link
Member

waruqi commented Nov 11, 2020

I have improved it, you can update to dev and try it again

xmake update -s dev
xmake f -p mingw -c -vD
xmake

@ImperatorS79
Copy link
Contributor Author

It worked using add_requires("pacman::nlohmann-json")!

@waruqi
Copy link
Member

waruqi commented Nov 11, 2020

Okay, then I will close it first, if you encounter other problems, you can open a new issue or reopen this issue.

@waruqi waruqi closed this as completed Nov 11, 2020
@ImperatorS79
Copy link
Contributor Author

I have this problem when launching xmake, might be unrelated to msys:

error: cannot import module: kinds.dynamic, not found!

@ImperatorS79
Copy link
Contributor Author

This is however related to msys: the target_os is linux in this:

xmake f -p mingw -c -vD
checking for architecture ... x86_64
checking for mingw directory ... C:/tools/msys64/mingw64
checking for unzip ... ok
checking for git ... ok
checking for gzip ... ok
checking for tar ... ok
checking for ping ... ok
checking for nmap ... no
pinging for the host(gitlab.com) ... 65535 ms
pinging for the host(github.com) ... 27 ms
pinging for the host(gitee.com) ... 218 ms
finding nlohmann-json from pacman ..
checking for pacman ... ok
checking for pkg-config ... ok
checking for pacman::nlohmann-json ... nlohmann-json
configure
{
    clean = true
    target_os = linux
    mode = release
    host = windows
    ndk_stdcxx = true
    cross = x86_64-w64-mingw32-
    mingw = C:/tools/msys64/mingw64
    ccache = true
    plat = mingw
    arch = x86_64
    buildir = build
    bin = C:\tools\msys64\mingw64\bin
    kind = static
}

@waruqi
Copy link
Member

waruqi commented Nov 11, 2020

It only for cross-compilation, xmake f -p cross and linux is only a default value.

We never use it on other platforms. Of course, I will try to improve it later, only showing the default value on the cross platform.

@ImperatorS79
Copy link
Contributor Author

ImperatorS79 commented Nov 12, 2020

Ok I got further with using xmake and I have now this problem with Eigen (linear algebra header-only library)

> x86_64-w64-mingw32-g++ "-fcolor-diagnostics"
checkinfo: @programdir\core\sandbox\modules\os.lua:258: x86_64-w64-mingw32-g++: error: unrecognized command-line option '-fcolor-diagnostics'

stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:792]: in function 'raise'
    [@programdir\core\sandbox\modules\os.lua:258]: in function 'runv'
    [@programdir\modules\detect\tools\gcc\has_flags.lua:42]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\detect\tools\gcc\has_flags.lua:42]: in function 'hasflags'
    [@programdir\modules\lib\detect\has_flags.lua:114]: in function 'has_flags'
    [@programdir\modules\core\tools\gcc.lua:367]: in function '_has_color_diagnostics'
    [@programdir\modules\core\tools\gcc.lua:444]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\core\tools\gcc.lua:429]:
    [C]: in function 'compile'
    [@programdir\modules\private\action\build\object.lua:75]: in function 'script'
    [@programdir\modules\private\action\build\object.lua:88]: in function '_build_object'
    [@programdir\modules\private\action\build\object.lua:113]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:188]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:182]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:317]:
checking for flags (-fdiagnostics-color=always) ... ok
> x86_64-w64-mingw32-g++ "-fdiagnostics-color=always"
error: @programdir\modules\private\async\runjobs.lua:210: @programdir\modules\private\action\build\object.lua:75: @programdir\modules\core\tools\gcc.lua:480: In file included from srcs\solver/SolverIncompressible.hpp:5,
                 from srcs\main.cpp:7:
srcs\solver/Solver.hpp:5:10: fatal error: Eigen/Dense: No such file or directory
    5 | #include <Eigen/Dense>
      |          ^~~~~~~~~~~~~
compilation terminated.
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:792]: in function 'raise'
    [@programdir\modules\core\tools\gcc.lua:480]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:127]: in function 'try'
    [@programdir\modules\core\tools\gcc.lua:429]:
    [C]: in function 'compile'
    [@programdir\modules\private\action\build\object.lua:75]: in function 'script'
    [@programdir\modules\private\action\build\object.lua:88]: in function '_build_object'
    [@programdir\modules\private\action\build\object.lua:113]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:188]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:182]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:317]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:792: in function 'raise'
        @programdir\modules\private\async\runjobs.lua:210: in function 'catch'
        @programdir\core\sandbox\modules\try.lua:127: in function 'try'
        @programdir\modules\private\async\runjobs.lua:182: in function 'cotask'
        @programdir\core\base\scheduler.lua:317: in function <@programdir\core\base\scheduler.lua:315>

I added the add_requires('pacman::eigen3') (which worked) and add_package('pacman::eigen3) in my target.

Output of xmake f -p mingw -c -vD:

checking for architecture ... x86_64
checking for mingw directory ... C:/tools/msys64/mingw64
checking for unzip ... ok
checking for git ... ok
checking for gzip ... ok
checking for tar ... ok
checking for ping ... ok
checking for nmap ... no
pinging for the host(gitlab.com) ... 65535 ms
pinging for the host(github.com) ... 27 ms
pinging for the host(gitee.com) ... 227 ms
finding nlohmann-json from pacman ..
finding eigen3 from pacman ..
checking for pacman ... ok
checking for pkg-config ... ok
checking for pacman::nlohmann-json ... nlohmann-json
checking for pacman::eigen3 ... eigen3 3.3.7
checking for x86_64-w64-mingw32-g++ ... C:\tools\msys64\mingw64\bin\x86_64-w64-mingw32-g++
checking for the shared library linker (sh) ... x86_64-w64-mingw32-g++
configure
{
    mode = release
    host = windows
    plat = mingw
    bin = C:\tools\msys64\mingw64\bin
    kind = static
    arch = x86_64
    cross = x86_64-w64-mingw32-
    target_os = linux
    ccache = true
    mingw = C:/tools/msys64/mingw64
    ndk_stdcxx = true
    buildir = build
    clean = true
}

@ImperatorS79
Copy link
Contributor Author

Okay nevermind I understood why it did not work ^^.

@waruqi
Copy link
Member

waruqi commented Nov 12, 2020

add_package('pacman::::eigen3) in my target

pacman::::eigen3? pacman::eigen3?

please let me see your xmake.lua

@ImperatorS79
Copy link
Contributor Author

Do not worry, the pacman::::eigen3 is a typo on github. I wrote it correctly in my xmake .lua ^^.

Reagrding the error I had, it was just that I forgot a target that needed eigen in my project.

@waruqi
Copy link
Member

waruqi commented Nov 12, 2020

Can you run pacman -Q -l mingw-w64-x86_64-eigen3 and let me see the output?

@ImperatorS79
Copy link
Contributor Author

You do not seem to understand that the problem I described above was not an error from xmake, but an error from myself in my xmake.lua, which I have fixed. It certainly because I don't express myself well in english ^^.

@waruqi
Copy link
Member

waruqi commented Nov 12, 2020

ok, you can also use alias name.

add_requires("pacman::eigen3", {alias = "eigen3"})

add_packages("eigen3")

@paul-reilly
Copy link
Contributor

On msys2

xmake f -p mingw -a [i386|x86_64] -c
xmake

On archlinux

xmake

Could $MSYSTEM be checked to avoid that configuration step in MSYS2?

@waruqi
Copy link
Member

waruqi commented Nov 24, 2020

On msys2

xmake f -p mingw -a [i386|x86_64] -c
xmake

On archlinux
xmake

Could $MSYSTEM be checked to avoid that configuration step in MSYS2?

I have improve it on dev branch, but I haven't tested it yet.

@paul-reilly
Copy link
Contributor

That seems to work, thanks!

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

3 participants