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

Xrepo how to pass configs to dependent libraries #2036

Closed
cyfdecyf opened this issue Feb 8, 2022 · 3 comments
Closed

Xrepo how to pass configs to dependent libraries #2036

cyfdecyf opened this issue Feb 8, 2022 · 3 comments

Comments

@cyfdecyf
Copy link
Contributor

cyfdecyf commented Feb 8, 2022

Consider following code in CMakeLists.txt which uses xrepo-cmake (Note the problem is not specific to xrepo-cmake):

xrepo_package("gflags" CONFIGS mt=true,shared=true)
xrepo_package("glog" CONFIGS shared=true)

glog depends on gflags, xrepo_package(glog ...) would install a -f mt=false,shared=false build of gflags because these are the default configs for gflags. But this version of config is not needed in the cmake project.

Manual install with xrepo install -f shared=true glog would have the same problem if the user actually wants a shared multi-threading enabled bulid of gflags.

We have builtin and non-builtin configs,

  • For builtin configs like shared=true, maybe it's reasonable to pass it recursively to all dependencies.
    • But for builtin flags like cflags, it maybe specific for each package thus shouldn't recursively pass to dependencies.
  • For non-builtin configs (mt=true for gflags).

This is a compilcated problem which I don't have any idea to gracefully handle. vcpkg uses baseline (if I understand correctly) which effectively does not allow user to (easily) change package configs.

For now I can live with creating a private repo and take one of the following options:

  1. change the mt=true as default for gflags.
  2. change the way glog depending on gflags.

Here's the code snippet in gflags's xmake.lua which I changed to take the second option:

for config, dep in pairs(configdeps) do
    if package:config(config) then
        if config == "gflags" then
            package:add("deps", "gflags 2.2.2", {
                configs = {mt = true, shared = package:config("shared")}
            })
        elseif config == "unwind" then
            package:add("deps", "libunwind", {
                configs = {shared = package:config("shared")}
            })
        else
            package:add("deps", dep)
        end
    end
end

It's rather ad-hoc but I doubt if there's any better way to this.

I'm consider adding arrow package in xmake-repo, it depends on lot's of other packages which may require extensive use of passing configs to dependent packages.

@waruqi
Copy link
Member

waruqi commented Feb 8, 2022

we can use add_requireconfs("glog.gflags", {configs = {mt = true, version = "2.2.2", shared = true}}) if we use xmake in xmake.lua.

but xrepo command does not support it yet.

Maybe we can use the xrepo install command to receive a xmake.lua file to describe all package information. for example:

xrepo install /xxx/glog.lua

/xxx/glog.lua

add_requires("glog")
add_requireconfs("glog.*", {system = false})
add_requireconfs("glog.gflags", {configs = {mt = true, version = "2.2.2", shared = true}})
-- ...

And add an api or option to pass glog.lua to xrepo-cmake wrapper.

xrepo_package("glog" CONFIGS /xxx/glog.lua)

@cyfdecyf
Copy link
Contributor Author

cyfdecyf commented Feb 8, 2022

Maybe we can use the xrepo install command to receive a xmake.lua file to describe all package information. for example:

xrepo install /xxx/glog.lua

/xxx/glog.lua

add_requires("glog")
add_requireconfs("glog.*", {system = false})
add_requireconfs("glog.gflags", {configs = {mt = true, version = "2.2.2", shared = true}})
-- ...

And add an api or option to pass glog.lua to xrepo-cmake wrapper.

xrepo_package("glog" CONFIGS /xxx/glog.lua)

This is a nice way for user to override configs in existing repo.

For xrepo package writers, the provided feature already satisfies the need.

@waruqi waruqi added this to the v2.6.4 milestone Feb 8, 2022
@waruqi
Copy link
Member

waruqi commented Feb 8, 2022

I have supported it on dev branch.

xrepo install xxx.lua
xrepo fetch xxx.lua

you can improve xrepo-cmake wrapper to support it.

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