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

github.setup        ahmetomerv photoc 0.5.0 v
github.tarball_from archive
revision            0

description         Command-line tools for photographers
long_description    photoc helps you review, organize, and prepare photos from \
                    the terminal. It can read metadata, find blurry shots and \
                    exact duplicates, rename and sort photos, make contact \
                    sheets, compress JPEGs, and remove private metadata.

categories          graphics
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} openmaintainer

# Uses clock_gettime and the exclusive rename APIs.
platforms           {darwin >= 16}

checksums           rmd160  59e247195d10ab2aab2017a4d2b656ebb0648af9 \
                    sha256  d63383d580df5c5ec22e77748b8327b2726b82ce98eaebe4734a96a909fa6b5a \
                    size    431526

depends_build-append \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  path:lib/pkgconfig/libexif.pc:libexif \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    path:lib/pkgconfig/libxml-2.0.pc:libxml2

compiler.c_standard 2017
installs_libs       no

post-patch {
    # Do not turn warnings from different compiler versions into build failures.
    reinplace "s/ -Werror//g" ${worksrcpath}/CMakeLists.txt
}

configure.args-append \
                    -DBUILD_TESTING=OFF

variant tests description {Build and run the upstream test suite} {
    depends_build-append \
                    path:bin/python3.14:python314
    configure.args-replace \
                    -DBUILD_TESTING=OFF -DBUILD_TESTING=ON
    configure.args-append \
                    -DPython3_EXECUTABLE=${prefix}/bin/python3.14
    test.run        yes
    test.cmd        ${prefix}/bin/ctest
    test.target
    test.args       --output-on-failure

    pre-test {
        # Destroot creates this as root; the installation test must rewrite it
        # as the unprivileged build user.
        delete ${build.dir}/install_manifest.txt
    }
}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions \
                ${destroot}${prefix}/share/zsh/site-functions \
                ${destroot}${prefix}/share/fish/vendor_completions.d

    xinstall -m 0644 ${worksrcpath}/completions/bash/photoc \
        ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 0644 ${worksrcpath}/completions/zsh/_photoc \
        ${destroot}${prefix}/share/zsh/site-functions
    xinstall -m 0644 ${worksrcpath}/completions/fish/photoc.fish \
        ${destroot}${prefix}/share/fish/vendor_completions.d
}
