# -*- 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
PortGroup           legacysupport 1.1

# O_CLOEXEC
# https://github.com/ninja-build/ninja/issues/2645
legacysupport.newest_darwin_requires_legacy 10

epoch               1
github.setup        ninja-build ninja 1.13.2 v
revision            1
checksums           rmd160  5164c27fecc557df135da31859d5d30f821b7b6e \
                    sha256  974d6b2f4eeefa25625d34da3cb36bdcebe7fbce40f4c16ac0835fd1c0cbae17 \
                    size    292385

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

# ./src/jobserver-posix.cc:130:10: error: no viable conversion from returned value of type 'unique_ptr<(anonymous namespace)::PosixJobserverClient, default_delete<(anonymous namespace)::PosixJobserverClient>>' to function return type 'unique_ptr<Jobserver::Client, default_delete<Jobserver::Client>>'
compiler.blacklist {clang < 900}

set py_ver          3.14
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
