Re: Using platforms in 2.8.0

2022-10-31 Thread Joshua Root

On 2022-11-1 13:41 , Nils Breunese wrote:

Joshua Root  wrote:

According to https://guide.macports.org/#reference.variables ${os.arch} is 
either “powerpc”, “i386”, or “arm”. Does this mean all Intel machines have 
${os.arch} set to ‘i386', regardless of whether they’re 32 or 64 bit machines, 
or is it possible to distinguish 32 and 64 bit Intel machines based on 
${os.arch}? What is the output of `uname -p` on a 64-bit Intel Mac?


That's right, `uname -p` outputs i386 on x86_64 Macs.


In some of the ports I maintain no building is going on, but the port does need 
to know whether to install files for 32-bit Intel, 64-bit Intel or 64-bit ARM. 
Is that possible using platform variants, or does that indeed require checking 
${configure.build_arch}?


You need to check ${configure.build_arch}, because that is not 
restricted to a single value on most OS versions, so there is no 1:1 
correspondence between ${os.arch} and the architecture you should be 
installing the port for. A user on an arm machine could ask for x86_64, 
and a user on an x86_64 machine could ask for i386.


- Josh


Re: Using platforms in 2.8.0

2022-10-31 Thread Nils Breunese
Joshua Root  wrote:

> On 2022-11-1 13:31 , Nils Breunese wrote:
>> Joshua Root  wrote:
>>> On 2022-11-1 11:45 , Nils Breunese wrote:
>>> 
 So when a port installs one pre-built binary on x86_64 and another on 
 arm64, regardless of OS version, setting 'platforms {darwin any}’ would be 
 appropriate and correct?
>>> 
>>> Sure. Unless the x86_64 binary was built targeting 10.5 though, you 
>>> probably also need to restrict the versions. E.g. if the binary works on 
>>> 10.12 and later:
>>> 
>>> platforms {darwin any} {darwin >= 16}
>> Should that be ‘platforms {darwin >= 16}’? If not, I don’t really understand 
>> the syntax above yet.
> 
> The {darwin any} is what makes a single binary archive shared between all OS 
> versions possible. Without it, separate archives for darwin_16, darwin_17, 
> and so on would be built.
> 
> Being able to say {darwin any >= 16} might be clearer, but unfortunately that 
> isn't accepted currently.

The fact that ‘any’ is not about which versions are supported, but about the 
fact that the resulting archive is identical for all supported versions was 
confusing me when reading that syntax, but I got it now. I also didn’t get from 
the documentation yet that '{darwin any}' and a version range check like 
'{darwin >= 16}' could be combined like that, but that’s good to know.

Thanks, Nils.

Re: Using platforms in 2.8.0

2022-10-31 Thread Joshua Root

On 2022-11-1 13:31 , Nils Breunese wrote:

Joshua Root  wrote:


On 2022-11-1 11:45 , Nils Breunese wrote:


So when a port installs one pre-built binary on x86_64 and another on arm64, 
regardless of OS version, setting 'platforms {darwin any}’ would be appropriate 
and correct?


Sure. Unless the x86_64 binary was built targeting 10.5 though, you probably 
also need to restrict the versions. E.g. if the binary works on 10.12 and later:

platforms {darwin any} {darwin >= 16}


Should that be ‘platforms {darwin >= 16}’? If not, I don’t really understand 
the syntax above yet.


The {darwin any} is what makes a single binary archive shared between 
all OS versions possible. Without it, separate archives for darwin_16, 
darwin_17, and so on would be built.


Being able to say {darwin any >= 16} might be clearer, but unfortunately 
that isn't accepted currently.


- Josh


Re: Using platforms in 2.8.0

2022-10-31 Thread Nils Breunese
Joshua Root  wrote:

> On 2022-11-1 11:40 , Nils Breunese wrote:
>> Joshua Root  wrote:
>>> On 2022-10-22 21:56 , Kirill A. Korinsky wrote:
 I'm asking is there a way to support specified arch inside platform 
 block's condition. Like:
 platform {aarch64}  {
 ...
 }
>>> 
>>> You can certainly do things like:
>>> 
>>> platform darwin arm {
>>> ...
>>> }
>> I wasn’t aware of this platform variants syntax 
>> (https://guide.macports.org/#reference.variants.platform) yet, so today I 
>> learned.
>> I maintain some ports that contain sections that look like this:
>> 
>> if {${configure.build_arch} eq "x86_64"} {
>> distname microsoft-jdk-${version}-macOS-x64
>> checksums rmd160 2fc1a89b2310905e0891bb2b1519c8df86998ab7 \
>> sha256 22697e9bbf3135c0ef843e7f371fe563ea948c6d464dfc532a7995fe32aebb09 \
>> size 187094964
>> } elseif {${configure.build_arch} eq "arm64"} {
>> distname microsoft-jdk-${version}-macOS-aarch64
>> checksums rmd160 feb696c4ba65ea42b68bb578e5e2de7b41e56669 \
>> sha256 c50a20ca8764a5aa54dc0a0cf681d891dadbdccc1051792806d797206d59ba34 \
>> size 184695872
>> }
>> 
>> I thought I’d replace such if-elseif sections with declarative platform 
>> variant blocks, but I noticed that the arch argument for the platform 
>> variant needs to be ‘arm’ instead of ‘arm64’:
>> 
>> platform darwin arm {
>> distname microsoft-jdk-${version}-macOS-aarch64
>> checksums rmd160 feb696c4ba65ea42b68bb578e5e2de7b41e56669 \
>> sha256 c50a20ca8764a5aa54dc0a0cf681d891dadbdccc1051792806d797206d59ba34 \
>> size 184695872
>> }
>> 
>> Why is the arch value for a platform variant not the same as 
>> ${configure.build_arch}? What are the valid values for the arch argument of 
>> a platform variant block? Can I use ‘platform darwin x86_64 { … }’ for the 
>> 64-bit Intel case or is that value also different from 
>> ${configure.build_arch}? I don’t have a x86_64 Mac I can use to test this 
>> myself.
> 
> The arch here is checked against ${os.arch}, which is (at least on darwin) 
> the same as the output of `uname -p`. That is separate to build_arch, which 
> depending on the OS version can often have multiple different valid values. 
> You use 'platform' purely to check what you're running on, not how you're 
> going to be building your code.

According to https://guide.macports.org/#reference.variables ${os.arch} is 
either “powerpc”, “i386”, or “arm”. Does this mean all Intel machines have 
${os.arch} set to ‘i386', regardless of whether they’re 32 or 64 bit machines, 
or is it possible to distinguish 32 and 64 bit Intel machines based on 
${os.arch}? What is the output of `uname -p` on a 64-bit Intel Mac?

In some of the ports I maintain no building is going on, but the port does need 
to know whether to install files for 32-bit Intel, 64-bit Intel or 64-bit ARM. 
Is that possible using platform variants, or does that indeed require checking 
${configure.build_arch}?

Nils.

Re: Using platforms in 2.8.0

2022-10-31 Thread Nils Breunese
Joshua Root  wrote:

> On 2022-11-1 11:45 , Nils Breunese wrote:
> 
>> So when a port installs one pre-built binary on x86_64 and another on arm64, 
>> regardless of OS version, setting 'platforms {darwin any}’ would be 
>> appropriate and correct?
> 
> Sure. Unless the x86_64 binary was built targeting 10.5 though, you probably 
> also need to restrict the versions. E.g. if the binary works on 10.12 and 
> later:
> 
> platforms {darwin any} {darwin >= 16}

Should that be ‘platforms {darwin >= 16}’? If not, I don’t really understand 
the syntax above yet.

I already have Daerwin version checks in place, but I should indeed also be 
able to get rid of those if-statements using this new platforms syntax with 
version check.

Nils.

Re: Using platforms in 2.8.0

2022-10-31 Thread Joshua Root

On 2022-11-1 11:45 , Nils Breunese wrote:

Joshua Root  wrote:


On 2022-11-1 11:14 , Nils Breunese wrote:

Joshua Root  wrote:

There is another way that platforms can be used:

platforms any
platforms {darwin any}

The first one indicates that the port will install identical files no matter what platform it is 
built on, and will set the platform in the archive filename to "any_any". The second one 
indicates that the port will install identical files when built on any version of Darwin, but may 
install different files when built on other platforms, and sets the platform in the archive 
filename to "darwin_any" when on Darwin.

These will usually only be applicable to noarch ports, though rare exceptions may exist. Ports that 
install only data files or scripts will often be able to use "any". Python scripts are an 
exception because Python uses a framework layout on Darwin only, so they will be "{darwin 
any}".

So setting ‘platforms {darwin any}’ is not appropriate when a port installs 
identical files on any Darwin version, but does install different files based 
on arch?


That would be uncommon but it is possible.


So when a port installs one pre-built binary on x86_64 and another on arm64, 
regardless of OS version, setting 'platforms {darwin any}’ would be appropriate 
and correct?


Sure. Unless the x86_64 binary was built targeting 10.5 though, you 
probably also need to restrict the versions. E.g. if the binary works on 
10.12 and later:


platforms   {darwin any} {darwin >= 16}

- Josh


Re: Using platforms in 2.8.0

2022-10-31 Thread Joshua Root

On 2022-11-1 11:40 , Nils Breunese wrote:

Joshua Root  wrote:


On 2022-10-22 21:56 , Kirill A. Korinsky wrote:

I'm asking is there a way to support specified arch inside platform block's 
condition. Like:
platform {aarch64}  {
...
}


You can certainly do things like:

platform darwin arm {
...
}


I wasn’t aware of this platform variants syntax 
(https://guide.macports.org/#reference.variants.platform) yet, so today I 
learned.

I maintain some ports that contain sections that look like this:


if {${configure.build_arch} eq "x86_64"} {
distnamemicrosoft-jdk-${version}-macOS-x64
checksums   rmd160  2fc1a89b2310905e0891bb2b1519c8df86998ab7 \
sha256  
22697e9bbf3135c0ef843e7f371fe563ea948c6d464dfc532a7995fe32aebb09 \
size187094964
} elseif {${configure.build_arch} eq "arm64"} {
distnamemicrosoft-jdk-${version}-macOS-aarch64
checksums   rmd160  feb696c4ba65ea42b68bb578e5e2de7b41e56669 \
sha256  
c50a20ca8764a5aa54dc0a0cf681d891dadbdccc1051792806d797206d59ba34 \
size184695872
}


I thought I’d replace such if-elseif sections with declarative platform variant 
blocks, but I noticed that the arch argument for the platform variant needs to 
be ‘arm’ instead of ‘arm64’:


platform darwin arm {
distnamemicrosoft-jdk-${version}-macOS-aarch64
checksums   rmd160  feb696c4ba65ea42b68bb578e5e2de7b41e56669 \
sha256  
c50a20ca8764a5aa54dc0a0cf681d891dadbdccc1051792806d797206d59ba34 \
size184695872
}


Why is the arch value for a platform variant not the same as 
${configure.build_arch}? What are the valid values for the arch argument of a 
platform variant block? Can I use ‘platform darwin x86_64 { … }’ for the 64-bit 
Intel case or is that value also different from ${configure.build_arch}? I 
don’t have a x86_64 Mac I can use to test this myself.


The arch here is checked against ${os.arch}, which is (at least on 
darwin) the same as the output of `uname -p`. That is separate to 
build_arch, which depending on the OS version can often have multiple 
different valid values. You use 'platform' purely to check what you're 
running on, not how you're going to be building your code.


- Josh


Re: Using platforms in 2.8.0

2022-10-31 Thread Nils Breunese
Joshua Root  wrote:

> On 2022-11-1 11:14 , Nils Breunese wrote:
>> Joshua Root  wrote:
>>> There is another way that platforms can be used:
>>> 
>>> platforms any
>>> platforms {darwin any}
>>> 
>>> The first one indicates that the port will install identical files no 
>>> matter what platform it is built on, and will set the platform in the 
>>> archive filename to "any_any". The second one indicates that the port will 
>>> install identical files when built on any version of Darwin, but may 
>>> install different files when built on other platforms, and sets the 
>>> platform in the archive filename to "darwin_any" when on Darwin.
>>> 
>>> These will usually only be applicable to noarch ports, though rare 
>>> exceptions may exist. Ports that install only data files or scripts will 
>>> often be able to use "any". Python scripts are an exception because Python 
>>> uses a framework layout on Darwin only, so they will be "{darwin any}".
>> So setting ‘platforms {darwin any}’ is not appropriate when a port installs 
>> identical files on any Darwin version, but does install different files 
>> based on arch?
> 
> That would be uncommon but it is possible.

So when a port installs one pre-built binary on x86_64 and another on arm64, 
regardless of OS version, setting 'platforms {darwin any}’ would be appropriate 
and correct?

Nils.

Re: Using platforms in 2.8.0

2022-10-31 Thread Joshua Root

On 2022-11-1 11:14 , Nils Breunese wrote:

Joshua Root  wrote:


There is another way that platforms can be used:

platforms any
platforms {darwin any}

The first one indicates that the port will install identical files no matter what platform it is 
built on, and will set the platform in the archive filename to "any_any". The second one 
indicates that the port will install identical files when built on any version of Darwin, but may 
install different files when built on other platforms, and sets the platform in the archive 
filename to "darwin_any" when on Darwin.

These will usually only be applicable to noarch ports, though rare exceptions may exist. Ports that 
install only data files or scripts will often be able to use "any". Python scripts are an 
exception because Python uses a framework layout on Darwin only, so they will be "{darwin 
any}".


So setting ‘platforms {darwin any}’ is not appropriate when a port installs 
identical files on any Darwin version, but does install different files based 
on arch?


That would be uncommon but it is possible.

- Josh


Re: Using platforms in 2.8.0

2022-10-31 Thread Nils Breunese
Joshua Root  wrote:

> On 2022-10-22 21:56 , Kirill A. Korinsky wrote:
>> I'm asking is there a way to support specified arch inside platform block's 
>> condition. Like:
>> platform {aarch64}  {
>> ...
>> }
> 
> You can certainly do things like:
> 
> platform darwin arm {
> ...
> }

I wasn’t aware of this platform variants syntax 
(https://guide.macports.org/#reference.variants.platform) yet, so today I 
learned.

I maintain some ports that contain sections that look like this:


if {${configure.build_arch} eq "x86_64"} {
distnamemicrosoft-jdk-${version}-macOS-x64
checksums   rmd160  2fc1a89b2310905e0891bb2b1519c8df86998ab7 \
sha256  
22697e9bbf3135c0ef843e7f371fe563ea948c6d464dfc532a7995fe32aebb09 \
size187094964
} elseif {${configure.build_arch} eq "arm64"} {
distnamemicrosoft-jdk-${version}-macOS-aarch64
checksums   rmd160  feb696c4ba65ea42b68bb578e5e2de7b41e56669 \
sha256  
c50a20ca8764a5aa54dc0a0cf681d891dadbdccc1051792806d797206d59ba34 \
size184695872
}


I thought I’d replace such if-elseif sections with declarative platform variant 
blocks, but I noticed that the arch argument for the platform variant needs to 
be ‘arm’ instead of ‘arm64’:


platform darwin arm {
distnamemicrosoft-jdk-${version}-macOS-aarch64
checksums   rmd160  feb696c4ba65ea42b68bb578e5e2de7b41e56669 \
sha256  
c50a20ca8764a5aa54dc0a0cf681d891dadbdccc1051792806d797206d59ba34 \
size184695872
}


Why is the arch value for a platform variant not the same as 
${configure.build_arch}? What are the valid values for the arch argument of a 
platform variant block? Can I use ‘platform darwin x86_64 { … }’ for the 64-bit 
Intel case or is that value also different from ${configure.build_arch}? I 
don’t have a x86_64 Mac I can use to test this myself.

Nils.

Re: Using platforms in 2.8.0

2022-10-31 Thread Nils Breunese
Joshua Root  wrote:

> There is another way that platforms can be used:
> 
> platforms any
> platforms {darwin any}
> 
> The first one indicates that the port will install identical files no matter 
> what platform it is built on, and will set the platform in the archive 
> filename to "any_any". The second one indicates that the port will install 
> identical files when built on any version of Darwin, but may install 
> different files when built on other platforms, and sets the platform in the 
> archive filename to "darwin_any" when on Darwin.
> 
> These will usually only be applicable to noarch ports, though rare exceptions 
> may exist. Ports that install only data files or scripts will often be able 
> to use "any". Python scripts are an exception because Python uses a framework 
> layout on Darwin only, so they will be "{darwin any}".

So setting ‘platforms {darwin any}’ is not appropriate when a port installs 
identical files on any Darwin version, but does install different files based 
on arch?

Nils.

Re: Using platforms in 2.8.0

2022-10-22 Thread Marius Schamschula
I haven’t tried to build MacPorts 2.8.0 under FreeBSD (the source tarball gives 
a 404), but I last tried 2.7.2 built and it installed cleanly, but was unusable 
as portindex failed. I could debug to the point where it failed, but never 
could figure out what was going on.

Marius
--
Marius Schamschula




> On Oct 22, 2022, at 3:50 AM, Joshua Root  wrote:
> 
> MacPorts 2.8.0 lets you specify which OS versions your ports work on via the 
> platforms option. This indicates a port that works on darwin versions from 
> 10.x to 19.x inclusive:
> 
> platforms {darwin >= 10 < 20}
> 
> Most ports will probably only need one comparison, but you can have as many 
> as you need. Operators supported are ==, !=, >, <, >= and <=. For == and !=, 
> a string comparison that allows globs is used. For the rest, vercmp is used. 
> If any comparison doesn't match, known_fail is set to yes.
> 
> Note that the comparison is against ${os.version}, not ${os.major}, so you'll 
> usually want to use e.g. < 20 for the upper bound rather than <= 19 (the 
> latter would exclude all 19.x versions).
> 
> These are all valid:
> 
> platforms {darwin >= 11}
> platforms {darwin < 19} freebsd
> platforms {darwin >= 16 != 18.2.* < 23} {linux != *}
> 
> The second one indicates FreeBSD support in a purely informational way, as 
> per the usage of the platforms option in older MacPorts versions. The last 
> one indicates that it doesn't work on Linux and will set known_fail there. 
> Again, most ports will probably only use something like the first example, 
> but the flexibility is there if you need it.
> 
> All of the above can be used without making your Portfile incompatible with 
> 2.7. There is another way that platforms can be used:
> 
> platforms any
> platforms {darwin any}
> 
> The first one indicates that the port will install identical files no matter 
> what platform it is built on, and will set the platform in the archive 
> filename to "any_any". The second one indicates that the port will install 
> identical files when built on any version of Darwin, but may install 
> different files when built on other platforms, and sets the platform in the 
> archive filename to "darwin_any" when on Darwin.
> 
> These will usually only be applicable to noarch ports, though rare exceptions 
> may exist. Ports that install only data files or scripts will often be able 
> to use "any". Python scripts are an exception because Python uses a framework 
> layout on Darwin only, so they will be "{darwin any}".
> 
> Since the archive filename is changed, using this will of course prevent 
> users on older MacPorts versions from using the archives. So we would 
> normally wait 2 weeks after the release of 2.8.0 before starting to use this 
> feature.
> 
> However, with the release of Ventura in a couple days, it may pay to set 
> these platforms values on as many eligible ports as possible, both to make 
> the archives available to Ventura users even before we have a Ventura 
> buildbot worker up and running, and to reduce the load on that worker once it 
> is up.
> 
> - Josh



Re: Using platforms in 2.8.0

2022-10-22 Thread Kirill A. Korinsky via macports-dev
clear, thanks

--
wbr, Kirill

> On 22. Oct 2022, at 13:03, Joshua Root  wrote:
> 
> On 2022-10-22 21:56 , Kirill A. Korinsky wrote:
>> I'm asking is there a way to support specified arch inside platform block's 
>> condition. Like:
>> platform {aarch64}  {
>> ...
>> }
> 
> You can certainly do things like:
> 
> platform darwin arm {
> ...
> }
> 
> or:
> 
> if {$build_arch eq "arm64"} {
> ...
> }
> 
> There is no arch comparison possible in the platforms option, because that 
> job is already being done by the supported_archs option. If you have some 
> really complicated compatibility requirement that can't be expressed any 
> other way, I guess you can set platforms differently based on the arch, or 
> supported_archs differently based on the platform.
> 
> - Josh



signature.asc
Description: Message signed with OpenPGP


Re: Using platforms in 2.8.0

2022-10-22 Thread Joshua Root

On 2022-10-22 21:56 , Kirill A. Korinsky wrote:
I'm asking is there a way to support specified arch inside platform 
block's condition. Like:


platform {aarch64}  {
...
}


You can certainly do things like:

platform darwin arm {
...
}

or:

if {$build_arch eq "arm64"} {
...
}

There is no arch comparison possible in the platforms option, because 
that job is already being done by the supported_archs option. If you 
have some really complicated compatibility requirement that can't be 
expressed any other way, I guess you can set platforms differently based 
on the arch, or supported_archs differently based on the platform.


- Josh


Re: Using platforms in 2.8.0

2022-10-22 Thread Kirill A. Korinsky via macports-dev
I'm asking is there a way to support specified arch inside platform block's 
condition. Like:

platform {aarch64}  {
...
}

--
wbr, Kirill

> On 22. Oct 2022, at 12:55, Joshua Root  wrote:
> 
> On 2022-10-22 20:34 , Kirill A. Korinsky wrote:
>> Does it support somehow arch?
> 
> I'm not sure what you're asking exactly. There was already the 
> supported_archs option of course, and either a specific set of archs or 
> "noarch" is included in the archive filename.
> 
> - Josh



signature.asc
Description: Message signed with OpenPGP


Re: Using platforms in 2.8.0

2022-10-22 Thread Joshua Root

On 2022-10-22 20:34 , Kirill A. Korinsky wrote:

Does it support somehow arch?


I'm not sure what you're asking exactly. There was already the 
supported_archs option of course, and either a specific set of archs or 
"noarch" is included in the archive filename.


- Josh


Re: Using platforms in 2.8.0

2022-10-22 Thread Kirill A. Korinsky via macports-dev
Does it support somehow arch?

--
wbr, Kirill

> On 22. Oct 2022, at 10:50, Joshua Root  wrote:
> 
> MacPorts 2.8.0 lets you specify which OS versions your ports work on via the 
> platforms option. This indicates a port that works on darwin versions from 
> 10.x to 19.x inclusive:
> 
> platforms {darwin >= 10 < 20}
> 
> Most ports will probably only need one comparison, but you can have as many 
> as you need. Operators supported are ==, !=, >, <, >= and <=. For == and !=, 
> a string comparison that allows globs is used. For the rest, vercmp is used. 
> If any comparison doesn't match, known_fail is set to yes.
> 
> Note that the comparison is against ${os.version}, not ${os.major}, so you'll 
> usually want to use e.g. < 20 for the upper bound rather than <= 19 (the 
> latter would exclude all 19.x versions).
> 
> These are all valid:
> 
> platforms {darwin >= 11}
> platforms {darwin < 19} freebsd
> platforms {darwin >= 16 != 18.2.* < 23} {linux != *}
> 
> The second one indicates FreeBSD support in a purely informational way, as 
> per the usage of the platforms option in older MacPorts versions. The last 
> one indicates that it doesn't work on Linux and will set known_fail there. 
> Again, most ports will probably only use something like the first example, 
> but the flexibility is there if you need it.
> 
> All of the above can be used without making your Portfile incompatible with 
> 2.7. There is another way that platforms can be used:
> 
> platforms any
> platforms {darwin any}
> 
> The first one indicates that the port will install identical files no matter 
> what platform it is built on, and will set the platform in the archive 
> filename to "any_any". The second one indicates that the port will install 
> identical files when built on any version of Darwin, but may install 
> different files when built on other platforms, and sets the platform in the 
> archive filename to "darwin_any" when on Darwin.
> 
> These will usually only be applicable to noarch ports, though rare exceptions 
> may exist. Ports that install only data files or scripts will often be able 
> to use "any". Python scripts are an exception because Python uses a framework 
> layout on Darwin only, so they will be "{darwin any}".
> 
> Since the archive filename is changed, using this will of course prevent 
> users on older MacPorts versions from using the archives. So we would 
> normally wait 2 weeks after the release of 2.8.0 before starting to use this 
> feature.
> 
> However, with the release of Ventura in a couple days, it may pay to set 
> these platforms values on as many eligible ports as possible, both to make 
> the archives available to Ventura users even before we have a Ventura 
> buildbot worker up and running, and to reduce the load on that worker once it 
> is up.
> 
> - Josh



signature.asc
Description: Message signed with OpenPGP