# -*- 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
# $Id$

PortSystem          1.0
PortGroup           github 1.0

github.setup        jpsim SourceKitten 0.14.1
categories          devel
platforms           darwin

universal_variant   no
license             MIT
maintainers         sean openmaintainer

description         An adorable little framework and command line tool for \
                    interacting with SourceKit.
long_description    ${description}

# Fetch from git instead of distfile because it needs submodules
fetch.type          git

use_configure       no
# everything is built during the prefix_install target
build               {}

destroot {
    file mkdir ${destroot}${prefix}/Frameworks/
    system -W ${worksrcpath} "${build.cmd} prefix_install PREFIX=${destroot}${prefix} TEMPORARY_FOLDER=${destroot} XCODEFLAGS=\"-workspace 'SourceKitten.xcworkspace' -scheme 'sourcekitten' DSTROOT=${destroot} -IDECustomDerivedDataLocation=${worksrcpath}/custombuild OTHER_LDFLAGS='-Wl,-headerpad_max_install_names'\""
}

post-destroot {
    delete ${destroot}${prefix}/var
    xinstall -d ${destroot}${prefix}/Library
    move ${destroot}${prefix}/Frameworks ${destroot}${prefix}/Library/
    system -W ${destroot}${prefix}/bin "install_name_tool -add_rpath @executable_path/../Library/Frameworks sourcekitten"
    system -W ${destroot}${prefix}/bin "install_name_tool -add_rpath @executable_path/../Library/Frameworks/SourceKittenFramework.framework/Versions/Current/Frameworks sourcekitten"
}