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

legacysupport.newest_darwin_requires_legacy 18
legacysupport.use_mp_libcxx yes

# MacPorts upstream switched to vulkan-specific branch,
# we do not want that. OpenGL branch is actively supported by upstream.
github.setup        KhronosGroup glslang 16.2.0
revision            0

categories          graphics devel
license             {BSD Permissive}
maintainers         {judaew @judaew} {@barracuda156 macos-powerpc.org:barracuda} openmaintainer

description         OpenGL shader compiler libraries & tools
long_description    Glslang is the official reference compiler \
                    for the OpenGL and OpenGL ES shading languages.
homepage            https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/

checksums           sha256  01985335785c97906a91afe3cb5ee015997696181ec6c125bab5555602ba08e2 \
                    rmd160  8a4f11cf02ecfcf0ff2b0f222be4803c70b3fd55 \
                    size    4294235
github.tarball_from archive

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

compiler.cxx_standard   2017

# Generate a pkg-config file, so that software projects that use
# pkg-config to locate external dependencies (e.g., Godot 4.x) are able
# to find and link against glslang.

# This patch has also been submitted upstream, and when it gets added
# to the glslang codebase, our patchfile can be deleted:
# https://github.com/KhronosGroup/glslang/pull/3371
patchfiles-append       create-pkgconfig-file.diff

# Fix finding and linking SPIRV
patchfiles-append       patch-fix-SPIRV.diff

depends_build-append    path:bin/pkg-config:pkgconfig \
                        port:python${py_ver_nodot}

depends_lib-append      port:spirv-tools

configure.python        ${prefix}/bin/python${py_ver}

configure.args-append   -DBUILD_EXTERNAL=OFF \
                        -DBUILD_SHARED_LIBS=ON \
                        -DGLSLANG_ENABLE_INSTALL=ON \
                        -DENABLE_HLSL=ON \
                        -DENABLE_OPT=ON \
                        -DPYTHON_EXECUTABLE:FILEPATH=${configure.python}
