ispc-9999.ebuild 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. LLVM_COMPAT=( {17..19} )
  5. PYTHON_COMPAT=( python3_{10..12} )
  6. inherit cmake llvm-r1 multiprocessing python-any-r1 toolchain-funcs
  7. DESCRIPTION="Intel SPMD Program Compiler"
  8. HOMEPAGE="
  9. https://ispc.github.io/
  10. https://github.com/ispc/ispc/
  11. "
  12. if [[ ${PV} == 9999 ]]; then
  13. inherit git-r3
  14. EGIT_REPO_URI="https://github.com/ispc/ispc.git"
  15. EGIT_SUBMODULES=()
  16. EGIT_BRANCH="main"
  17. else
  18. SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV//_*/}.tar.gz -> ${P}.tar.gz"
  19. KEYWORDS="amd64 ~arm ~arm64 ~ppc64 ~x86"
  20. S=${WORKDIR}/${PN}-${PV//_*/}
  21. fi
  22. LICENSE="BSD BSD-2 UoI-NCSA"
  23. SLOT="0"
  24. IUSE="doc examples gpu openmp sanitize test utils"
  25. RESTRICT="!test? ( test ) mirror"
  26. DEPEND="
  27. $(llvm_gen_dep '
  28. sys-devel/clang:${LLVM_SLOT}
  29. ')
  30. sys-libs/ncurses:=
  31. gpu? ( dev-libs/level-zero:= )
  32. !openmp? ( dev-cpp/tbb:= )
  33. doc? (
  34. app-doc/doxygen[dot(+)]
  35. media-fonts/freefont
  36. )
  37. "
  38. RDEPEND="
  39. ${DEPEND}
  40. "
  41. BDEPEND="
  42. app-alternatives/yacc
  43. app-alternatives/lex
  44. ${PYTHON_DEPS}
  45. "
  46. PATCHES+=(
  47. "${FILESDIR}"/0001-Fix-QA-Issues.patch
  48. #"${FILESDIR}"/0002-cmake-don-t-build-for-32-bit-targets.patch
  49. "${FILESDIR}"/0001-CMakeLists.txt-link-with-libclang-cpp-library-instea.patch
  50. )
  51. DOCS=( README.md "${S}"/docs/{ReleaseNotes.txt,faq.rst,ispc.rst,perf.rst,perfguide.rst} )
  52. pkg_pretend() {
  53. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  54. }
  55. pkg_setup() {
  56. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  57. llvm-r1_pkg_setup
  58. python-any-r1_pkg_setup
  59. }
  60. src_prepare() {
  61. # drop -Werror
  62. sed -e 's/-Werror//' -i CMakeLists.txt || die
  63. # fix path for dot binary
  64. if use doc; then
  65. sed -e 's|/usr/local/bin/dot|/usr/bin/dot|' -i "${S}"/doxygen.cfg || die
  66. fi
  67. # do not require bundled gtest
  68. mkdir -p ispcrt/tests/vendor/google/googletest || die
  69. cat > ispcrt/tests/vendor/google/googletest/CMakeLists.txt <<-EOF || die
  70. find_package(GTest)
  71. EOF
  72. # remove hacks that break unbundling
  73. sed -i -e '/gmock/d' -e '/install/,$d' ispcrt/tests/CMakeLists.txt || die
  74. cmake_src_prepare
  75. }
  76. src_configure() {
  77. CMAKE_BUILD_TYPE="Release"
  78. local mycmakeargs=(
  79. -DARM_ENABLED=$(usex arm)
  80. -DCMAKE_SKIP_RPATH=ON
  81. #-DNVPTX_ENABLED=OFF
  82. -DISPC_INCLUDE_EXAMPLES=$(usex examples)
  83. -DISPC_INCLUDE_DPCPP_EXAMPLES=$(usex examples)
  84. -DISPC_INCLUDE_TESTS=$(usex test)
  85. -DISPC_INCLUDE_UTILS=$(usex utils)
  86. -DISPC_PREPARE_PACKAGE=OFF
  87. -DISPC_STATIC_STDCXX_LINK=OFF
  88. -DISPC_STATIC_LINK=OFF
  89. -DISPCRT_BUILD_GPU=$(usex gpu)
  90. -DISPCRT_BUILD_TASK_MODEL=$(usex openmp OpenMP TBB)
  91. -DISPC_USE_ASAN=$(usex sanitize)
  92. -DPython3_EXECUTABLE="${PYTHON}"
  93. # prevent it from trying to find the git repo
  94. -DGIT_BINARY=GIT_BINARY-NOTFOUND
  95. )
  96. cmake_src_configure
  97. }
  98. src_test() {
  99. # Inject path to prevent using system ispc
  100. local -x PATH="${BUILD_DIR}/bin:${PATH}"
  101. "${EPYTHON}" ./scripts/run_tests.py "-j$(makeopts_jobs)" -v ||
  102. die "Testing failed under ${EPYTHON}"
  103. }
  104. src_compile(){
  105. cmake_src_compile
  106. if use doc; then
  107. pushd "${S}" >/dev/null || die
  108. doxygen -u doxygen.cfg || die "failed to update doxygen.cfg"
  109. doxygen doxygen.cfg || die "failed to build documentation"
  110. popd >/dev/null || die
  111. fi
  112. }
  113. src_install() {
  114. cmake_src_install
  115. if use doc; then
  116. local HTML_DOCS=( docs/doxygen/html/. )
  117. fi
  118. einstalldocs
  119. if use examples; then
  120. #insinto "/usr/share/doc/${PF}/examples"
  121. docompress -x "/usr/share/doc/${PF}/examples"
  122. #doins -r "${BUILD_DIR}"/examples/*
  123. dodoc -r examples
  124. fi
  125. }