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

github.setup        KhronosGroup glslang 1.4.321.0 vulkan-sdk-
github.tarball_from archive
revision            0

categories          graphics devel
license             {BSD Permissive}
maintainers         {judaew @judaew} 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  cb14f05b25b832655f440a36b13fbd0ab83e508d4de5c2e19c5f83eb61f6d55c \
                    rmd160  e5e011e1406a4d2e631d81ff1b1e6cba63e553b7 \
                    size    4205817

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

compiler.cxx_standard 2017

# Need to use MacPorts libc++ on macOS 10.14 Mojave and older, because
# Apple Clang only added support for the C++17 <filesystem> library
# starting in Xcode 11 (clang-1100) for macOS 10.15+.
#
# References:
# * https://stackoverflow.com/a/55353263
# * https://developer.apple.com/documentation/xcode-release-notes/xcode-11-release-notes
legacysupport.newest_darwin_requires_legacy 18
legacysupport.use_mp_libcxx yes

# 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

depends_lib-append      port:spirv-tools
depends_lib-append      port:python${py_ver_nodot}

depends_build-append    port:python${py_ver_nodot}

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

# there is no such option in CMakeLists.txt, cmake discovers and uses right python
#configure.args-append   -DPYTHON_EXECUTABLE:FILEPATH=${configure.python}

configure.args-append   -DBUILD_SHARED_LIBS=ON \
                        -DGLSLANG_ENABLE_INSTALL=ON \
                        -DALLOW_EXTERNAL_SPIRV_TOOLS=ON
