TERMUX_PKG_HOMEPAGE=https://github.com/google/shaderc
TERMUX_PKG_DESCRIPTION="Collection of tools, libraries, and tests for Vulkan shader compilation"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="2026.3"
TERMUX_PKG_SRCURL=https://github.com/google/shaderc/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=ee493ccf1b3038b4ef2fe024664c5eb2dc4bcc1f6b05b33e3909de0e19c81024
TERMUX_PKG_DEPENDS="glslang, spirv-tools, libc++"
TERMUX_PKG_BUILD_DEPENDS="spirv-headers"
TERMUX_PKG_NO_STATICSPLIT=true
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_UPDATE_TAG_TYPE="newest-tag"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DCMAKE_INSTALL_LIBDIR=$TERMUX__PREFIX__LIB_SUBDIR
-DCMAKE_INSTALL_INCLUDEDIR=$TERMUX__PREFIX__INCLUDE_SUBDIR
-DSHADERC_SKIP_TESTS=ON
-Dglslang_SOURCE_DIR=$TERMUX_PREFIX/include/glslang
"

termux_step_pre_configure() {
	# based on Arch Linux:
	# https://gitlab.archlinux.org/archlinux/packaging/packages/shaderc/-/blob/3ed2bcb6358e964d75044f075a04cb0cd8bd4fa8/README.md
	# de-vendor libs and disable git versioning
	local _SPIRV_TOOLS_BUILD_SH="$TERMUX_SCRIPTDIR/packages/spirv-tools/build.sh"
	local _GLSLANG_BUILD_SH="$TERMUX_SCRIPTDIR/packages/glslang/build.sh"
	local _SPIRV_TOOLS_VERSION=$(bash -c ". $_SPIRV_TOOLS_BUILD_SH; echo \${TERMUX_PKG_VERSION#*:}")
	local _GLSLANG_VERSION=$(bash -c ". $_GLSLANG_BUILD_SH; echo \${TERMUX_PKG_VERSION#*:}")

	sed '/examples/d;/third_party/d' -i "$TERMUX_PKG_SRCDIR/CMakeLists.txt"
	sed '/build-version/d' -i "$TERMUX_PKG_SRCDIR/glslc/CMakeLists.txt"
	cat <<- EOF > "$TERMUX_PKG_SRCDIR/glslc/src/build-version.inc"
		"${TERMUX_PKG_VERSION}\\n"
		"${_SPIRV_TOOLS_VERSION}\\n"
		"${_GLSLANG_VERSION}\\n"
	EOF
}
