# -*- 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.24.4 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  1797fa317fb2dcde753c30ea71f8c6079d6da5b1 \
                    sha256  d704832a6bfaac8b3cbca3b5d773cad613183ba8c04166638af2c6e5dfb9e2d2 \
                    size    3019387

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.]+)}