Joshua Root <j...@macports.org> wrote:

> On 2022-11-1 11:40 , Nils Breunese wrote:
>> Joshua Root <j...@macports.org> 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.

Reply via email to