Subject: [bug#70880] [PATCH v2 7/8] gnu: Add prusa-wxwidgets.

From: "Artyom V. Poptsov" <[email-masked]>
Date: Mon, 1 Jul 2024 20:07:09 +0300

* gnu/packages/engineering.scm (prusa-wxwidgets): New variable.
* gnu/packages/patches/prusa-wxwidgets-makefile-fix.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register
  "prusa-wxwidgets-makefile-fix.patch".

Co-authored-by: Nikita Domnitskii <[email-masked]>
Change-Id: I9043c2acc95986275ee24d9c5d944e5fe2702e99
---
 gnu/local.mk                                  |   1 +
 .../prusa-wxwidgets-makefile-fix.patch        | 112 ++++++++++++++++++
 gnu/packages/wxwidgets.scm                    |  29 +++++
 3 files changed, 142 insertions(+)
 create mode 100644 gnu/packages/patches/prusa-wxwidgets-makefile-fix.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index e263261986..29107a618b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1842,6 +1842,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/prusa-slicer-boost-fixes.patch		\
   %D%/packages/patches/prusa-slicer-fix-tests.patch		\
   %D%/packages/patches/prusa-slicer-with-cereal-1.3.1.patch	\
+  %D%/packages/patches/prusa-wxwidgets-makefile-fix.patch	\
   %D%/packages/patches/pthreadpool-system-libraries.patch	\
   %D%/packages/patches/python-3.12-fix-tests.patch		\
   %D%/packages/patches/python-accupy-use-matplotx.patch		\
diff --git a/gnu/packages/patches/prusa-wxwidgets-makefile-fix.patch b/gnu/packages/patches/prusa-wxwidgets-makefile-fix.patch
new file mode 100644
index 0000000000..aadf976588
--- /dev/null
+++ b/gnu/packages/patches/prusa-wxwidgets-makefile-fix.patch
@@ -0,0 +1,112 @@
+diff --git a/Makefile.in b/Makefile.in
+index 8f33aa2ff4..39928382da 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -4358,7 +4358,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS =  \
+ 	monodll_msw_utils.o \
+ 	monodll_utilsexc.o \
+ 	monodll_fswatcher.o \
+-	monodll_msw_secretstore.o
++	monodll_msw_secretstore.o \
+ 	monodll_msw_uilocale.o
+ @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS)
+ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS \
+@@ -5284,7 +5284,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS =  \
+ 	monodll_uuid.o \
+ 	monodll_msw_evtloop.o \
+ 	monodll_access.o \
+-	monodll_dark_mode.o
++	monodll_dark_mode.o \
+ 	monodll_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS = \
+@@ -6196,7 +6196,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_1 =  \
+ 	monodll_uuid.o \
+ 	monodll_msw_evtloop.o \
+ 	monodll_access.o \
+-	monodll_dark_mode.o
++	monodll_dark_mode.o \
+ 	monodll_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_1 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_1)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_1 = \
+@@ -6371,7 +6371,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1 =  \
+ 	monolib_msw_utils.o \
+ 	monolib_utilsexc.o \
+ 	monolib_fswatcher.o \
+-	monolib_msw_secretstore.o
++	monolib_msw_secretstore.o \
+ 	monolib_msw_uilocale.o
+ @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_1 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1)
+ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_1 \
+@@ -7297,7 +7297,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_2 =  \
+ 	monolib_uuid.o \
+ 	monolib_msw_evtloop.o \
+ 	monolib_access.o \
+-	monolib_dark_mode.o
++	monolib_dark_mode.o \
+ 	monolib_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_2 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_2)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_2 = \
+@@ -8209,7 +8209,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_3 =  \
+ 	monolib_uuid.o \
+ 	monolib_msw_evtloop.o \
+ 	monolib_access.o \
+-	monolib_dark_mode.o
++	monolib_dark_mode.o \
+ 	monolib_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_3 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_3)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_3 = \
+@@ -8436,7 +8436,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2 =  \
+ 	basedll_msw_utils.o \
+ 	basedll_utilsexc.o \
+ 	basedll_fswatcher.o \
+-	basedll_msw_secretstore.o
++	basedll_msw_secretstore.o \
+ 	basedll_msw_uilocale.o
+ @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_2 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2)
+ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_2 \
+@@ -8523,7 +8523,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3 =  \
+ 	baselib_msw_utils.o \
+ 	baselib_utilsexc.o \
+ 	baselib_fswatcher.o \
+-	baselib_msw_secretstore.o
++	baselib_msw_secretstore.o \
+ 	baselib_msw_uilocale.o
+ @COND_PLATFORM_WIN32_1@__BASE_PLATFORM_SRC_OBJECTS_3 = $(COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3)
+ @COND_PLATFORM_WIN32_1@__BASE_AND_GUI_PLATFORM_SRC_OBJECTS_3 \
+@@ -9464,7 +9464,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_4 =  \
+ 	coredll_uuid.o \
+ 	coredll_msw_evtloop.o \
+ 	coredll_access.o \
+-	coredll_dark_mode.o
++	coredll_dark_mode.o \
+ 	coredll_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_4 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_4)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_4 = \
+@@ -10376,7 +10376,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_5 =  \
+ 	coredll_uuid.o \
+ 	coredll_msw_evtloop.o \
+ 	coredll_access.o \
+-	coredll_dark_mode.o
++	coredll_dark_mode.o \
+ 	coredll_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_5 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_5)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_5 = \
+@@ -11204,7 +11204,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_6 =  \
+ 	corelib_uuid.o \
+ 	corelib_msw_evtloop.o \
+ 	corelib_access.o \
+-	corelib_dark_mode.o
++	corelib_dark_mode.o \
+ 	corelib_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_6 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_6)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_6 = \
+@@ -12116,7 +12116,7 @@ COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_7 =  \
+ 	corelib_uuid.o \
+ 	corelib_msw_evtloop.o \
+ 	corelib_access.o \
+-	corelib_dark_mode.o
++	corelib_dark_mode.o \
+ 	corelib_msw_bmpbndl.o
+ @COND_TOOLKIT_MSW@__LOWLEVEL_SRC_OBJECTS_7 = $(COND_TOOLKIT_MSW___LOWLEVEL_SRC_OBJECTS_7)
+ @COND_TOOLKIT_OSX_COCOA@__LOWLEVEL_SRC_OBJECTS_7 = \
diff --git a/gnu/packages/wxwidgets.scm b/gnu/packages/wxwidgets.scm
index 973e962fb1..2cf2ceba56 100644
--- a/gnu/packages/wxwidgets.scm
+++ b/gnu/packages/wxwidgets.scm
@@ -265,6 +265,35 @@ (define-public wxwidgets-2
                (("-Wall") "-Wall -Wno-narrowing"))
              #t)))))))
 
+(define-public prusa-wxwidgets
+  ;; There is no tag/release, all patches are in separate branch.
+  (let ((commit "78aa2dc0ea7ce99dc19adc1140f74c3e2e3f3a26"))
+    (package
+      (inherit wxwidgets)
+      (name "prusa-wxwidgets")
+      (version "3.2.0")
+      (home-page "https://github.com/prusa3d/wxWidgets")
+      (source
+       (origin
+         (inherit (package-source wxwidgets))
+         (method git-fetch)
+         (uri (git-reference
+               (url home-page)
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (patches (search-patches "prusa-wxwidgets-makefile-fix.patch"))
+         (sha256
+          (base32
+           "02nd07c23xbclnf1jjfbv6r5vqjb80gsdy2l559c5qzgdcvfd2xd"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments wxwidgets)
+         ((#:configure-flags flags)
+          ;; To fix 3D rendering in PrusaSlicer, wxWidgets must be compiled with
+          ;; "--disable-glcanvasegl" flag.
+          ;;
+          ;; See <https://github.com/NixOS/nixpkgs/issues/193135>
+          #~(cons "--disable-glcanvasegl" #$flags)))))))
+
 (define-public python-wxpython
   (package
     (name "python-wxpython")
-- 
2.45.2