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

Simplifying boolean value configs #5727

Closed
xq114 opened this issue Oct 17, 2024 · 14 comments
Closed

Simplifying boolean value configs #5727

xq114 opened this issue Oct 17, 2024 · 14 comments

Comments

@xq114
Copy link
Contributor

xq114 commented Oct 17, 2024

你在什么场景下需要该功能?

对于有很多组件/设置的包,一个个指定比较繁琐

add_requires("boost >=1.78.0", {configs = {iostreams = true, system = true, thread = true}})

描述可能的解决方案

#5527

希望3.0中可以简化设置,支持

add_requires("boost[iostreams,system,thread] >=1.78.0")

等价于在原有configs后追加iostreams = true, system = true, thread = true

描述你认为的候选方案

add_requires("boost >=1.78.0", {configs = ["iostreams", "system", "thread"])

若传入list则认为是config名称;这种做法灵活性比上一种差,但对现有语法变动小

其他信息

No response

@Issues-translate-bot
Copy link

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


In what scenario do you need this function?

For packages with many components/settings, specifying them one by one is cumbersome.

add_requires("boost >=1.78.0", {configs = {iostreams = true, system = true, thread = true}})

Describe possible solutions

#5527

It is hoped that the settings can be simplified in 3.0 and supported

add_requires("boost[iostreams,system,thread] >=1.78.0")

Equivalent to appending iostreams = true, system = true, thread = true after the original configs

Describe your alternatives

add_requires("boost >=1.78.0", {configs = ["iostreams", "system", "thread"])

If a list is passed in, it is considered to be the config name; this method is less flexible than the previous one, but it has less changes to the existing syntax.

Other information

No response

@star-hengxing
Copy link
Contributor

https://github.com/xmake-io/xmake-repo/blob/a3db9799031f80657356df314cd261838f341ad3/packages/t/thorvg/xmake.lua#L19-L23

add_requires("thorvg", {configs = {
    loaders = {"svg", "png"},
    tools = {"svg2png"}
}})

@xq114
Copy link
Contributor Author

xq114 commented Oct 17, 2024

xmake-io/xmake-repo@a3db979/packages/t/thorvg/xmake.lua#L19-L23

add_requires("thorvg", {configs = {
    loaders = {"svg", "png"},
    tools = {"svg2png"}
}})

这么写就更复杂了,尤其是90%的情况只需要一个配置xxx=true

@Issues-translate-bot
Copy link

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


[xmake-io/xmake-repo@a3db979/packages/t/thorvg/xmake.lua#L19-L23](https://github.com/xmake-io/xmake-repo/blob/a3db9799031f80657356df314cd261838f341ad3/packages /t/thorvg/xmake.lua#L19-L23)

``lua
add_requires("thorvg", {configs = {
loaders = {"svg", "png"},
tools = {"svg2png"}
}})

Writing this way is more complicated, especially in 90% of cases only one configuration xxx=true is needed

1 similar comment
@Issues-translate-bot
Copy link

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


[xmake-io/xmake-repo@a3db979/packages/t/thorvg/xmake.lua#L19-L23](https://github.com/xmake-io/xmake-repo/blob/a3db9799031f80657356df314cd261838f341ad3/packages /t/thorvg/xmake.lua#L19-L23)

``lua
add_requires("thorvg", {configs = {
loaders = {"svg", "png"},
tools = {"svg2png"}
}})

Writing this way is more complicated, especially in 90% of cases only one configuration xxx=true is needed

@xmake-io xmake-io deleted a comment from xq114 Oct 18, 2024
@waruqi
Copy link
Member

waruqi commented Oct 18, 2024

可以考虑 ,还可以带上string值。复杂的,array values 这种,就用 configs = {} 配。

add_requires("boost[iostreams,system,thread,key=value] >=1.78.0")
add_requires("boost[iostreams=y,thread=n] >=1.78.0")
xrepo install boost[iostreams,system,thread,key=value]

@waruqi waruqi mentioned this issue Oct 18, 2024
10 tasks
waruqi added a commit that referenced this issue Oct 18, 2024
@waruqi
Copy link
Member

waruqi commented Oct 18, 2024

这个实现比较简单,并且没啥副作用,可以提前进去,试试这个 patch #5736

@waruqi waruqi added this to the v2.9.6 milestone Oct 18, 2024
waruqi added a commit that referenced this issue Oct 19, 2024
@waruqi waruqi closed this as completed Oct 19, 2024
@waruqi
Copy link
Member

waruqi commented Oct 21, 2024

改进了下,还能支持 array values

 xrepo install ffmpeg[shared,debug,codecs=[foo,bar,zoo]]

@xflcx1991
Copy link

反对一个功能有多种写法,这会给以后交流学习,教程编写带来分歧,会进一步误导新手。

add_requires("boost >=1.78.0", {configs = {iostreams = true, system = true, thread = true}})

复制不就行了,难道真手敲?

@Issues-translate-bot
Copy link

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


It is against having multiple ways to write a function, which will cause differences in future communication and learning, and tutorial writing, and will further mislead novices.

add_requires("boost >=1.78.0", {configs = {iostreams = true, system = true, thread = true}})

Isn’t it enough to just copy it? Is it possible to type it by hand?

@waruqi
Copy link
Member

waruqi commented Oct 24, 2024

目前限制仅对 xmake 包生效,三方包不启用,因为 vcpkg::boost[core] 等三方包有自己的包名格式,会冲突

@Issues-translate-bot
Copy link

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


The current restriction only takes effect for the xmake package. Third-party packages are not enabled because third-party packages such as vcpkg::boost[core] have their own package name formats and will conflict.

@heheda123123
Copy link
Contributor

反对一个功能有多种写法,这会给以后交流学习,教程编写带来分歧,会进一步误导新手。

add_requires("boost >=1.78.0", {configs = {iostreams = true, system = true, thread = true}})

复制不就行了,难道真手敲?

都写c++了,一种功能多种写法应该习惯了,自己选择吧

@Issues-translate-bot
Copy link

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


It is against multiple ways of writing a function, which will cause differences in future communication and learning, and tutorial writing, and will further mislead novices.

add_requires("boost >=1.78.0", {configs = {iostreams = true, system = true, thread = true}})

Isn’t it just copying? Is it possible to type it by hand?

I've all written C++, so I should be used to writing one function in multiple ways. You can make your own choice.

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

6 participants