opencascade-9999.ebuild 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. inherit cmake flag-o-matic virtualx
  5. DESCRIPTION="Development platform for CAD/CAE, 3D surface/solid modeling and data exchange"
  6. HOMEPAGE="https://www.opencascade.com"
  7. MY_PN="OCCT"
  8. MY_TEST_PV="7.8.0"
  9. MY_TEST_PV2="${MY_TEST_PV//./_}"
  10. SRC_URI="
  11. test? ( https://github.com/Open-Cascade-SAS/${MY_PN}/releases/download/V${MY_TEST_PV2}/${PN}-dataset-${MY_TEST_PV}.tar.xz )
  12. "
  13. if [[ ${PV} = *9999* ]] ; then
  14. inherit git-r3
  15. EGIT_REPO_URI="https://github.com/Open-Cascade-SAS/${MY_PN}.git"
  16. else
  17. MY_PV="${PV//./_}"
  18. SRC_URI+="
  19. https://github.com/Open-Cascade-SAS/${MY_PN}/archive/refs/tags/V${MY_PV}.tar.gz -> ${P}.tar.gz
  20. "
  21. S="${WORKDIR}/${MY_PN}-${MY_PV}"
  22. KEYWORDS="~amd64 ~arm ~arm64 ~riscv ~x86"
  23. fi
  24. LICENSE="|| ( Open-CASCADE-LGPL-2.1-Exception-1.0 LGPL-2.1 )"
  25. SLOT="0/$(ver_cut 1-2)"
  26. IUSE="X debug doc draco examples ffmpeg freeimage freetype gles2-only inspector jemalloc json +opengl optimize tbb test testprograms tk vtk"
  27. REQUIRED_USE="
  28. ?? ( optimize tbb )
  29. ?? ( opengl gles2-only )
  30. test? ( freeimage json opengl )
  31. "
  32. # There's no easy way to test. Testing needs a rather big environment properly set up.
  33. RESTRICT="!test? ( test )"
  34. # ffmpeg: https://tracker.dev.opencascade.org/view.php?id=32871
  35. RDEPEND="
  36. dev-lang/tcl:=
  37. tk? ( dev-lang/tk:= )
  38. dev-libs/double-conversion
  39. draco? (
  40. media-libs/draco
  41. )
  42. freetype? (
  43. media-libs/fontconfig
  44. media-libs/freetype:2
  45. )
  46. gles2-only? (
  47. media-libs/libglvnd
  48. )
  49. opengl? (
  50. media-libs/libglvnd[X]
  51. )
  52. X? (
  53. x11-libs/libX11
  54. )
  55. examples? (
  56. dev-qt/qtcore:5
  57. dev-qt/qtgui:5
  58. dev-qt/qtquickcontrols2:5
  59. dev-qt/qtwidgets:5
  60. dev-qt/qtxml:5
  61. )
  62. ffmpeg? ( <media-video/ffmpeg-5:= )
  63. freeimage? ( media-libs/freeimage )
  64. inspector? (
  65. dev-qt/qtcore:6
  66. dev-qt/qtgui:6
  67. dev-qt/qtquickcontrols2:6
  68. dev-qt/qtwidgets:6
  69. dev-qt/qtxml:6
  70. )
  71. jemalloc? ( dev-libs/jemalloc )
  72. tbb? ( dev-cpp/tbb:= )
  73. vtk? (
  74. dev-lang/tk:=
  75. sci-libs/vtk:=[rendering]
  76. tbb? (
  77. sci-libs/vtk:=[tbb,-cuda]
  78. )
  79. )
  80. "
  81. DEPEND="
  82. ${RDEPEND}
  83. X? ( x11-base/xorg-proto )
  84. json? ( dev-libs/rapidjson )
  85. "
  86. BDEPEND="
  87. doc? ( app-text/doxygen[dot] )
  88. inspector? (
  89. dev-qt/linguist-tools:6
  90. )
  91. test? ( dev-tcltk/thread )
  92. "
  93. PATCHES=(
  94. "${FILESDIR}/${PN}-7.5.1-0005-fix-write-permissions-on-scripts.patch"
  95. "${FILESDIR}/${PN}-7.5.1-0006-fix-creation-of-custom.sh-script.patch"
  96. "${FILESDIR}/${PN}-7.7.0-fix-installation-of-cmake-config-files.patch"
  97. "${FILESDIR}/${PN}-7.7.0-avoid-pre-stripping-binaries.patch"
  98. "${FILESDIR}/${PN}-7.7.0-musl.patch"
  99. "${FILESDIR}/${PN}-7.7.0-tbb-detection.patch"
  100. "${FILESDIR}/${PN}-7.7.0-jemalloc-lib-type.patch"
  101. "${FILESDIR}/${PN}-7.8.0-cmake-min-version.patch"
  102. "${FILESDIR}/${PN}-7.8.0-tests.patch"
  103. "${FILESDIR}/${PN}-7.8.0-jemalloc-noexcept.patch"
  104. "${FILESDIR}/${PN}-7.8.1-vtk_components.patch"
  105. "${FILESDIR}/${PN}-7.8.1-wayland-support.patch"
  106. "${FILESDIR}/${PN}-7.8.1-freetype-const.patch"
  107. #"${FILESDIR}/${PN}-7.8.2-avoid-pre-stripping-binaries.patch"
  108. #"${FILESDIR}/${PN}-7.8.2-jemalloc-lib-type.patch"
  109. )
  110. src_unpack() {
  111. if [[ ${PV} = *9999* ]] ; then
  112. git-r3_src_unpack
  113. else
  114. unpack "${P}.tar.gz"
  115. fi
  116. if use test; then
  117. mkdir "${WORKDIR}/data"
  118. pushd "${WORKDIR}/data" > /dev/null || die
  119. # should be in paths indicated by CSF_TestDataPath environment variable,
  120. # or in subfolder data in the script directory
  121. unpack "${PN}-dataset-${MY_TEST_PV}.tar.xz"
  122. popd > /dev/null || die
  123. fi
  124. }
  125. src_prepare() {
  126. cmake_src_prepare
  127. sed -e 's|/lib\$|/'"$(get_libdir)"'\$|' \
  128. -i adm/templates/OpenCASCADEConfig.cmake.in || die
  129. # There is an OCCT_UPDATE_TARGET_FILE cmake macro that fails due to some
  130. # assumptions it makes about installation paths. Rather than fixing it, just
  131. # get rid of the mechanism altogether - its purpose is to allow a
  132. # side-by-side installation of release and debug libraries.
  133. sed -e 's|\\${OCCT_INSTALL_BIN_LETTER}||' \
  134. -i adm/cmake/occt_toolkit.cmake || die
  135. }
  136. src_configure() {
  137. # -Werror=odr
  138. # https://bugs.gentoo.org/862912
  139. # https://tracker.dev.opencascade.org/view.php?id=33091
  140. filter-lto
  141. CMAKE_BUILD_TYPE=Release
  142. local mycmakeargs=(
  143. -D3RDPARTY_DIR="${ESYSROOT}/usr"
  144. -DBUILD_CPP_STANDARD="C++17"
  145. -DBUILD_SOVERSION_NUMBERS=2
  146. -DBUILD_DOC_Overview="$(usex doc)"
  147. -DBUILD_Inspector="$(usex inspector)"
  148. -DBUILD_ENABLE_FPE_SIGNAL_HANDLER="$(usex debug)"
  149. -DBUILD_USE_PCH="no"
  150. # -DBUILD_OPT_PROFILE="Default" # Production
  151. # -DBUILD_RESOURCES="yes"
  152. # -DBUILD_YACCLEX="yes"
  153. -DBUILD_RELEASE_DISABLE_EXCEPTIONS="no" # bug #847916
  154. -DINSTALL_DIR="${EPREFIX}/usr"
  155. -DINSTALL_DIR_BIN="$(get_libdir)/${PN}/bin"
  156. -DINSTALL_DIR_CMAKE="$(get_libdir)/cmake/${PN}"
  157. -DINSTALL_DIR_DATA="share/${PN}/data"
  158. -DINSTALL_DIR_DOC="share/doc/${PF}"
  159. -DINSTALL_DIR_INCLUDE="include/${PN}"
  160. -DINSTALL_DIR_LIB="$(get_libdir)/${PN}"
  161. -DINSTALL_DIR_RESOURCE="share/${PN}/resources"
  162. -DINSTALL_DIR_SAMPLES="share/${PN}/samples"
  163. -DINSTALL_DIR_SCRIPT="$(get_libdir)/${PN}/bin"
  164. -DINSTALL_DIR_TESTS="share/${PN}/tests"
  165. -DINSTALL_DIR_WITH_VERSION="no"
  166. -DINSTALL_SAMPLES="$(usex examples)"
  167. -DINSTALL_TEST_CASES="$(usex testprograms)"
  168. # no package yet in tree
  169. -DUSE_DRACO="$(usex draco)"
  170. -DUSE_FFMPEG="$(usex ffmpeg)"
  171. -DUSE_FREEIMAGE="$(usex freeimage)"
  172. -DUSE_FREETYPE="$(usex freetype)"
  173. # Indicates whether OpenGL ES 2.0 should be used in OCCT visualization module
  174. -DUSE_GLES2="$(usex gles2-only)"
  175. # Indicates whether OpenGL desktop should be used in OCCT visualization module
  176. -DUSE_OPENGL="$(usex opengl)"
  177. # no package in tree
  178. -DUSE_OPENVR="no"
  179. -DUSE_RAPIDJSON="$(usex json)"
  180. -DUSE_TBB="$(usex tbb)"
  181. -DUSE_TK="$(usex tk)"
  182. -DUSE_VTK="$(usex vtk)"
  183. -DUSE_XLIB="$(usex X)"
  184. )
  185. if use draco; then
  186. mycmakeargs+=(
  187. -D3RDPARTY_DRACO_INCLUDE_DIR="${ESYSROOT}/usr/include/draco"
  188. )
  189. fi
  190. # Select using memory manager tool.
  191. if ! use jemalloc && ! use tbb; then
  192. mycmakeargs+=( -DUSE_MMGR_TYPE=NATIVE )
  193. elif use jemalloc && ! use tbb; then
  194. mycmakeargs+=(
  195. -DUSE_MMGR_TYPE=JEMALLOC
  196. -D3RDPARTY_JEMALLOC_INCLUDE_DIR="${ESYSROOT}/usr/include/jemalloc"
  197. )
  198. elif ! use jemalloc && use tbb; then
  199. mycmakeargs+=( -DUSE_MMGR_TYPE=TBB )
  200. elif use jemalloc && use tbb; then
  201. mycmakeargs+=( -DUSE_MMGR_TYPE=FLEXIBLE )
  202. fi
  203. if use doc; then
  204. mycmakeargs+=(
  205. -DINSTALL_DOC_Overview="yes"
  206. -D3RDPARTY_SKIP_DOT_EXECUTABLE="no"
  207. )
  208. fi
  209. if use examples || use inspector; then
  210. mycmakeargs+=(
  211. -D3RDPARTY_QT_DIR="${ESYSROOT}/usr"
  212. -DBUILD_SAMPLES_QT="$(usex examples)"
  213. )
  214. fi
  215. if use tbb; then
  216. mycmakeargs+=(
  217. -D3RDPARTY_TBB_DIR="${ESYSROOT}/usr"
  218. )
  219. fi
  220. if use vtk; then
  221. local vtk_ver
  222. vtk_ver="$(best_version "sci-libs/vtk")"
  223. vtk_ver=$(ver_cut 1-2 "${vtk_ver#sci-libs/vtk-}")
  224. mycmakeargs+=(
  225. -D3RDPARTY_VTK_INCLUDE_DIR="${ESYSROOT}/usr/include/vtk-${vtk_ver}"
  226. -D3RDPARTY_VTK_LIBRARY_DIR="${ESYSROOT}/usr/$(get_libdir)"
  227. )
  228. fi
  229. cmake_src_configure
  230. sed -e "s|lib/|$(get_libdir)/|" \
  231. -e "s|VAR_CASROOT|${EPREFIX}/usr|" \
  232. < "${FILESDIR}/${PN}.env.in" > "${T}/99${PN}" || die
  233. # use TBB for memory allocation optimizations
  234. if use tbb; then
  235. sed -e 's|^#MMGT_OPT=0$|MMGT_OPT=2|' -i "${T}/99${PN}" || die
  236. fi
  237. # use internal optimized memory manager and don't clear memory with this
  238. # memory manager.
  239. if use optimize ; then
  240. sed -e 's|^#MMGT_OPT=0$|MMGT_OPT=1|' \
  241. -e 's|^#MMGT_CLEAR=1$|MMGT_CLEAR=0|' \
  242. -i "${T}/99${PN}" || die
  243. fi
  244. }
  245. src_test() {
  246. echo "export CSF_OCCTDataPath=${WORKDIR}/data" >> "${BUILD_DIR}/custom.sh" || die
  247. if has_version media-fonts/dejavu; then
  248. cp "${ESYSROOT}/usr/share/fonts/dejavu/DejaVuSans.ttf" "${WORKDIR}/data/" # no die here as this isn't fatal
  249. fi
  250. local test_file=${T}/testscript.tcl
  251. local draw_opts=(
  252. i # see ${BUILD_DIR}/custom*.sh
  253. # -b # batch mode (no GUI, no viewers)
  254. -v # no GUI, use virtual (off-screen) windows for viewers
  255. )
  256. local test_names=(
  257. "demo draw bug30430" # prone to dying due to cpu limit
  258. )
  259. local test_opts=( # run single tests
  260. -overwrite
  261. )
  262. for test_name in "${test_names[@]}"; do
  263. cat >> "${test_file}" <<- _EOF_ || die
  264. test ${test_name} -outfile "${BUILD_DIR}/test_results/${test_name// /\/}.html" ${test_opts[@]}
  265. _EOF_
  266. done
  267. local testgrid_opts=()
  268. local SKIP_TESTS=()
  269. if [[ "${OCCT_OPTIONAL_TESTS}" != "true" ]]; then
  270. SKIP_TESTS+=(
  271. 'blend complex F4'
  272. 'bugs'
  273. 'geometry circ2d3Tan '{CircleCircleLin_11,CircleLinPoint_11}
  274. 'heal checkshape bug32448_1'
  275. 'hlr exact_hlr bug25813_2'
  276. 'hlr poly_hlr '{bug25813_2,bug25813_3,bug25813_4,Plate}
  277. 'lowalgos intss bug'{565,567_1,25950,27431,29807_i1003,29807_i2006,29807_i3003,29807_i5002,30703}
  278. 'lowalgos proximity '{A4,A5}
  279. 'opengl background bug27836'
  280. 'opengl drivers opengles'
  281. 'opengles3'
  282. 'demo draw bug30430'
  283. )
  284. local DEL_TESTS=(
  285. 'opengl/data/background/bug27836'
  286. 'perf/mesh/bug26965'
  287. 'v3d/trsf/bug26029'
  288. )
  289. for test in "${DEL_TESTS[@]}"; do
  290. rm "${CMAKE_USE_DIR}/tests/${test}" || die
  291. done
  292. fi
  293. if ! use vtk; then
  294. SKIP_TESTS+=(
  295. 'vtk'
  296. )
  297. echo "IGNORE /Could not open: libTKIVtkDraw/skip VTK" >> "${CMAKE_USE_DIR}/tests/opengl/parse.rules"
  298. fi
  299. if [[ -n "${SKIP_TESTS[*]}" ]]; then
  300. testgrid_opts+=( -exclude "$(IFS=',' ; echo "${SKIP_TESTS[*]}")" )
  301. fi
  302. testgrid_opts+=(
  303. # -refresh 5
  304. -overwrite
  305. )
  306. cat >> "${test_file}" <<- _EOF_ || die
  307. testgrid -outdir "${BUILD_DIR}/test_results" ${testgrid_opts[@]}
  308. _EOF_
  309. # # regenerate summary in case we have to
  310. # cat >> "${test_file}" <<- _EOF_ || die
  311. # testsummarize "${BUILD_DIR}/test_results"
  312. # _EOF_
  313. # Work around zink warnings
  314. export LIBGL_ALWAYS_SOFTWARE="true"
  315. export CASROOT="${BUILD_DIR}"
  316. virtx \
  317. "${BUILD_DIR}/draw.sh" \
  318. "${draw_opts[@]}" \
  319. -f "${test_file}"
  320. if [[ ! -f "${BUILD_DIR}/test_results/tests.log" ]]; then
  321. eerror "tests never ran!"
  322. die
  323. fi
  324. failed_tests="$(grep ": FAILED" "${BUILD_DIR}/test_results/tests.log")"
  325. if [[ -n ${failed_tests} ]]; then
  326. eerror "Failed tests:"
  327. eerror "${failed_tests}"
  328. die
  329. fi
  330. }
  331. src_install() {
  332. cmake_src_install
  333. doenvd "${T}/99${PN}"
  334. docompress -x "/usr/share/doc/${PF}/overview/html"
  335. }