# -*- 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                dart-sdk
version             3.12.1
categories          lang
license             BSD
maintainers         {amake @amake} openmaintainer
description         The Dart SDK
long_description    Dart is an open-source, scalable programming language, \
                    with robust libraries and runtimes, for building web, \
                    server, and mobile apps.

platforms           {darwin any}
supported_archs     x86_64 arm64

homepage            https://dart.dev/
master_sites        https://storage.googleapis.com/dart-archive/channels/stable/release/${version}/sdk/

distname            dartsdk-macos-x64-release
use_zip             yes
dist_subdir         ${name}/${version}
worksrcdir          ${name}

if {${configure.build_arch} eq "x86_64"} {
    distname     dartsdk-macos-x64-release
    checksums    rmd160  28e63fdc5c137dc4f4eb89e7045931d2f3cd384f \
                 sha256  c56b322cdbc15e0d7c373970c2e2be53bfb438458bd67c1828703e744acb7916 \
                 size    217963871
} elseif {${configure.build_arch} eq "arm64"} {
    distname     dartsdk-macos-arm64-release
    checksums    rmd160  0a85485cec8e2dd023fed866a865b839120f26d6 \
                 sha256  eaff3823d5a0c5cdcb65b38adf204e5f35290fcd560d48cb47c2fac7e1547b97 \
                 size    215261496
}

use_configure       no
build               {}

destroot {
    set libexecdir ${prefix}/libexec/${name}
    copy ${worksrcpath} ${destroot}${libexecdir}
    ln -s ${libexecdir}/bin/dart ${destroot}${prefix}/bin
    foreach bin [glob -tails -directory ${destroot}${libexecdir}/bin pub dart?*] {
        xinstall -m 0755 ${filespath}/shim.in ${destroot}${prefix}/bin/${bin}
        reinplace "s|@@BIN@@|${libexecdir}/bin/${bin}|g" ${destroot}${prefix}/bin/${bin}
    }
}

livecheck.type      regex
livecheck.url       https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION
livecheck.regex     "\"version\": \"(\[0-9.\]+)\""
