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

set argon2_hash         b31aa322566a8559403d419b2e9cd3f57957e394

github.setup            MacPass KeePassKit 3.3.2
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
categories              security
license                 GPL-3+
maintainers             nomaintainer
description             KeePass database loading, storing and manipulation framework.
long_description        ${name} is a framework to offer support for the Keepass database format. \
                        You can use it to work with KDB and KDBX files. Supported formats are KDB3, KDBX3.1 and KDBX4.

master_sites            ${github.homepage}/archive:keepasskit \
                        https://github.com/P-H-C/phc-winner-argon2/archive:argon2

distfiles               ${version}.tar.gz:keepasskit \
                        ${argon2_hash}.tar.gz:argon2

checksums               ${version}.tar.gz \
                        rmd160  dce1e97aea76ed0781a8a0dd6cecc34af7b7bcda \
                        sha256  da782fe500978374f9b3bd5003d513233b88f0d65ee2b78fce59fd6d5fb3021d \
                        size    24525057 \
                        ${argon2_hash}.tar.gz \
                        rmd160  fe3ad7f6fdff4a91e7a1acf392d3d4ec5693e506 \
                        sha256  c31776881e09f55d537a8f2854f532961392b3d8ecf58d529729ff6d31150e8d \
                        size    1503597

post-extract {
    file delete -force ${worksrcpath}/Argon2
    move ${workpath}/phc-winner-argon2-${argon2_hash} ${worksrcpath}/Argon2
}

depends_lib             port:KissXML \
                        port:libxml2

xcode.scheme            {KeePassKit macOS}
xcode.configuration     Release
xcode.destroot.type     framework

xcode.destroot.settings CODE_SIGN_STYLE=Manual \
                        CODE_SIGN_IDENTITY=- \
                        ENABLE_HARDENED_RUNTIME=NO \
                        ONLY_ACTIVE_ARCH=YES \
                        HEADER_SEARCH_PATHS=${prefix}/include/libxml2 \
                        FRAMEWORK_SEARCH_PATHS=${frameworks_dir} \
                        SKIP_INSTALL=NO \
                        INSTALL_DIR=${destroot}${frameworks_dir} \
                        LD_DYLIB_INSTALL_NAME=${frameworks_dir}/${name}.framework/Versions/A/${name}

# xcode PortGroup sets the DerivedData to /var/root/... which is not writeable. This fixes it.
destroot.pre_args-append -derivedDataPath ./DerivedData

# Building will be done in the destroot phase.
# See https://trac.macports.org/ticket/57137
build {}