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

github.setup        tree-sitter tree-sitter 0.26.8 v
github.tarball_from archive
revision            0

homepage            https://tree-sitter.github.io

description         An incremental parsing system for programming tools

long_description    \
    Tree-sitter is a parser generator tool and an incremental parsing \
    library. It can build a concrete syntax tree for a source file and \
    efficiently update the syntax tree as the source file is edited. \
    Tree-sitter aims to be: General enough to parse any programming language, \
    Fast enough to parse on every keystroke in a text editor, Robust enough \
    to provide useful results even in the presence of syntax errors, \
    Dependency-free so that the runtime library (which is written in pure C) \
    can be embedded in any application

categories          devel
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

dist_subdir         ${name}/${version}_${revision}

checksums           ${distname}${extract.suffix} \
                    rmd160  e29630c70a28559a82a39d7519f7d87bc4ff7433 \
                    sha256  e6826b7533ec3a885aba598377a6d20b5a6321ff3db76968e960c2352d3a5077 \
                    size    908286

use_configure       no

if {${subport} eq ${name}} {
    PortGroup       makefile 1.0

    # cc1: error: unrecognized command line option "-std=c11"
    compiler.c_standard 2011
}

subport ${name}-cli {
    PortGroup       cargo 1.0

    revision        0

    build.dir       ${worksrcpath}/cli

    dist_subdir     ${subport}/${version}_${revision}

    depends_run-append \
                    bin:node:nodejs20

    build.pre_args-delete \
                    --frozen --offline

    destroot {
        xinstall -m 0755 \
            ${worksrcpath}/target/[cargo.rust_platform]/release/${name} \
            ${destroot}${prefix}/bin/
    }
}

# Exclude pre-release candidates
github.livecheck.regex \
                    {([0-9.]+)}
