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

epoch               1
github.setup        ninja-build ninja 1.13.1 v
revision            0
checksums           rmd160  6765fd1becaccc480b857bdf7953405dfdd43ff3 \
                    sha256  f0055ad0369bf2e372955ba55128d000cfcc21777057806015b45e4accbebf23 \
                    size    292098

categories          devel
maintainers         {ryandesign @ryandesign} openmaintainer
license             Apache-2
installs_libs       no
conflicts           samurai

description         Small build system with a focus on speed.

long_description    Ninja is yet another build system. It takes as input    \
                    the interdependencies of files (typically source code   \
                    and output executables) and orchestrates building them, \
                    quickly.                                                \
                                                                            \
                    Ninja joins a sea of other build systems. Its           \
                    distinguishing goal is to be fast. It is born from my   \
                    work on the Chromium browser project, which has over    \
                    30,000 source files and whose other build systems       \
                    (including one built from custom non-recursive          \
                    Makefiles) can take ten seconds to start building       \
                    after changing one file. Ninja is under a second.

homepage            https://ninja-build.org
github.tarball_from archive
checksums-prepend   ${distfiles}
set gtest_version   1.16.0
set gtest_distname  googletest-${gtest_version}
set gtest_distfile  ${gtest_distname}${extract.suffix}
master_sites        ${master_sites}:main \
                    https://github.com/google/googletest/archive/v${gtest_version}:gtest
distfiles           ${distfiles}:main \
                    ${gtest_distfile}:gtest
checksums-append    ${gtest_distfile} \
                    rmd160  d3183abe7ab17d19d47b2ccf520a3b4e076804eb \
                    sha256  78c676fc63881529bf97bf9d45948d905a66833fbfa5318ea2cd7478cb98f399 \
                    size    876245

installs_libs       no

patchfiles          patch-configure.py-bootstrap-only.diff \
                    patch-ninja-configure.py-remove-mmd.diff

depends_build-append \
                    port:re2c

# Required by googletest
compiler.cxx_standard \
                    2014

set py_ver          3.13
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_lib-append  port:python${py_ver_nodot}
configure.python    ${prefix}/bin/python${py_ver}

default configure.cmd \
                    {${configure.python}}
configure.pre_args  configure.py
default configure.args \
                    {--with-python=${configure.python}}
configure.post_args --bootstrap \
                    --gtest-source-dir=${workpath}/${gtest_distname} \
                    --verbose
configure.universal_args

build.cmd           ./ninja
build.target
build.args          -v

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin
    xinstall -m 0644 ${worksrcpath}/build/libninja.a ${destroot}${prefix}/lib

    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 0644 ${worksrcpath}/misc/bash-completion ${destroot}${prefix}/share/bash-completion/completions/ninja

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -m 0644 ${worksrcpath}/misc/zsh-completion ${destroot}${prefix}/share/zsh/site-functions/_ninja

    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        CONTRIBUTING.md \
        COPYING \
        README.md \
        ${destroot}${docdir}
}

test.run            yes
test.cmd            ./ninja ninja_test && ./ninja_test
test.args
