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

github.setup        Sequel-Ace Sequel-Ace 2.3.1
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
license             MIT
categories          aqua devel databases
maintainers         nomaintainer
description         MySQL/MariaDB database management for macOS

long_description \
    a fast, easy-to-use Mac database management application for working with \
    MySQL & MariaDB databases

checksums           md5     af9628bca85ac78697a33166bb7157ee \
                    sha1    30d1daf3fd98cff04fc63f436ca2a68c3e1b0dab \
                    rmd160  ed89d0f560ffd92ce16c22af211fc3f8b4ac6ddf \
                    sha256  277b33627c4c8c840464c3ffca4b8a7395bf6a6b6151d5bd124d2e98c95efedb \
                    size    54568493

minimum_xcodeversions-append {17 10.0}

platforms           {darwin >= 17}

supported_archs     i386 x86_64

use_xcode           yes

pre-configure {
    # This port really needs to use the Xcode SDK, not CLT SDK for some
    # currently unknown reason.
    #
    # With the base logic in portconfigure.tcl there is currently no way to
    # force the selection of an Xcode SDK in the case that Xcode has something
    # newer than the OS: e.g. macOS 10.15 running Xcode 12 will never choose
    # Xcode's MacOSX11.0.sdk and will always choose the CLT MacOSX10.15.sdk.
    #
    # There is no consensus on what can or should be done about this; see
    # https://lists.macports.org/pipermail/macports-dev/2020-November/042621.html
    #
    # Thus we do this hacky thing: at runtime choose the best Xcode SDK
    # possible.
    if {[catch {exec xcrun --sdk macosx${configure.sdk_version} --show-sdk-path 2> /dev/null} sdk]} {
        ui_debug "Failed to find Xcode SDK for macosx${configure.sdk_version}; trying macosx"
        catch {exec xcrun --sdk macosx --show-sdk-path 2> /dev/null} sdk
    }
    if {${sdk} ne ""} {
        ui_debug "Found Xcode SDK ${sdk}"
        configure.sdkroot  ${sdk}
    }
}

xcode.scheme        "Sequel Ace Release Build"
xcode.configuration Release
xcode.build.settings-append \
                    CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO

# Don't set INSTALL_PATH. This build system uses INSTALL_PATH internally to
# link the application and frameworks together with relative paths.
xcode.destroot.type

# This should be removed if/when dealt with in the xcode portgroup; see:
# https://trac.macports.org/ticket/57137
if {[vercmp $xcodeversion 5.0] >= 0} {
    build.pre_args  -derivedDataPath ./DerivedData
}

destroot {
	copy "${worksrcpath}/build/${xcode.configuration}/Sequel Ace.app" \
		${destroot}${applications_dir}
}

github.livecheck.regex  {([^"-]+)}
