From 12f7a724f86a2bd829a35bdd0ac276e177f58888 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 12 Jan 2022 15:38:20 +1000 Subject: [PATCH] Blender3: add recipe for 3.0.0 version --- .../blender/additional-files/Blender3.sh | 2 + media-gfx/blender/blender3-3.0.0.recipe | 295 ++++++++++++++++++ .../blender/patches/blender3-3.0.0.patchset | 190 +++++++++++ 3 files changed, 487 insertions(+) create mode 100755 media-gfx/blender/additional-files/Blender3.sh create mode 100644 media-gfx/blender/blender3-3.0.0.recipe create mode 100644 media-gfx/blender/patches/blender3-3.0.0.patchset diff --git a/media-gfx/blender/additional-files/Blender3.sh b/media-gfx/blender/additional-files/Blender3.sh new file mode 100755 index 000000000..1c38f6b2c --- /dev/null +++ b/media-gfx/blender/additional-files/Blender3.sh @@ -0,0 +1,2 @@ +#!/bin/bash +MESA_GL_VERSION_OVERRIDE="4.1" `finddir B_APPS_DIRECTORY`/Blender3/Blender -p 50 50 1024 768 diff --git a/media-gfx/blender/blender3-3.0.0.recipe b/media-gfx/blender/blender3-3.0.0.recipe new file mode 100644 index 000000000..14a5b2933 --- /dev/null +++ b/media-gfx/blender/blender3-3.0.0.recipe @@ -0,0 +1,295 @@ +SUMMARY="3D Creation/Animation/Publishing System" +DESCRIPTION="Blender is the free and open source 3D creation suite. It \ +supports the entirety of the 3D pipeline—modeling, rigging, animation, \ +simulation, rendering, compositing and motion tracking, even video editing \ +and game creation. +Advanced users employ Blender’s API for Python scripting to customize the \ +application and write specialized tools; often these are included in Blender’s \ +future releases. Blender is well suited to individuals and small studios who \ +benefit from its unified pipeline and responsive development process." +HOMEPAGE="https://www.blender.org/" +COPYRIGHT="2002-2021 Blender Foundation" +LICENSE="GNU GPL v2" +REVISION="1" +SOURCE_URI="https://download.blender.org/source/blender-$portVersion.tar.xz" +CHECKSUM_SHA256="50f0f32bcdf8825a12ba5c8d853b6e6c6b2da65ef01e858ea5900a06cccbf1cb" +SOURCE_DIR="blender-$portVersion" +PATCHES=" + blender3-$portVersion.patchset + " +ADDITIONAL_FILES=" + blender.rdef.in + Blender3.sh + " + +ARCHITECTURES="all !x86_gcc2" +SECONDARY_ARCHITECTURES="x86" + +PYTHON_VERSION="3.9" + +PROVIDES=" + blender3$secondaryArchSuffix = $portVersion + app:blender3 = $portVersion + cmd:blender_thumbnailer.py${secondaryArchSuffix} = $portVersion + " +REQUIRES=" + haiku$secondaryArchSuffix + numpy${secondaryArchSuffix}_python39 + requests_python39 + lib:libalembic$secondaryArchSuffix + lib:libavcodec$secondaryArchSuffix + lib:libavdevice$secondaryArchSuffix + lib:libboost_atomic$secondaryArchSuffix + lib:libboost_chrono$secondaryArchSuffix + lib:libboost_date_time$secondaryArchSuffix + lib:libboost_filesystem$secondaryArchSuffix + lib:libboost_locale$secondaryArchSuffix + lib:libboost_regex$secondaryArchSuffix + lib:libboost_system$secondaryArchSuffix + lib:libboost_thread$secondaryArchSuffix + lib:libembree3$secondaryArchSuffix + lib:libexecinfo$secondaryArchSuffix + lib:libfftw3$secondaryArchSuffix + lib:libfreetype$secondaryArchSuffix + lib:libgcc_s$secondaryArchSuffix + lib:libgl$secondaryArchSuffix + lib:libglew$secondaryArchSuffix + lib:libglu$secondaryArchSuffix + lib:libgmp$secondaryArchSuffix + lib:libgmpxx$secondaryArchSuffix + lib:libgomp$secondaryArchSuffix + lib:libhdf5$secondaryArchSuffix + lib:libiconv$secondaryArchSuffix + lib:libicui18n$secondaryArchSuffix + lib:libicuuc$secondaryArchSuffix + lib:libiex_3_0$secondaryArchSuffix + lib:libilmthread_3_0$secondaryArchSuffix + lib:libimath_3_0$secondaryArchSuffix + lib:libLLVM_9$secondaryArchSuffix + lib:liblzma$secondaryArchSuffix + lib:liblzo2$secondaryArchSuffix + lib:libopenal$secondaryArchSuffix + lib:libopencolladabaseutils$secondaryArchSuffix + lib:libopencolorio$secondaryArchSuffix + lib:libopenimageio$secondaryArchSuffix + lib:libopenjp2$secondaryArchSuffix +# lib:libopenvdb$secondaryArchSuffix + lib:libosdCPU$secondaryArchSuffix + lib:libosdGPU$secondaryArchSuffix +# lib:liboslcomp$secondaryArchSuffix + lib:libpcre$secondaryArchSuffix + lib:libpng16$secondaryArchSuffix + lib:libpotrace$secondaryArchSuffix + lib:libpugixml$secondaryArchSuffix + lib:libpython${PYTHON_VERSION}$secondaryArchSuffix + lib:libsdl2_2.0$secondaryArchSuffix + lib:libsndfile$secondaryArchSuffix + lib:libtiff$secondaryArchSuffix + lib:libtinyxml$secondaryArchSuffix + lib:libturbojpeg$secondaryArchSuffix + lib:libxml2$secondaryArchSuffix + lib:libyaml_cpp$secondaryArchSuffix + lib:libz$secondaryArchSuffix + lib:libzstd$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + numpy${secondaryArchSuffix}_python39 + devel:eigen$secondaryArchSuffix + devel:libalembic$secondaryArchSuffix + devel:libavcodec$secondaryArchSuffix + devel:libavdevice$secondaryArchSuffix + devel:libboost_atomic$secondaryArchSuffix >= 1.69.0 + devel:libboost_chrono$secondaryArchSuffix >= 1.69.0 + devel:libboost_date_time$secondaryArchSuffix >= 1.69.0 + devel:libboost_filesystem$secondaryArchSuffix >= 1.69.0 + devel:libboost_locale$secondaryArchSuffix >= 1.69.0 + devel:libboost_regex$secondaryArchSuffix >= 1.69.0 + devel:libboost_system$secondaryArchSuffix >= 1.69.0 + devel:libboost_thread$secondaryArchSuffix >= 1.69.0 + devel:libembree3$secondaryArchSuffix + devel:libexecinfo$secondaryArchSuffix + devel:libfftw3$secondaryArchSuffix + devel:libfreetype$secondaryArchSuffix + devel:libgl$secondaryArchSuffix + devel:libglew$secondaryArchSuffix + devel:libglu$secondaryArchSuffix + devel:libgmp$secondaryArchSuffix + devel:libgomp$secondaryArchSuffix + devel:libhdf5$secondaryArchSuffix + devel:libiconv$secondaryArchSuffix + devel:libicuuc$secondaryArchSuffix >= 66 + devel:libiex_3_0$secondaryArchSuffix + devel:libilmthread_3_0$secondaryArchSuffix + devel:libimath_3_0$secondaryArchSuffix + devel:libllvm_9$secondaryArchSuffix + devel:liblzma$secondaryArchSuffix + devel:liblzo2$secondaryArchSuffix + devel:libopenal$secondaryArchSuffix + devel:libopencolladabaseutils$secondaryArchSuffix + devel:libopencolorio$secondaryArchSuffix + devel:libopenimageio$secondaryArchSuffix + devel:libopenjp2$secondaryArchSuffix +# devel:libopenvdb$secondaryArchSuffix + devel:libosdCPU$secondaryArchSuffix + devel:libosdGPU$secondaryArchSuffix +# devel:liboslcomp$secondaryArchSuffix + devel:libpcre$secondaryArchSuffix + devel:libpng16$secondaryArchSuffix + devel:libpotrace$secondaryArchSuffix + devel:libpugixml$secondaryArchSuffix + devel:libpython${PYTHON_VERSION}$secondaryArchSuffix + devel:libsdl2_2.0$secondaryArchSuffix + devel:libsndfile$secondaryArchSuffix + devel:libtiff$secondaryArchSuffix + devel:libtinyxml$secondaryArchSuffix + devel:libturbojpeg$secondaryArchSuffix + devel:libxml2$secondaryArchSuffix + devel:libyaml_cpp$secondaryArchSuffix + devel:libz$secondaryArchSuffix + devel:libzstd$secondaryArchSuffix + lib:libavdevice$secondaryArchSuffix # REQUIRED + " +BUILD_PREREQUIRES=" + numpy${secondaryArchSuffix}_python39 + requests_python39 + cmd:cmake + cmd:find + cmd:gcc$secondaryArchSuffix + cmd:ld$secondaryArchSuffix + cmd:ninja + cmd:python${PYTHON_VERSION} + cmd:sed + cmd:strip + " + + +PATCH() +{ + find . -type f -name "*.py" | xargs sed -i -e 's,python3,python3.9,g' +} + +BUILD() +{ + # IMPORTANT INFORMATION, PLEASE READ BEFORE CHANGE ANYTHING. + + # Please do not make any changes here if they not *REALLY* necessary. + # Keep this list short and tidy. + + # Blender uses the following settings to produce the official releases: + # https://github.com/blender/blender/blob/master/build_files/cmake/config/blender_release.cmake + # This settings are used on Haiku too, but we had to override some settings. + # We should follow their settings as closely as possible to make interoperability possible between diferent platforms. + # In the recipe there are 3 group for the compiler flags: + # - platform specific (required to build Blender on Haiku) + # - bugous (these settings should work but they breaks build / functionality on Haiku, should be fixed) + # - missing deps (required dependency is not (yet) available for Haiku, should be ported) + # If a change required please put it in the correct category, if you are unsure, ask at HaikuPorts. + + INCLUDE_DIR="`finddir B_SYSTEM_HEADERS_DIRECTORY`${secondaryArchSubDir}" + + # Haiku specific settings + BLENDER_PLATFORM_SPECIFIC="-DCMAKE_INSTALL_PREFIX:PATH=$appsDir/Blender3 \ + -DPYTHON_VERSION=${PYTHON_VERSION} \ + -DPYTHON_INCLUDE_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY`/python${PYTHON_VERSION}/ \ + -DPYTHON_LIBRARY=`finddir B_SYSTEM_LIB_DIRECTORY`${secondaryArchSubDir}/libpython${PYTHON_VERSION}.so.1.0 \ + -DPYTHON_EXECUTABLE=/bin/python${PYTHON_VERSION} \ + -DOPENCOLLADA_COLLADABASEUTILS_INCLUDE_DIR=${INCLUDE_DIR}/opencollada/COLLADABaseUtils \ + -DOPENCOLLADA_COLLADAFRAMEWORK_INCLUDE_DIR=${INCLUDE_DIR}/opencollada/COLLADAFramework \ + -DOPENCOLLADA_COLLADASAXFRAMEWORKLOADER_INCLUDE_DIR=${INCLUDE_DIR}/opencollada/COLLADASaxFrameworkLoader \ + -DOPENCOLLADA_COLLADASTREAMWRITER_INCLUDE_DIR=${INCLUDE_DIR}/opencollada/COLLADAStreamWriter \ + -DOPENCOLLADA_GENERATEDSAXPARSER_INCLUDE_DIR=${INCLUDE_DIR}/opencollada/GeneratedSaxParser \ + -DOPENSUBDIV_INCLUDE_DIR=${INCLUDE_DIR} \ + -DZLIB_LIBRARY_RELEASE=`finddir B_SYSTEM_LIB_DIRECTORY`${secondaryArchSubDir}/libz.so.1 \ + -DWITH_GHOST_SDL=ON \ + -DWITH_BUILDINFO=OFF \ + -DWITH_PYTHON_INSTALL=OFF \ + -DWITH_PYTHON_INSTALL_NUMPY=OFF \ + -DWITH_PYTHON_INSTALL_REQUESTS=OFF \ + -DWITH_PYTHON_MODULE=OFF \ + -DWITH_PYTHON_SAFETY=OFF \ + -DWITH_CYCLES_EMBREE=OFF \ + -DWITH_PYTHON_NUMPY=ON \ + -DWITH_TBB=OFF \ + -DCMAKE_SKIP_RPATH=ON \ + -Wno-dev" + + # Release settings breaks build on Haiku + BLENDER_BUGOUS="-DWITH_CYCLES_LOGGING=OFF \ + -DWITH_GAMEENGINE_DECKLINK=OFF \ + -DWITH_GTESTS=OFF \ + -DWITH_SYSTEM_EIGEN3=ON \ + -DWITH_SYSTEM_LZO=ON" + + # Missing deps on Haiku + BLENDER_MISSING="-DWITH_JACK=OFF \ + -DWITH_MEM_JEMALLOC=OFF \ + -DWITH_INPUT_NDOF=OFF" + + # Extra CXX Flags + BLENDER_CXX="-std=c++11" + + mkdir -p build_haiku + cd build_haiku + + cmake .. \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -C ../build_files/cmake/config/blender_release.cmake \ + $BLENDER_PLATFORM_SPECIFIC \ + $BLENDER_BUGOUS \ + $BLENDER_MISSING \ + -DCMAKE_CXX_FLAGS="$BLENDER_CXX" + + ninja $jobArgs +} + +INSTALL() +{ + cd build_haiku + ninja install $jobArgs + + mv $appsDir/Blender3/blender $appsDir/Blender3/Blender + + local MAJOR="`echo "$portVersion" | cut -d. -f1`" + local MIDDLE="`echo "$portVersion" | cut -d. -f2`" + local MINOR="`echo "$portVersion" | cut -d. -f3`" + sed \ + -e "s|@MAJOR@|$MAJOR|" \ + -e "s|@MIDDLE@|$MIDDLE|" \ + -e "s|@MINOR@|$MINOR|" \ + $portDir/additional-files/blender.rdef.in > blender.rdef + + addResourcesToBinaries blender.rdef \ + $appsDir/Blender3/Blender + + # Startscript for windowed mode (WORKAROUND) + cp $portDir/additional-files/Blender3.sh $appsDir/Blender3/Blender.sh + chmod +x $appsDir/Blender3/Blender.sh + + # Installing extra-attribs + rc blender.rdef + resattr -o $appsDir/Blender3/Blender.sh \ + blender.rsrc + + cd $appsDir/Blender3 + mkdir -p $docDir/blender + + rm -rf blender.desktop + + addAppDeskbarSymlink $appsDir/Blender3/Blender.sh Blender-3.0 + + mkdir -p $binDir + ln -s $appsDir/Blender3/blender_thumbnailer.py \ + $binDir/blender_thumbnailer.py +} + +TEST() +{ + cd build_haiku + # The whole testcase is around 1GB and not included. Get it from here: + # svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/tests + # and put it in "work-2.xx/sources/lib" + make test +} diff --git a/media-gfx/blender/patches/blender3-3.0.0.patchset b/media-gfx/blender/patches/blender3-3.0.0.patchset new file mode 100644 index 000000000..3ecc0b72c --- /dev/null +++ b/media-gfx/blender/patches/blender3-3.0.0.patchset @@ -0,0 +1,190 @@ +From a3c450d7c077a76ddc6e892529a61e7aa649a5c8 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 19 Mar 2021 08:13:09 +1000 +Subject: Fix for Haiku + + +diff --git a/extern/wcwidth/wcwidth.h b/extern/wcwidth/wcwidth.h +index 3039a50..68f21b6 100644 +--- a/extern/wcwidth/wcwidth.h ++++ b/extern/wcwidth/wcwidth.h +@@ -21,7 +21,7 @@ + #define __WCWIDTH_H__ + + #ifndef __cplusplus +-# if defined(__APPLE__) || defined(__NetBSD__) ++# if defined(__APPLE__) || defined(__NetBSD__) || defined(__HAIKU__) + /* The standard header is missing on macOS. */ + #include + typedef unsigned int char32_t; +diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h +index 4f71e3a..4d55d5d 100644 +--- a/source/blender/blenlib/BLI_threads.h ++++ b/source/blender/blenlib/BLI_threads.h +@@ -177,7 +177,7 @@ void BLI_thread_queue_nowait(ThreadQueue *queue); + + /* Thread local storage */ + +-#if defined(__APPLE__) ++#if defined(__APPLE__) || defined(__HAIKU__) + # define ThreadLocal(type) pthread_key_t + # define BLI_thread_local_create(name) pthread_key_create(&name, NULL) + # define BLI_thread_local_delete(name) pthread_key_delete(name) +diff --git a/source/blender/windowmanager/intern/wm_platform_support.c b/source/blender/windowmanager/intern/wm_platform_support.c +index 54fc454..89514f3 100644 +--- a/source/blender/windowmanager/intern/wm_platform_support.c ++++ b/source/blender/windowmanager/intern/wm_platform_support.c +@@ -118,7 +118,7 @@ bool WM_platform_support_perform_checks() + char link[WM_PLATFORM_SUPPORT_TEXT_SIZE]; + + bool result = true; +- ++#ifndef __HAIKU__ + eGPUSupportLevel support_level = GPU_platform_support_level(); + const char *platform_key = GPU_platform_support_level_key(); + +@@ -216,6 +216,6 @@ bool WM_platform_support_perform_checks() + WM_ghost_show_message_box( + title, message, "Find Latest Drivers", "Continue Anyway", link, dialog_options); + } +- ++#endif + return result; + } +-- +2.30.2 + + +From e42f83b51d19c603044a187fecaa602978898300 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Fri, 19 Mar 2021 11:33:53 +1000 +Subject: Fix hangs on exit + + +diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c +index 1a45e53..df233cb 100644 +--- a/source/blender/windowmanager/intern/wm_init_exit.c ++++ b/source/blender/windowmanager/intern/wm_init_exit.c +@@ -624,6 +624,10 @@ void WM_exit_ex(bContext *C, const bool do_python) + + ED_file_exit(); /* for fsmenu */ + ++ /* No need to call this early, rather do it late so that other ++ * pieces of Blender using sound may exit cleanly, see also T50676. */ ++ BKE_sound_exit(); ++ + UI_exit(); + BKE_blender_userdef_data_free(&U, false); + +@@ -642,10 +646,6 @@ void WM_exit_ex(bContext *C, const bool do_python) + BLI_threadapi_exit(); + BLI_task_scheduler_exit(); + +- /* No need to call this early, rather do it late so that other +- * pieces of Blender using sound may exit cleanly, see also T50676. */ +- BKE_sound_exit(); +- + BKE_appdir_exit(); + CLG_exit(); + +-- +2.30.2 + + +From 1b366a4083109e8eb645bdcb1a8e71a64a93d914 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Sun, 26 Dec 2021 17:05:15 +1000 +Subject: applying patch openexr3.patch + + +diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake +index 090f80b..a2f7b4c 100644 +--- a/build_files/cmake/Modules/FindOpenEXR.cmake ++++ b/build_files/cmake/Modules/FindOpenEXR.cmake +@@ -34,11 +34,10 @@ ENDIF() + SET(_openexr_libs_ver_init "2.0") + + SET(_openexr_FIND_COMPONENTS +- Half + Iex +- IlmImf +- IlmThread + Imath ++ OpenEXR ++ IlmThread + ) + + SET(_openexr_SEARCH_DIRS +@@ -120,7 +119,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG + IF(OPENEXR_FOUND) + SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES}) + # Both include paths are needed because of dummy OSL headers mixing #include and #include :( +- SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}/OpenEXR) ++ SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}/OpenEXR ${OPENEXR_INCLUDE_DIR}/Imath) + ENDIF() + + MARK_AS_ADVANCED( +diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp +index adf09f8..4784a9b 100644 +--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp ++++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp +@@ -38,8 +38,10 @@ + #include + #include + #include ++#include + #include + #include ++#include + #include + #include + #include +-- +2.30.2 + + +From d6c36dcc77d6f7b691dddee7c17fb8749f0e77f9 Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Sun, 26 Dec 2021 20:55:05 +1000 +Subject: Link with icu + + +diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake +index fc0c37e..1876bae 100644 +--- a/build_files/cmake/platform/platform_unix.cmake ++++ b/build_files/cmake/platform/platform_unix.cmake +@@ -505,7 +505,7 @@ endif() + + # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed + if(HAIKU) +- list(APPEND PLATFORM_LINKLIBS -lnetwork) ++ list(APPEND PLATFORM_LINKLIBS -lnetwork -liconv -licuuc -licui18n) + else() + list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm) + endif() +-- +2.30.2 + + +From f3c84cddd8ca36f931e7260194dd69f93c776ccf Mon Sep 17 00:00:00 2001 +From: Gerasim Troeglazov <3dEyes@gmail.com> +Date: Sun, 26 Dec 2021 20:55:26 +1000 +Subject: Use clock_gettime for Haiku + + +diff --git a/source/blender/blenlib/intern/uuid.cc b/source/blender/blenlib/intern/uuid.cc +index de4602b..300aa93 100644 +--- a/source/blender/blenlib/intern/uuid.cc ++++ b/source/blender/blenlib/intern/uuid.cc +@@ -42,7 +42,7 @@ bUUID BLI_uuid_generate_random() + static_assert(std::mt19937_64::max() == 0xffffffffffffffffLL); + + struct timespec ts; +-#ifdef __APPLE__ ++#if defined(__APPLE__) || defined(__HAIKU__) + /* `timespec_get()` is only available on macOS 10.15+, so until that's the minimum version + * supported by Blender, use another function to get the timespec. + * +-- +2.30.2 +