# -*- 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.2
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  c8d6ab392743aa68155a3ca5a0fc4487a0f7dc08 \
                 sha256  38199f56fe22f2235e76799191d5b9516e360369c61b6ba4411398d5d5920bab \
                 size    217963426
} elseif {${configure.build_arch} eq "arm64"} {
    distname     dartsdk-macos-arm64-release
    checksums    rmd160  7c7aa89864219f557e702fd7e008d140c74c5056 \
                 sha256  cd8753928e77b6b665bd70dce0e64b4ec6d2e2fde141d6409bb716c8ac1f1c0a \
                 size    215274228
}

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.\]+)\""
