# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0

name                dotnet-runtime-devel
set main_version    11.0.0
# See patch version in https://dotnet.microsoft.com/download/dotnet/10.0
set patch_version   rc.2.26504.105
version             ${main_version}-${patch_version}
revision            0
categories          dotnet
license             MIT
maintainers         @BjarneDMat {@judaew judaew} openmaintainer

description         .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

long_description    .NET is a free, cross-platform, open source developer platform \
                    for building many different types of applications. \
                    \
                    With .NET, you can use multiple languages, editors, and libraries \
                    to build for web, mobile, desktop, games, and IoT.

homepage            https://dotnet.microsoft.com/
platforms           {darwin any} {darwin >= 21}
supported_archs     x86_64 arm64

switch ${build_arch} {
    x86_64 {
        distname            dotnet-runtime-${version}-osx-x64
        checksums           rmd160  8a6f930e5d68879021d47d3b57a88e6601ffccff \
                            sha256  ec56435eac948c020d2b91cd80ddde64b39847b2095758a901bfc35d16b5078e \
                            size    37224687
    }
    arm64 {
        distname            dotnet-runtime-${version}-osx-arm64
        checksums           rmd160  2608bb1ffa7f89e40d2a80f46fee690688a045e0 \
                            sha256  7afec6b40a4d1c8cb7e57e76267bd6323f0b0f4307d9b1c0328ebf72f29df1aa \
                            size    34663403
    }
    default {
        known_fail yes
        pre-fetch {
            ui_error "${subport} @ ${version} only supported for architectures ${supported_archs}"
            return -code error "Unsupported architecture: ${build_arch}"
        }
    }
}

master_sites        https://builds.dotnet.microsoft.com/dotnet/Runtime/${version}/

worksrcdir          ${name}-${version}
extract.mkdir       yes

use_configure       no

depends_run         port:dotnet-cli

build {}

destroot {
    set dotnet_home ${prefix}/share/dotnet
    set hostfxr_dir /host/fxr
    set runtime_dir /shared/Microsoft.NETCore.App
    xinstall -d ${destroot}${dotnet_home}${hostfxr_dir}
    xinstall -d ${destroot}${dotnet_home}${runtime_dir}

    move ${worksrcpath}${hostfxr_dir}/${version} ${destroot}${dotnet_home}${hostfxr_dir}
    move ${worksrcpath}${runtime_dir}/${version} ${destroot}${dotnet_home}${runtime_dir}
}

livecheck.version   [join [lrange [split ${patch_version} .] 0 0] .]
livecheck.type      regex
livecheck.url       https://dotnet.microsoft.com/download/dotnet/10.0
livecheck.regex     ".NET Runtime ${main_version}-(\\d)"
