# -*- 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    HexFiend HexFiend 2.16.0 v
checksums       rmd160  f8fc576c829919d805f80049f2ef928bc49a0aee \
                sha256  c362fa3bc5fdf20ce965913ef17f171b918dbea04e5abaef95a34df3dc51c4fb \
                size    4630697

epoch           1
categories      editors aqua
maintainers     {cal @neverpanic} openmaintainer
license         BSD

long_description \n\
    * Insert, delete, rearrange. Hex Fiend is not limited to in-place changes like some hex editors.\n\
    * Work with huge files. Hex Fiend can handle as big a file as you're able to create. It's been tested on files as \
      large as 118 GB.\n\
    * Small footprint. Hex Fiend does not need to keep your files in memory. You won't dread launching or working with \
       Hex Fiend even on low-RAM machines.\n\
    * Fast. Open a huge file, scroll around, copy and paste, all instantly. Find what you're looking for with fast \
       searching.\n\
    * Smart saving. Hex Fiend knows not to waste time overwriting the parts of your files that haven't changed.\n\
    * Data inspector. Interpret data as integer or floating point, signed or unsigned, big or little endian...\n\
    * Smooth scrolling. No separate pages - scroll like any text document.

supported_archs x86_64 arm64

patch.pre_args  -p1
if {${os.platform} eq "darwin"} {
    if {${os.major} == 17} {
        patchfiles      patch-enable-build-on-high-sierra.diff
    } else {
        patchfiles      patch-xcode-disable-sparkle.diff
    }
}

description     HexFiend is a fast and clever hex editor

xcode.scheme        Release
xcode.configuration Release
xcode.build.settings \
    CODE_SIGN_IDENTITY=- \
    CODE_SIGN_STYLE=Manual
build.pre_args -derivedDataPath ${worksrcpath}

destroot {
    copy "${worksrcpath}/build/Release/Hex Fiend.app" ${destroot}${applications_dir}
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/License.txt ${destroot}${prefix}/share/doc/${name}
}

if {${os.platform} ne "darwin" || ${os.major} < 17} {
    pre-fetch {
        ui_error "${subport} @${version} only works with macOS 10.13 High Sierra or later."
        return -code error "incompatible macOS version"
    }
}
