Question about `platforms` and `${os.platform}`

Ryan Schmidt ryandesign at
Mon Dec 13 19:26:04 UTC 2021

On Dec 11, 2021, at 18:42, Jason Liu wrote:

> On Sat, Dec 11, 2021 at 5:46 PM Ryan Schmidt wrote:
>> I wouldn't expect you to need to write more than a couple such conditionals in a portfile so I wouldn't expect it to be that inconvenient.
> Actually, I find myself needing to use them more and more. For example, I now often have to check for macOS < 10.12, due to the large overhaul that happened in AppKit between 10.11 and 10.12. My workarounds for older versions of macOS are contained inside those `if {${os.major} <= 15}` conditionals.

Ok, so that's one conditional.

If you need multiple different Darwin os.major conditionals, you could:

platform darwin {
    if {${os.major} <= 15} {
        # something
    if {${os.major} <= 19} {
        # something

Before you mentioned the AppKit overhaul some time ago and started addressing it in your ports, I had never heard of it and I don't think anyone else's ports do anything about it. So either we have a lot of broken ports due to this problem that we're not aware of, or for some reason it uniquely affects the ports you maintain...

>> Josh did recently commit "darwin" as a default for platforms, so it is no longer mandatory to explicitly put a platforms line in each portfile.
> Does this mean that we can start removing `platforms darwin` from our portfiles? Or is it one of those "despite the fact that it's a default, you have to put it in the file anyway"?

I have seen many recent commits in which the "platforms darwin" line is silently being removed while other changes are being made, so sure, that's fine.

More information about the macports-dev mailing list