# -*- 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.10

java.version        1.8
java.fallback       openjdk8

revision            0
categories          devel electronics java lang
platforms           darwin
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  c9ff434aec48356ee406a1ff1092f818308a60b1 \
                    sha256  1ccd7c5e22af9169a9befc7c312c528a6209689f1d49b308410a160d3e20cb5c \
                    size    42780952

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+)*)"