-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
formula: add on_macos and on_linux #7257
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this! Thank you! Something for my tired brain to use to standardize both the cores again with not too much thought!
Do we want to add I don't want to overcomplicate things… but… we'll likely also need conditional patches. Do we want a unified predicate syntax that works for both OS conditional |
If we have I think patches should be handled in a separate PR. |
Some ideas - feel free to disagree: depends_on "linux-headers" => :linux patch do
url "..."
sha256 "..."
only_on :linux
end |
I like Bo's suggestions. I'd like something as parallel as possible. So perhaps… depends_on "linux-headers", :on => :linux
patch do
…
on :linux
end Or perhaps… on_macos do
depends_on …
patch do
…
end
end though not sure that I like it any better. Just spitballing. |
I thought it might help to contextualise each of these suggestions in the context of a formula, so I mocked up some (non-functional, obviously) examples with one of our most common Linux dependencies: I like Bo's suggestions, but we'd have to do some designing around what would happen in the
My concern with this is that yes, it's self-contained, but it makes the general flow of a formula not feel so good and would be alien to most contributors, especially if we nest patches within this as well. And in which block do we put |
I see where you want to go with Also, as @issyl0 said (if I understood well): we would be mixing two concepts: build/test stuff, and platform stuff. What would you do if you need a build dependency for Linux, but the same package is needed as a full dependency on mac? This might be too complex to write, or cumbersome at least. I would like to keep this first PR small, so I am not focusing on patches (though the design choice for patches might influence this PR). Regarding mac only dependencies; I would like to introduce this in a second PR too, to keep this one small.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a far of the naming as-is. I'd like to explore the problem a lot more before we jump into a DSL (that we'll need to support indefinitely)
What are some examples of things that are depended on on Linux and not macOS? Why is that? Is it actually "Linux" or is it "not macOS" (these things are not interchangeable). Is it for Homebrew on Linux or is it the same in e.g. Debian?
uses_from_macos
is communicating a specific thing about a dependency that macOS provides that Linux does not (which we still need an audit for so it's not used for packages not provided by macOS; I'd also like to see that work "finished" before we add more DSL).
Actually there are not so many, here are the main ones:
There are a few more exotic ones. Sometimes build scripts or libraries require different libraries on linux and on mac (I found a few: Sometimes it was not noticed on mac, because the build is done on a clean CI, but we had some users on Linux complaining about opportunistic linking with libraries installed outside of brew while building from source: this made us add more dependencies (or try to disable these features when possible) over time to avoid build failures. Maybe some of these are not necessary anymore and can be cleaned up. But stuff like I had a look at linuxbrew-core, there are still many cases were we could use One thing which is also linux-only right now are the xorg libraries, but this should be fixed once xorg is merged into homebrew-core. |
This looks like
This is a
This may be a bit of a
This seem legitimately Linux-only dependencies (clue is in the name, I guess 😂). I think I'd prefer a
Yeh, these seem like ones that don't warrant being different on macOS and Linux.
Yeh, this is another case where I suspect that macOS and Linux will want to unify the formulae. I think (given what's happened with Thoughts? |
I'll get on and sync both of these then!
I also thought this, but there are some |
@issyl0 Yes but I think higher priority: would you (or anyone else here) be able to work on a |
That would be great. It's not the topic of this PR, this can be done in parallel. But definitively needed. Of course if we want to whitelist the linux only dependencies, it would be great to have the mac whitelist implemented upfront, so we can extend that whitelist mechanism for this Linux PR too).
I would not misuse
I always wondered how this worked on mac. The .pc files are there, but no pkg-config is delivered by the system? I would be ok to use
I am fine to have a whitelist, to keep this under control. I still disagree about the syntax: |
I believe
Well, they don't "need" it as they are building fine 😉. I'm not as allergic to the system LibreSSL as some maintainers (past at least) have been so I think it's worth leaving as-is.
Yup, that's intentional. I don't think the underlying method of implementation needs to be consistent between macOS and Linux. We may end up with a need for
|
I would recommend not using See for example https://github.com/Homebrew/linuxbrew-core/blob/master/Formula/sratoolkit.rb uses_from_macos "libxml2"
uses_from_macos "perl"
depends_on "pkg-config" => :build unless OS.mac? On macOS |
Yes, there are 18 occurrences of dependencies needed on macOS but not on Linux. |
Another option (considering, as you've pointed out, the need for macOS or Linux-specific patches) would be a macos do
depends_on ...
patch ...
end
linux do
depends_on ...
patch ...
end We've already had that in the past due to |
It won't be any different from what we are doing right now, just a change from |
I think I like it, because it solves the patch and the depends_on issue quite nicely. If everyone agrees on that syntax I'll work on that. |
It is a bit different: I still think This pattern can also work in e.g. |
I suggested Now on to the bike shedding, I have a mild preference for |
I tested the new blocks with dependencies and patches. I can also add a test for resources? Are there other things we might want to test? I'll split the tests I wrote in more smaller subtests if there is is more content to be added. What do you think? |
I have a process question. What's the plan for using this in the wild? Because switching over |
If that's something you'll need in linuxbrew-core: do it 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good (and implementation is nicely simple).
I added the doc, and extended the tests. @issyl0 lets discuss the process somewhere else than this PR :) |
Sudden thought:
|
They'll be handled as-is with the current functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Looks good, nice work @iMichka! |
Thanks! |
I am working on adding an audit for this. I need more opinions. The tests in this PR were written with the idea in my mind that there would be multiple @MikeMcQuaid proposed an alternative, with only one single block, like a
What do you think? |
I did a bit of playing around with this in a tap and got something like this which does install cleanly. It's a bit weird at first glance, but on reflection, I do like that everything is in its place and near to the "normal" locations of |
I like that example (except I'd have the OS-specific stuff lower down but we can debate that later).
I think we want to allow something like that but what I'd do would be: def caveats
on_macos do
"gds-cli depends on aws-vault being installed. You can install it with `brew cask install aws-vault`."
end
end |
This will allow to bring homebrew-core and linuxbrew-core closer together.
See #7028
brew style
with your changes locally?brew tests
with your changes locally?