Different versions per swift version in Portfile
Andrew Udvare
audvare at gmail.com
Tue May 25 06:56:42 UTC 2021
> On 2021-05-25, at 02:22, 조성빈 <goranmoomin at daum.net> wrote:
>
> Thanks for the helpful advice!
>
> I’ve incorporated some changes from your suggestions, e.g. adding subports.
> However I’m not sure if I’m writing idiomatic port files…
> Could you skim my portfile attached and check if there’s any glaring mistakes?
>
> I’m guessing I should also have a swift-format54 subport.
> Is there any way to do something like aliasing the main port to a specific subport?
> It doesn’t feel right to have logic for Swift 5.4 outside the swift-format54 subport body…
I don't know if there's a way to alias, but normally the top level gets no suffix and it usually is latest. You could also make it the -devel release (latest Git HEAD), and have swift-format54 subport be the latest stable.
>
>>>
>
> Should I also be checking the maximum version?
> E.g., AFAIK swift-format53 won’t work with Xcode 12.5 or later, should I check this too?
Yes. Also you should add "known_fail yes" in that block. Similar to this: https://github.com/macports/macports-ports/blob/d275a24edbefe7f361f2aa6eb8f59648092058c0/graphics/Paintbrush/Portfile#L29
>
>
> Would not supporting older platforms, e.g. supporting only the latest version of Swift make it a blocker to adding this to the main repo? The attached file Portfile.bkup was the one I was originally using without the subports…
I do not think so. You are not really obligated to provide older versions for a new package. You can mark your port as openmaintanier to allow others to make changes without your approval.
For a first version it may be okay. I think at this point you can submit a PR and will get good feedback.
A minor issue is that the build phase pulls in other dependencies via Git (which by the way does not add a "depends_build-append port:git" because Xcode comes with Git). You could have MacPorts handle these as separate packages (which is going to be very difficult) or you could pull in the repositories as part of the fetch (or similar) phase in MacPorts. I do this often with projects that use submodules.
Example: on these lines I specify the tarballs and distfiles (note the suffixes :swda and :swiftcli)
https://github.com/Tatsh/ports/blob/master/aqua/SwiftDefaultApps/Portfile#L20
In my pre-configure phase, I copy the submodule files to their expected location.
https://github.com/Tatsh/ports/blob/master/aqua/SwiftDefaultApps/Portfile#L46
In your case, the swift-format package looks for a SWIFTCI_USE_LOCAL_DEPS environment variable. You can put extracted tarball contents of swift-syntax and swift-argument-parser in the directory behind ${worksrcpath} (${worksrcpath}/..).
https://github.com/apple/swift-format/blob/main/Package.swift#L139
You can set this variable with:
build.env-append SWIFTCI_USE_LOCAL_DEPS=yes
>
> Thanks.
No problem.
--
Andrew
More information about the macports-users
mailing list