1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_6 )
8 inherit check-reqs cmake-utils xdg-utils flag-o-matic xdg-utils \
9 pax-utils python-single-r1 toolchain-funcs eapi7-ver
11 DESCRIPTION="3D Creation/Animation/Publishing System"
12 HOMEPAGE="https://www.blender.org"
14 SRC_URI="https://download.blender.org/source/${P}.tar.gz"
16 # Blender can have letters in the version string,
17 # so strip off the letter if it exists.
18 MY_PV="$(ver_cut 1-2)"
21 LICENSE="|| ( GPL-2 BL )"
23 IUSE="+bullet +dds +elbeem +game-engine +openexr collada color-management \
24 cuda cycles debug doc ffmpeg fftw headless jack jemalloc jpeg2k libav \
25 llvm man ndof nls openal opencl openimageio openmp opensubdiv openvdb \
26 osl player sdl sndfile test tiff valgrind"
27 RESTRICT="!test? ( test )"
29 REQUIRED_USE="${PYTHON_REQUIRED_USE}
31 cycles? ( openexr tiff openimageio )
34 player? ( game-engine !headless )"
36 RDEPEND="${PYTHON_DEPS}
37 >=dev-libs/boost-1.62:=[nls?,threads(+)]
39 >=dev-python/numpy-1.10.1[${PYTHON_USEDEP}]
40 dev-python/requests[${PYTHON_USEDEP}]
44 media-libs/libsamplerate
50 collada? ( >=media-libs/opencollada-1.6.18:= )
51 color-management? ( media-libs/opencolorio )
52 cuda? ( dev-util/nvidia-cuda-toolkit:= )
53 ffmpeg? ( media-video/ffmpeg:=[x264,mp3,encode,theora,jpeg2k?] )
54 libav? ( >=media-video/libav-11.3:=[x264,mp3,encode,theora,jpeg2k?] )
55 fftw? ( sci-libs/fftw:3.0= )
61 jack? ( virtual/jack )
62 jemalloc? ( dev-libs/jemalloc:= )
63 jpeg2k? ( media-libs/openjpeg:0 )
64 llvm? ( sys-devel/llvm:= )
69 nls? ( virtual/libiconv )
70 openal? ( media-libs/openal )
71 opencl? ( virtual/opencl )
72 openimageio? ( >=media-libs/openimageio-1.7.0 )
74 >=media-libs/ilmbase-2.2.0:=
75 >=media-libs/openexr-2.2.0:=
77 opensubdiv? ( >=media-libs/opensubdiv-3.3.0:=[cuda=,opencl=] )
79 media-gfx/openvdb[${PYTHON_USEDEP},-abi3-compat(-),abi4-compat(+)]
81 >=dev-libs/c-blosc-1.5.2
83 osl? ( media-libs/osl:= )
84 sdl? ( media-libs/libsdl2[sound,joystick] )
85 sndfile? ( media-libs/libsndfile )
86 tiff? ( media-libs/tiff:0 )
87 valgrind? ( dev-util/valgrind )"
90 >=dev-cpp/eigen-3.2.8:3
93 app-doc/doxygen[-nodot(-),dot(+),latex]
94 dev-python/sphinx[latex]
96 nls? ( sys-devel/gettext )"
99 "${FILESDIR}/${PN}-fix-install-rules.patch"
100 "${FILESDIR}/${P}-gcc-8.patch"
101 "${FILESDIR}/${P}-ffmpeg-4-compat.patch"
102 "${FILESDIR}/${P}-fix-for-gcc9-new-openmp-data-sharing.patch"
105 blender_check_requirements() {
106 [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
109 CHECKREQS_DISK_BUILD="4G" check-reqs_pkg_pretend
114 blender_check_requirements
118 blender_check_requirements
119 python-single-r1_pkg_setup
123 cmake-utils_src_prepare
125 # we don't want static glew, but it's scattered across
126 # multiple files that differ from version to version
127 # !!!CHECK THIS SED ON EVERY VERSION BUMP!!!
129 while IFS="" read -d $'\0' -r file ; do
130 sed -i -e '/-DGLEW_STATIC/d' "${file}" || die
131 done < <(find . -type f -name "CMakeLists.txt")
133 # Disable MS Windows help generation. The variable doesn't do what it
135 sed -e "s|GENERATE_HTMLHELP = YES|GENERATE_HTMLHELP = NO|" \
136 -i doc/doxygen/Doxyfile || die
140 # FIX: forcing '-funsigned-char' fixes an anti-aliasing issue with menu
141 # shadows, see bug #276338 for reference
142 append-flags -funsigned-char
144 # Blender is compatible ABI 4 or less, so use ABI 4.
145 append-cppflags -DOPENVDB_ABI_VERSION_NUMBER=4
148 -DPYTHON_VERSION="${EPYTHON/python/}"
149 -DPYTHON_LIBRARY="$(python_get_library_path)"
150 -DPYTHON_INCLUDE_DIR="$(python_get_includedir)"
151 -DWITH_INSTALL_PORTABLE=OFF
152 -DWITH_PYTHON_INSTALL=OFF
153 -DWITH_PYTHON_INSTALL_NUMPY=OFF
154 -DWITH_STATIC_LIBS=OFF
155 -DWITH_SYSTEM_GLEW=ON
156 -DWITH_SYSTEM_OPENJPEG=ON
157 -DWITH_SYSTEM_EIGEN3=ON
162 -DWITH_BULLET=$(usex bullet)
163 -DWITH_CODEC_FFMPEG=$(usex ffmpeg)
164 -DWITH_CODEC_SNDFILE=$(usex sndfile)
165 -DWITH_CUDA=$(usex cuda)
166 -DWITH_CYCLES_DEVICE_CUDA=$(usex cuda TRUE FALSE)
167 -DWITH_CYCLES=$(usex cycles)
168 -DWITH_CYCLES_OSL=$(usex osl)
169 -DWITH_LLVM=$(usex llvm)
170 -DWITH_FFTW3=$(usex fftw)
171 -DWITH_GAMEENGINE=$(usex game-engine)
172 -DWITH_HEADLESS=$(usex headless)
173 -DWITH_X11=$(usex !headless)
174 -DWITH_IMAGE_DDS=$(usex dds)
175 -DWITH_IMAGE_OPENEXR=$(usex openexr)
176 -DWITH_IMAGE_OPENJPEG=$(usex jpeg2k)
177 -DWITH_IMAGE_TIFF=$(usex tiff)
178 -DWITH_INPUT_NDOF=$(usex ndof)
179 -DWITH_INTERNATIONAL=$(usex nls)
180 -DWITH_JACK=$(usex jack)
181 -DWITH_MOD_FLUID=$(usex elbeem)
182 -DWITH_MOD_OCEANSIM=$(usex fftw)
183 -DWITH_OPENAL=$(usex openal)
184 -DWITH_OPENCL=$(usex opencl)
185 -DWITH_OPENCOLORIO=$(usex color-management)
186 -DWITH_OPENCOLLADA=$(usex collada)
187 -DWITH_OPENIMAGEIO=$(usex openimageio)
188 -DWITH_OPENMP=$(usex openmp)
189 -DWITH_OPENSUBDIV=$(usex opensubdiv)
190 -DWITH_OPENVDB=$(usex openvdb)
191 -DWITH_OPENVDB_BLOSC=$(usex openvdb)
192 -DWITH_PLAYER=$(usex player)
193 -DWITH_SDL=$(usex sdl)
194 -DWITH_CXX_GUARDEDALLOC=$(usex debug)
195 -DWITH_ASSERT_ABORT=$(usex debug)
196 -DWITH_GTESTS=$(usex test)
197 -DWITH_DOC_MANPAGE=$(usex man)
198 -DWITH_MEM_JEMALLOC=$(usex jemalloc)
199 -DWITH_MEM_VALGRIND=$(usex valgrind)
201 cmake-utils_src_configure
205 cmake-utils_src_compile
208 # Workaround for binary drivers.
211 addpredict /dev/nvidiactl
213 einfo "Generating Blender C/C++ API docs ..."
214 cd "${CMAKE_USE_DIR}"/doc/doxygen || die
215 doxygen -u Doxyfile || die
216 doxygen || die "doxygen failed to build API docs."
218 cd "${CMAKE_USE_DIR}" || die
219 einfo "Generating (BPY) Blender Python API docs ..."
220 "${BUILD_DIR}"/bin/blender --background --python doc/python_api/sphinx_doc_gen.py -noaudio || die "sphinx failed."
222 cd "${CMAKE_USE_DIR}"/doc/python_api || die
223 sphinx-build sphinx-in BPY_API || die "sphinx failed."
229 einfo "Running Blender Unit Tests ..."
230 cd "${BUILD_DIR}"/bin/tests || die
239 # Pax mark blender for hardened support.
240 pax-mark m "${CMAKE_BUILD_DIR}"/bin/blender
243 docinto "html/API/python"
244 dodoc -r "${CMAKE_USE_DIR}"/doc/python_api/BPY_API/.
246 docinto "html/API/blender"
247 dodoc -r "${CMAKE_USE_DIR}"/doc/doxygen/html/.
250 cmake-utils_src_install
254 dodoc "${CMAKE_USE_DIR}"/release/text/readme.html
255 rm -r "${ED%/}"/usr/share/doc/blender || die
257 python_fix_shebang "${ED%/}/usr/bin/blender-thumbnailer.py"
258 python_optimize "${ED%/}/usr/share/blender/${MY_PV}/scripts"
263 elog "Blender uses python integration. As such, may have some"
264 elog "inherit risks with running unknown python scripts."
266 elog "It is recommended to change your blender temp directory"
267 elog "from /tmp to /home/user/tmp or another tmp file under your"
268 elog "home directory. This can be done by starting blender, then"
269 elog "dragging the main menu down do display all paths."
272 ewarn "This ebuild does not unbundle the massive amount of 3rd party"
273 ewarn "libraries which are shipped with blender. Note that"
274 ewarn "these have caused security issues in the past."
275 ewarn "If you are concerned about security, file a bug upstream:"
276 ewarn " https://developer.blender.org/"
278 xdg_icon_cache_update
279 xdg_mimeinfo_database_update
283 xdg_icon_cache_update
284 xdg_mimeinfo_database_update
287 ewarn "You may want to remove the following directory."
288 ewarn "~/.config/${PN}/${MY_PV}/cache/"
289 ewarn "It may contain extra render kernels not tracked by portage"