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

PortSystem          1.0
PortGroup           github 1.0

github.setup        facebook xctool 0.3.7
revision            0
checksums           rmd160  5edb9d2e0eaddf4e02fd3cb4fbb6a0e30d3bc4a9 \
                    sha256  608522865dc42959a6240010c8295ce01278f4b7a8276d838f21a8973938206d \
                    size    8417193

categories          devel
platforms           darwin
license             Apache-2
maintainers         nomaintainer

description         An extension for Apple's xcodebuild that makes it easier to \
                    test iOS and macOS apps.
long_description    {*}${description}

github.tarball_from archive

use_configure       no
use_xcode           yes

# put everything into libexec since the binaries seem not to be user facing
# (i.e. only xctool is run by the user and flags like -reporter will run a
# binary underneath the hood)
build {
    system -W ${worksrcpath} "./scripts/build.sh XT_INSTALL_ROOT=${destroot}${prefix}/libexec/xctool/ -IDECustomDerivedDataLocation=${worksrcpath}/custombuild"
}

destroot {
    foreach f [glob -tails -directory ${destroot}${prefix}/libexec/xctool/lib *.dylib] {
        system "install_name_tool -id ${prefix}/libexec/xctool/lib/$f ${destroot}${prefix}/libexec/xctool/lib/$f"
    }
    ln -s ${prefix}/libexec/xctool/bin/xctool ${destroot}${prefix}/bin/xctool
}
