# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           java 1.0

github.setup        arduino Arduino 1.8.19
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball

java.version        1.8
java.fallback       openjdk8

revision            0
categories          devel electronics java lang
maintainers         {gmail.com:giansalvo.gusinu @giansalvo} openmaintainer
license             GPL-2

supported_archs     x86_64

description         Arduino Software (IDE) makes it easy to write code and upload it to the board.

long_description \
    Arduino is an open-source electronics platform based on easy-to-use \
    hardware and software. It's intended for anyone making interactive \
    projects. The Arduino IDE runs on Windows, Mac OS X, and Linux. \
    The environment is written in Java and based on Processing and other \
    open-source software. This software can be used with any Arduino board.

homepage            https://www.arduino.cc/

checksums           rmd160  86d5e9cecd59b93fce1f00217a2c40feed0f8c44 \
                    sha256  85e028db38aaaf593cf02f42c35951b3e0420fd0327b1a8188772006cb5cdbdc \
                    size    34716296

depends_lib         port:apache-ant

use_configure       no

# Arduino requires macOS 10.8 (Mountain Lion, darwin 12) or greater
pre-fetch {
    set check.os.major 12
    if {${os.major} < ${check.os.major}} {
        return -code error "${name} requires macOS 10.8 or greater."
    }
}

build {
    set ::env(JAVA_HOME) [exec /usr/libexec/java_home -v ${java.version}]
    system -W ${worksrcpath}/build "ant build dist -Dplatform=macosx <<<'${version}'"
}

destroot {
    xinstall -d ${destroot}${prefix}/share/${name}
    xinstall -m 755 -W ${worksrcpath} CONTRIBUTING.md README.md license.txt ${destroot}${prefix}/share/${name}

    file copy ${worksrcpath}/build/macosx/work/${name}.app ${destroot}${applications_dir}
}

livecheck.type      regex
livecheck.url       https://github.com/arduino/Arduino/releases
livecheck.regex     "Release (\\d+(?:\\.\\d+)*)"
