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

Add a way to ask xmake to try to download dependencies from a certain package manager #1140

Closed
ImperatorS79 opened this issue Dec 13, 2020 · 5 comments

Comments

@ImperatorS79
Copy link
Contributor

Describe the solution you'd like

Currently, one have to add the prefix pacman:: in front of required librairies to download them using msys on windows. But what happens if a library is available on msys, on conan or on vcpkg and one wants to let the user choose from which package manager the library will be downloaded?

It could be great to add an option from command-line to tell xmake "try first to download dependencies from this package manager, if it does not work, build them using xmake-repo", so that the user is not forced to modify the xmake.lua to do so.

@waruqi
Copy link
Member

waruqi commented Dec 14, 2020

I think only need to modify the xmake.lua configuration to support it.

add_requires("pacman::zlib", {group = "zlib"})
add_requires("zlib", {group = "zlib"})
target("xxx")
     if has_package("pacman::zlib") then
         add_packages("pacman::zib")
     else
         add_packages("zlib")
     end

@ImperatorS79
Copy link
Contributor Author

ImperatorS79 commented Dec 20, 2020

The problem is that each project manager has to add those if else for each package manager manually. Which means that some project manager won't bother while their program would prefectly compile using librairies coming from pacman.

It would really easy to juste have something like:

xmake -prefPkgMan pacman

And inside each add_requires we would have

if(prefPkgMan == "pacman")
-- try to use pacman
else if (prefPkgMan == "conan")
-- try to use conan
end

-- if pacman or conan failed, use xmake-repo

@waruqi
Copy link
Member

waruqi commented Dec 21, 2020

Because even the same package, the configuration in each package manager may be different, and even the package name may be different

xmake cannot handle them automatically, unless the user uses add_requires to explicitly configure which package manager to use.

In addition, using add_requires("xxx"), xmake will first automatically find and use their packages from various package managers such as pacman, brew, pkg-config, etc.

If users don’t want to download packages from xmake-repo, they can directly use brew/pacman to install these packages, so users do not need to modify xmake.lua

@waruqi
Copy link
Member

waruqi commented Feb 11, 2021

you can see #1239

@waruqi
Copy link
Member

waruqi commented May 27, 2021

I have supported it on this pr: #1429

we need add some extsources in packages.

package("fmt")
    if is_plat("macosx") then
        add_extsources("brew::fmt")
    end

and xmake.lua

add_requires("fmt")
target("test")
    -- ...
    add_packages("fmt")

Then run xmake and input m and number list to modify packages to select 3rd packages.

$ xmake
note: install or modify (m) these packages (pass -y to skip confirm)?
in local-repo:
  -> fmt 7.1.3
please input: y (y/n/m)
m
note: select the following 3rd packages
  1. brew::fmt -> fmt 7.1.3
please input number list: n (1,2,..)
1
note: install or modify (m) these packages (pass -y to skip confirm)?
in brew:
  -> brew::fmt latest
please input: y (y/n/m)
y
  => install brew::fmt latest .. ok
[ 25%]: ccache compiling.release src/main.cpp
[ 50%]: linking.release test
[100%]: build ok!

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