From 10819b56073e0cab9ca864ec4ebcfc48d9965bba Mon Sep 17 00:00:00 2001
From: Chris Morgan <aur@chrismorgan.info>
Date: Sat, 1 May 2021 01:08:26 +1000
Subject: [PATCH] Patch to support openexr 3.0

Patch taken from the community/blender package,
https://github.com/archlinux/svntogit-community/commit/463ea4f7e7e3b7fb9384336d5dea14ea183fa65f
---
 .SRCINFO               |  4 +++-
 PKGBUILD               |  6 +++++-
 blender-openexr3.patch | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100644 blender-openexr3.patch

diff --git a/.SRCINFO b/.SRCINFO
index 55869b2..66b200d 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
 pkgbase = blender-wayland-git
 	pkgdesc = A fully integrated 3D graphics creation suite (development)
-	pkgver = 2.93.r103725.g80a8df72be9
+	pkgver = 3.0.r105703.g8f27ea40d63
 	pkgrel = 1
 	url = https://blender.org/
 	arch = i686
@@ -42,6 +42,7 @@ pkgbase = blender-wayland-git
 	source = blender-addons-contrib.git::git://git.blender.org/blender-addons-contrib.git
 	source = blender-translations.git::git://git.blender.org/blender-translations.git
 	source = blender-dev-tools.git::git://git.blender.org/blender-dev-tools.git
+	source = blender-openexr3.patch
 	source = usd_python.patch
 	source = embree.patch
 	sha256sums = SKIP
@@ -49,6 +50,7 @@ pkgbase = blender-wayland-git
 	sha256sums = SKIP
 	sha256sums = SKIP
 	sha256sums = SKIP
+	sha256sums = 5297dc61cc4edcc1d5bad3474ab882264b69d68036cebbd0f2600d9fe21d5a1b
 	sha256sums = 12bd6db5c1fe14244fd7321e3d740941a36aa545ec21b02325e7553c9214778a
 	sha256sums = 6249892f99ffd960e36f43fb893c14e2f8e4dd1d901b9581d25882e865f2603f
 
diff --git a/PKGBUILD b/PKGBUILD
index bd27daa..66cd7ec 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -13,7 +13,7 @@ _CMAKE_FLAGS+=( -DWITH_ALEMBIC_HDF5=ON )
 _CMAKE_FLAGS+=( -DWITH_CYCLES_NETWORK=OFF )
 
 pkgname=blender-wayland-git
-pkgver=2.93.r103725.g80a8df72be9
+pkgver=3.0.r105703.g8f27ea40d63
 pkgrel=1
 pkgdesc="A fully integrated 3D graphics creation suite (development)"
 arch=('i686' 'x86_64')
@@ -39,6 +39,7 @@ source=("git://git.blender.org/blender.git${_fragment}"
         'blender-addons-contrib.git::git://git.blender.org/blender-addons-contrib.git'
         'blender-translations.git::git://git.blender.org/blender-translations.git'
         'blender-dev-tools.git::git://git.blender.org/blender-dev-tools.git'
+        blender-openexr3.patch
         usd_python.patch #add missing python headers when building against python enabled usd.
         embree.patch #add missing embree link.
         )
@@ -47,6 +48,7 @@ sha256sums=('SKIP'
             'SKIP'
             'SKIP'
             'SKIP'
+            '5297dc61cc4edcc1d5bad3474ab882264b69d68036cebbd0f2600d9fe21d5a1b'
             '12bd6db5c1fe14244fd7321e3d740941a36aa545ec21b02325e7553c9214778a'
             '6249892f99ffd960e36f43fb893c14e2f8e4dd1d901b9581d25882e865f2603f')
 
@@ -64,6 +66,8 @@ prepare() {
   # update the submodules
   git submodule update --init --recursive --remote
   git apply -v "${srcdir}"/{embree,usd_python}.patch
+
+  patch -p1 < "$srcdir"/blender-openexr3.patch # Fix build with OpenEXR 3
 }
 
 build() {
diff --git a/blender-openexr3.patch b/blender-openexr3.patch
new file mode 100644
index 0000000..73a727a
--- /dev/null
+++ b/blender-openexr3.patch
@@ -0,0 +1,42 @@
+diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake
+index 090f80b8df7..a2f7b4c622b 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 <OpenEXR/foo.h> and #include <foo.h> :(
+-  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 382d86f2645..eff50b19c31 100644
+--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
++++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
+@@ -38,8 +38,10 @@
+ #include <ImfChannelList.h>
+ #include <ImfCompression.h>
+ #include <ImfCompressionAttribute.h>
++#include <ImfFrameBuffer.h>
+ #include <ImfIO.h>
+ #include <ImfInputFile.h>
++#include <ImfInt64.h>
+ #include <ImfOutputFile.h>
+ #include <ImfPixelType.h>
+ #include <ImfStandardAttributes.h>
-- 
2.31.1

