# -*- 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
PortGroup           github 1.0

github.setup        ninxsoft mist-cli 2.3 v
github.tarball_from archive
revision            0

platforms           {darwin >= 20}
supported_archs     arm64 x86_64

categories          sysutils
license             MIT
maintainers         {pguyot @pguyot} openmaintainer

description         A Mac command-line tool to download macOS Firmwares and Installers
long_description    {*}${description}

checksums           rmd160  55638d0bbf6005dc6bdd265b4331e6f8be76fa77 \
                    sha256  734bf8305a0005af2032a948689ca66352bcbe99e3779464db3607c17f3d9348 \
                    size    1725754

post-extract {
    reinplace "s|swift-tools-version:6.3.1|swift-tools-version:5.10|" \
        ${worksrcpath}/Package.swift
    # swift-argument-parser 1.8+ uses swift-tools-version:6.0 which enables
    # strict concurrency checks that fail against the macOS 14 SDK
    reinplace {s|from: "1.8.2"|.upToNextMinor(from: "1.7.1")|} \
        ${worksrcpath}/Package.swift
}

# Clearing CPATH because of header conflicts when using swiftPM build system
compiler.cpath

use_configure       no
use_xcode           yes

build.cmd           swift
build.target        build
build.args          --configuration release --disable-sandbox \
                    --cache-path ${workpath}/.swiftpm/cache \
                    --security-path ${workpath}/.swiftpm/security \
                    --config-path ${workpath}/.swiftpm/config

destroot {
    xinstall -m 755 ${worksrcpath}/.build/release/mist ${destroot}${prefix}/bin/
}
