# Copyright 2022-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 # note: version 2.6 should be kept for longer given it's the # last version to support /dev/null; then eerror "With USE=crossdev-mingw, it is necessary to setup the mingw toolchain." eerror "For instructions, please see: https://wiki.gentoo.org/wiki/Mingw" use abi_x86_32 && use abi_x86_64 && eerror "Also, with USE=abi_x86_32, will need both i686 and x86_64 toolchains." die "USE=crossdev-mingw is enabled, but ${tool} was not found" elif [[ ! $(LC_ALL=C ${tool} -v 2>&1) =~ "Thread model: posix" ]]; then eerror "${PN} requires GCC to be built with --enable-threads=posix" eerror "Please see: https://wiki.gentoo.org/wiki/Mingw#POSIX_threads_for_Windows" die "USE=crossdev-mingw is enabled, but ${tool} does not use POSIX threads" fi done tool=-w64-mingw32-widl for tool in $(usev abi_x86_64 x86_64${tool}) $(usev abi_x86_32 i686${tool}); do if ! type -P widl >/dev/null && ! type -P ${tool} >/dev/null; then eerror "With USE=crossdev-mingw, you need to provide the widl compiler by either" eerror "building crossdev mingw64-runtime with USE=tools or installing wine." die "USE=crossdev-mingw is set but neither widl nor ${tool} were found" fi done fi } src_prepare() { if [[ ${PV} != 9999 ]]; then rmdir subprojects/{{SPIRV,Vulkan}-Headers,dxil-spirv} || die mv ../dxil-spirv-${HASH_DXIL} subprojects/dxil-spirv || die mv ../SPIRV-Headers-${HASH_SPIRV} subprojects/SPIRV-Headers || die mv ../Vulkan-Headers-${HASH_VULKAN} subprojects/Vulkan-Headers || die ln -s ../../../SPIRV-Headers/include \ subprojects/dxil-spirv/third_party/spirv-headers || die fi default sed -i "/^basedir=/s|=.*|=${EPREFIX}/usr/lib/${PN}|" setup_vkd3d_proton.sh || die if [[ ${PV} != 9999 ]]; then # without .git, meson sets vkd3d_build as 0x${PV} leading to failure sed -i "s/@VCS_TAG@/${HASH_VKD3D::15}/" vkd3d_build.h.in || die sed -i "s/@VCS_TAG@/${HASH_VKD3D::7}/" vkd3d_version.h.in || die fi } src_configure() { use crossdev-mingw || PATH=${BROOT}/usr/lib/mingw64-toolchain/bin:${PATH} # -mavx with mingw-gcc has a history of obscure issues and # disabling is seen as safer, e.g. `WINEARCH=win32 winecfg` # crashes with -march=skylake >=wine-8.10, similar issues with # znver4: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273 append-flags -mno-avx if [[ ${CHOST} != *-mingw* ]]; then if [[ ! -v MINGW_BYPASS ]]; then unset AR CC CXX RC STRIP WIDL filter-flags '-fuse-ld=*' filter-flags '-mfunction-return=thunk*' #878849 if has_version ' "${T}"/widl.${ABI}.ini || die local emesonargs=( --prefix="${EPREFIX}"/usr/lib/${PN} --{bin,lib}dir=x${ABI: -2} --{cross,native}-file="${T}"/widl.${ABI}.ini $(meson_use {,enable_}extras) $(meson_use debug enable_trace) $(usev !debug --strip) # portage won't strip .dll, so allow it here -Denable_tests=false # needs wine/vulkan and is intended for manual use ) meson_src_configure } multilib_src_install_all() { dobin setup_vkd3d_proton.sh einstalldocs # unnecesasry files, see package-release.sh rm "${ED}"/usr/lib/${PN}/x*/libvkd3d-proton-utils-3.dll || die find "${ED}" -type f -name '*.a' -delete || die } pkg_postinst() { if [[ ! ${REPLACING_VERSIONS} ]]; then elog "To enable ${PN} on a wine prefix, you can run the following command:" elog elog " WINEPREFIX=/path/to/prefix setup_vkd3d_proton.sh install --symlink" elog elog "See ${EROOT}/usr/share/doc/${PF}/README.md* for details." fi }