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

github.setup        wdas partio 1.14.6 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
categories          graphics
license             BSD
maintainers         @jasonliu-- openmaintainer

homepage            http://partio.us
description         C++ library for manipulating a variety of particle \
                    formats
long_description    Partio is an open-source C++ library, developed by \
                    Walt Disney Animation Studios, for reading, \
                    writing, and manipulating a variety of standard \
                    particle formats (GEO, BGEO, PTC, PDB, PDA). It \
                    allows software applications to read and write \
                    point cloud formats from a variety of computer \
                    graphics programs and can serve as a way to \
                    interchange particle data between various file \
                    formats.

checksums           rmd160  746da72c3b02f4947fbb7ac15dc354622ffd05a5 \
                    sha256  27aba0a59f738c51aae0e1df80a63a6b5fd4282dee8f7b6090156bbf634fa49f \
                    size    336531

# enforce to using the same compiler that is used for osl
set llvm_version    14

# pin the used version for LLVM before 10.13 to
# which is forced by used version of osl
if {${os.platform} eq "darwin" && ${os.major} < 18} {
    set llvm_version    11
}

compiler.blacklist-append clang
compiler.fallback macports-clang-${llvm_version}


depends_build-append \
                    path:bin/doxygen:doxygen \
                    port:clang-$llvm_version \
                    port:swig-python
depends_lib         port:zlib

pre-test {
    if {![variant_isset tests]} {
        ui_error "'tests' variant must be activated to enable test support"
        error "Please enable the 'tests' variant and try again"
    }
}

post-destroot {
    if {![file exists ${destroot}${prefix}/share/${name}/py]} {
        xinstall -d ${destroot}${prefix}/share/${name}/py
    }
    copy ${worksrcpath}/src/py/example \
         ${destroot}${prefix}/share/${name}/py
}

set pythons_suffixes    {38 39 310 311}

set pythons_ports       {}
foreach s ${pythons_suffixes} {
    lappend pythons_ports python${s}
}

foreach s ${pythons_suffixes} {
    set p python${s}
    set v [string index ${s} 0].[string range ${s} 1 end]
    set i [lsearch -exact ${pythons_ports} ${p}]
    set c [lreplace ${pythons_ports} ${i} ${i}]
    variant ${p} description "Build the Python ${v} bindings" conflicts {*}${c} "
        depends_lib-append      port:${p}

        configure.args-append   -DPython3_EXECUTABLE=${prefix}/bin/python${v}
    "
}

set set_python_default  yes
foreach s ${pythons_suffixes} {
    if {[variant_isset python${s}]} {
        set set_python_default  no
    }
}
# this default version should stay synchronized with python_get_default_version
#    in the python PortGroup
if {${set_python_default}} {
    default_variants        +python311
}

variant tests description {Build tests} {
    depends_lib-append      port:gtest
    configure.args-append   GTEST_ENABLED=ON
    test.run    yes

    post-destroot {
        copy ${worksrcpath}/src/data \
             ${destroot}${prefix}/share/${name}/test
    }
}
