ispc-9999.ebuild 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Copyright 1999-2025 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. llvm-core/clang:${LLVM_SLOT}
  29. llvm-core/llvm:${LLVM_SLOT}
  30. ')
  31. sys-libs/ncurses:=
  32. gpu? ( dev-libs/level-zero:= )
  33. !openmp? ( dev-cpp/tbb:= )
  34. doc? (
  35. app-doc/doxygen[dot(+)]
  36. media-fonts/freefont
  37. )
  38. "
  39. RDEPEND="
  40. ${DEPEND}
  41. "
  42. BDEPEND="
  43. app-alternatives/yacc
  44. app-alternatives/lex
  45. ${PYTHON_DEPS}
  46. "
  47. PATCHES+=(
  48. "${FILESDIR}"/0001-Fix-QA-Issues.patch
  49. #"${FILESDIR}"/0002-cmake-don-t-build-for-32-bit-targets.patch
  50. "${FILESDIR}"/0001-CMakeLists.txt-link-with-libclang-cpp-library-instea.patch
  51. )
  52. DOCS=( README.md "${S}"/docs/{ReleaseNotes.txt,faq.rst,ispc.rst,perf.rst,perfguide.rst} )
  53. pkg_pretend() {
  54. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  55. }
  56. pkg_setup() {
  57. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  58. llvm-r1_pkg_setup
  59. python-any-r1_pkg_setup
  60. }
  61. src_prepare() {
  62. # drop -Werror
  63. sed -e 's/-Werror//' -i CMakeLists.txt || die
  64. # fix path for dot binary
  65. if use doc; then
  66. sed -e 's|/usr/local/bin/dot|/usr/bin/dot|' -i "${S}"/doxygen.cfg || die
  67. fi
  68. # do not require bundled gtest
  69. mkdir -p ispcrt/tests/vendor/google/googletest || die
  70. cat > ispcrt/tests/vendor/google/googletest/CMakeLists.txt <<-EOF || die
  71. find_package(GTest)
  72. EOF
  73. # remove hacks that break unbinding
  74. sed -i -e '/gmock/d' -e '/install/,$d' ispcrt/tests/CMakeLists.txt || die
  75. cmake_src_prepare
  76. }
  77. src_configure() {
  78. CMAKE_BUILD_TYPE="Release"
  79. local mycmakeargs=(
  80. -DCMAKE_CXX_STANDARD=17
  81. -DARM_ENABLED=$(usex arm)
  82. -DCMAKE_SKIP_RPATH=ON
  83. #-DNVPTX_ENABLED=OFF
  84. -DISPC_INCLUDE_EXAMPLES=$(usex examples)
  85. -DISPC_INCLUDE_DPCPP_EXAMPLES=$(usex examples)
  86. -DISPC_INCLUDE_TESTS=$(usex test)
  87. -DISPC_INCLUDE_UTILS=$(usex utils)
  88. -DISPC_PREPARE_PACKAGE=OFF
  89. -DISPC_STATIC_STDCXX_LINK=OFF
  90. -DISPC_STATIC_LINK=OFF
  91. -DISPCRT_BUILD_GPU=$(usex gpu)
  92. -DISPCRT_BUILD_TASK_MODEL=$(usex openmp OpenMP TBB)
  93. -DISPC_USE_ASAN=$(usex sanitize)
  94. -DPython3_EXECUTABLE="${PYTHON}"
  95. # prevent it from trying to find the git repo
  96. -DGIT_BINARY=GIT_BINARY-NOTFOUND
  97. )
  98. cmake_src_configure
  99. }
  100. src_test() {
  101. # Inject path to prevent using system ispc
  102. local -x PATH="${BUILD_DIR}/bin:${PATH}"
  103. "${EPYTHON}" ./scripts/run_tests.py "-j$(makeopts_jobs)" -v ||
  104. die "Testing failed under ${EPYTHON}"
  105. }
  106. src_compile(){
  107. cmake_src_compile
  108. if use doc; then
  109. pushd "${S}" >/dev/null || die
  110. doxygen -u doxygen.cfg || die "failed to update doxygen.cfg"
  111. doxygen doxygen.cfg || die "failed to build documentation"
  112. popd >/dev/null || die
  113. fi
  114. }
  115. src_install() {
  116. cmake_src_install
  117. if use doc; then
  118. local HTML_DOCS=( docs/doxygen/html/. )
  119. fi
  120. einstalldocs
  121. if use examples; then
  122. #insinto "/usr/share/doc/${PF}/examples"
  123. docompress -x "/usr/share/doc/${PF}/examples"
  124. #doins -r "${BUILD_DIR}"/examples/*
  125. dodoc -r examples
  126. fi
  127. }