# -*- 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.12.1 v
revision            1
checksums           rmd160  edb99cb67641947a6cdde89300a326de69df77f4 \
                    sha256  821bdff48a3f683bc4bb3b6f0b5fe7b2d647cf65d52aeb63328c91a6c6df285a \
                    size    240483

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.14.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  54f7bd68b80152528dfc13d9291b247c0353c2a4 \
                    sha256  8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7 \
                    size    867764

installs_libs       no

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

depends_build-append \
                    port:re2c

# cc1plus: error: unrecognized command line option "-std=c++11"
compiler.cxx_standard   2011

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}
}

platform darwin {
    if {${os.major} == 8} {
        patchfiles-append patch-tiger-no-posix-spawn.diff
        patchfiles-append patch-tiger-sysconf.diff
    }
}

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