# Ensure the path returned by get_llvm_prefix() contains clang as well.
llvm_check_deps(){
has_version "sys-devel/clang:${LLVM_SLOT}"
}
src_prepare(){
# TODO: File upstream issue requesting a sane way to disable NumPy support.
if ! use numpy;then
sed -i -e '/\bprint(os\.path\.realpath(numpy))/d'\
libshiboken/CMakeLists.txt || die
fi
# Shiboken2 assumes Vulkan headers live under either "$VULKAN_SDK/include"
# or "$VK_SDK_PATH/include" rather than "${EPREFIX}/usr/include/vulkan".
if use vulkan;then
sed -i -e 's~\bdetectVulkan(&headerPaths);~headerPaths.append(HeaderPath{QByteArrayLiteral("'${EPREFIX}'/usr/include/vulkan"), HeaderType::System});~'\
ApiExtractor/clangparser/compilersupport.cpp || die
fi
# Shiboken2 assumes the "/usr/lib/clang/${CLANG_NEWEST_VERSION}/include/"
# subdirectory provides Clang builtin includes (e.g., "stddef.h") for the
# currently installed version of Clang, where ${CLANG_NEWEST_VERSION} is
# the largest version specifier that exists under the "/usr/lib/clang/"
# subdirectory. This assumption is false in edge cases, including when
# users downgrade from newer Clang versions but fail to remove those
# versions with "emerge --depclean". See also:
# https://github.com/leycec/raiagent/issues/85
#
# Sadly, the clang-* family of functions exported by the "toolchain-funcs"
# eclass are defective, returning nonsensical placeholder strings if the
# end user has *NOT* explicitly configured their C++ compiler to be Clang.
# PySide2 does *NOT* care whether the end user has done so or not, as
# PySide2 unconditionally requires Clang in either case. See also:
# https://bugs.gentoo.org/619490
sed -i -e 's~(findClangBuiltInIncludesDir())~(QStringLiteral("'${EPREFIX}'/usr/lib/clang/'$(CPP=clang clang-fullversion)'/include"))~'\
ApiExtractor/clangparser/compilersupport.cpp || die
cmake_src_prepare
}
src_configure(){
# Minimal tests for now, 2 failing with the extended version
# FIXME Subscripted generics cannot be used with class and instance checks
localmycmakeargs=(
-DBUILD_TESTS=$(usex test)
-DDISABLE_DOCSTRINGS=$(usex !docstrings)
)
shiboken2_configure(){
localmycmakeargs=(
"${mycmakeargs[@]}"
-DPYTHON_CONFIG_SUFFIX="-${EPYTHON}"
-DPYTHON_EXECUTABLE="${PYTHON}"
-DUSE_PYTHON_VERSION="${EPYTHON#python}"
)
# CMakeLists.txt expects LLVM_INSTALL_DIR as an environment variable.
local -x LLVM_INSTALL_DIR="$(get_llvm_prefix)"
cmake_src_configure
}
python_foreach_impl shiboken2_configure
}
src_compile(){
python_foreach_impl cmake_src_compile
}
src_test(){
python_foreach_impl cmake_src_test
}
src_install(){
shiboken2_install(){
cmake_src_install
python_optimize
# Uniquify the "shiboken2" executable for the current Python target,
# preserving an unversioned "shiboken2" file arbitrarily associated
# with the last Python target.
cp "${ED}"/usr/bin/${PN}{,-${EPYTHON}}|| die
# Uniquify the Shiboken2 pkgconfig file for the current Python target,
# preserving an unversioned "shiboken2.pc" file arbitrarily associated
# with the last Python target. See also:
# https://github.com/leycec/raiagent/issues/73
cp "${ED}/usr/$(get_libdir)"/pkgconfig/${PN}{,-${EPYTHON}}.pc || die
}
python_foreach_impl shiboken2_install
# CMakeLists.txt installs a "Shiboken2Targets-gentoo.cmake" file forcing
# downstream consumers (e.g., PySide2) to target one "libshiboken2-*.so"
# library and one "shiboken2" executable linked to one Python interpreter.