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

github.setup            gpilab core-nodes 2.2.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
name                    py-gpilab-core
# Bump to rebuild with latest py-gpilab-framework
revision                0
python.versions         39
license                 {BSD LGPL-3+}
maintainers             {eborisch @eborisch} \
                        openmaintainer
description             Core GPI nodes.

long_description        The core nodes are a collection of basic data \
                        manipulation and visualization algorithms.

homepage                http://gpilab.com

checksums \
    rmd160  3f779a36a2c07263617243431d6ec9fed7177bee \
    sha256  f43c9bc01ed9d7d96ea35f6afbb3c8b4d65f0c16bb1779f70066e4e7569ae099 \
    size    183510

if {${name} ne ${subport} } {
    depends_lib-append      port:py${python.version}-gpilab-framework \
                            port:py${python.version}-qtpy \
                            port:py${python.version}-h5py \
                            port:py${python.version}-matplotlib

    use_configure no

    build {
        set MODS [glob ${worksrcpath}/*/*_PyMOD.cpp]
        foreach mod ${MODS} {
            set D [file dirname ${mod}]
            set M [string range [file tail ${mod}] 0 end-10]
            ln -s ${worksrcpath} ${D}/gpi_core
            system -W ${D} "${prefix}/bin/gpi_make-${python.version} ${M}"
            delete ${D}/gpi_core
        }
        system -W ${worksrcpath} \
            "${prefix}/bin/python${python.branch} -O -m compileall ."
    }

    destroot {
        xinstall -d ${destroot}${prefix}/share/${subport}/

        set PP ${destroot}${python.pkgd}
        xinstall -d ${PP}

        # Normalize hack required due to symlink generation in github portgroup
        file copy [file dirname [file normalize ${worksrcpath}/_]] ${PP}/gpi_core

        system -W ${PP}/gpi_core \
            "mv {AUT,LIC,COP,READ}* ${destroot}${prefix}/share/${subport}"

        delete ${PP}/gpi_core/.gitattributes \
               ${PP}/gpi_core/.gitignore

        fs-traverse pth ${PP}/gpi_core {
            if {[file isfile ${pth}]} {
                if {[string match *build/temp* ${pth}] ||
                    [string match *.c ${pth}] ||
                    [string match *.cpp ${pth}]} {
                    delete ${pth}
                }
            }
        }
    }

    livecheck.type          none
}

