summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/godot-libjpeg-turbo-unbundle.patch
blob: f324de3d0b8c0f807ce8cac92736fa47c75884f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
From 6d8aa8582f5c312cd5aab396f90904df1ddc0567 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <rverschelde@gmail.com>
Date: Mon, 15 Sep 2025 23:43:13 +0200
Subject: [PATCH] Linux: Allow unbundling libjpeg-turbo to use system package

---
 modules/jpg/SCsub           | 182 ++++++++++++++++++------------------
 platform/linuxbsd/detect.py |   3 +
 2 files changed, 93 insertions(+), 92 deletions(-)

diff --git a/modules/jpg/SCsub b/modules/jpg/SCsub
index e5b1bc19c0b9..a45b5eff33f1 100644
--- a/modules/jpg/SCsub
+++ b/modules/jpg/SCsub
@@ -8,98 +8,96 @@ env_jpg = env_modules.Clone()
 
 thirdparty_obj = []
 
-thirdparty_dir = "#thirdparty/libjpeg-turbo"
-
-thirdparty_sources_common = [
-    "jaricom.c",
-    "jcapimin.c",
-    "jcarith.c",
-    "jchuff.c",
-    "jcicc.c",
-    "jcinit.c",
-    "jcmarker.c",
-    "jcmaster.c",
-    "jcomapi.c",
-    "jcparam.c",
-    "jcphuff.c",
-    "jctrans.c",
-    "jdapimin.c",
-    "jdarith.c",
-    "jdatadst.c",
-    "jdatadst-tj.c",
-    "jdatasrc.c",
-    "jdatasrc-tj.c",
-    "jdhuff.c",
-    "jdicc.c",
-    "jdinput.c",
-    "jdmarker.c",
-    "jdmaster.c",
-    "jdphuff.c",
-    "jdtrans.c",
-    "jerror.c",
-    "jfdctflt.c",
-    "jmemmgr.c",
-    "jmemnobs.c",
-    "jpeg_nbits.c",
-    "transupp.c",
-    "turbojpeg.c",
-]
-
-thirdparty_sources_bit_dependent = [
-    "jcapistd.c",
-    "jccoefct.c",
-    "jccolor.c",
-    "jcdctmgr.c",
-    "jcmainct.c",
-    "jcprepct.c",
-    "jcsample.c",
-    "jdcoefct.c",
-    "jdcolor.c",
-    "jdapistd.c",
-    "jddctmgr.c",
-    "jdmainct.c",
-    "jdmerge.c",
-    "jdpostct.c",
-    "jdsample.c",
-    "jfdctfst.c",
-    "jfdctint.c",
-    "jidctflt.c",
-    "jidctfst.c",
-    "jidctint.c",
-    "jidctred.c",
-    "jutils.c",
-    "jquant1.c",
-    "jquant2.c",
-]
-
-thirdparty_sources_by_bits = {
-    8: list(thirdparty_sources_bit_dependent),
-    12: list(thirdparty_sources_bit_dependent),
-}
-
-
-def source_paths(files):
-    return [thirdparty_dir + "/src/" + f for f in files]
-
-
-env_jpg.Prepend(CPPEXTPATH=[thirdparty_dir + "/src"])
-
-
-def add_bit_depth(bit_depth: int):
-    env_bit_depth = env_jpg.Clone()
-    env_bit_depth.disable_warnings()
-    env_bit_depth["OBJSUFFIX"] = f"_{bit_depth}{env_bit_depth['OBJSUFFIX']}"
-    env_bit_depth.Append(CPPDEFINES=[f"BITS_IN_JSAMPLE={bit_depth}"])
-    env_bit_depth.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_by_bits[bit_depth]))
-
-
-add_bit_depth(8)
-add_bit_depth(12)
-
-env_thirdparty = env_jpg.Clone()
-env_thirdparty.disable_warnings()
-env_thirdparty.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_common))
-env.modules_sources += thirdparty_obj
+if env["builtin_libjpeg_turbo"]:
+    thirdparty_dir = "#thirdparty/libjpeg-turbo"
+
+    thirdparty_sources_common = [
+        "jaricom.c",
+        "jcapimin.c",
+        "jcarith.c",
+        "jchuff.c",
+        "jcicc.c",
+        "jcinit.c",
+        "jcmarker.c",
+        "jcmaster.c",
+        "jcomapi.c",
+        "jcparam.c",
+        "jcphuff.c",
+        "jctrans.c",
+        "jdapimin.c",
+        "jdarith.c",
+        "jdatadst.c",
+        "jdatadst-tj.c",
+        "jdatasrc.c",
+        "jdatasrc-tj.c",
+        "jdhuff.c",
+        "jdicc.c",
+        "jdinput.c",
+        "jdmarker.c",
+        "jdmaster.c",
+        "jdphuff.c",
+        "jdtrans.c",
+        "jerror.c",
+        "jfdctflt.c",
+        "jmemmgr.c",
+        "jmemnobs.c",
+        "jpeg_nbits.c",
+        "transupp.c",
+        "turbojpeg.c",
+    ]
+
+    thirdparty_sources_bit_dependent = [
+        "jcapistd.c",
+        "jccoefct.c",
+        "jccolor.c",
+        "jcdctmgr.c",
+        "jcmainct.c",
+        "jcprepct.c",
+        "jcsample.c",
+        "jdcoefct.c",
+        "jdcolor.c",
+        "jdapistd.c",
+        "jddctmgr.c",
+        "jdmainct.c",
+        "jdmerge.c",
+        "jdpostct.c",
+        "jdsample.c",
+        "jfdctfst.c",
+        "jfdctint.c",
+        "jidctflt.c",
+        "jidctfst.c",
+        "jidctint.c",
+        "jidctred.c",
+        "jutils.c",
+        "jquant1.c",
+        "jquant2.c",
+    ]
+
+    thirdparty_sources_by_bits = {
+        8: list(thirdparty_sources_bit_dependent),
+        12: list(thirdparty_sources_bit_dependent),
+    }
+
+    def source_paths(files):
+        return [thirdparty_dir + "/src/" + f for f in files]
+
+    env_jpg.Prepend(CPPEXTPATH=[thirdparty_dir + "/src"])
+
+    def add_bit_depth(bit_depth: int):
+        env_bit_depth = env_jpg.Clone()
+        env_bit_depth.disable_warnings()
+        env_bit_depth["OBJSUFFIX"] = f"_{bit_depth}{env_bit_depth['OBJSUFFIX']}"
+        env_bit_depth.Append(CPPDEFINES=[f"BITS_IN_JSAMPLE={bit_depth}"])
+        env_bit_depth.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_by_bits[bit_depth]))
+
+    add_bit_depth(8)
+    add_bit_depth(12)
+
+    env_thirdparty = env_jpg.Clone()
+    env_thirdparty.disable_warnings()
+    env_thirdparty.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_common))
+    env.modules_sources += thirdparty_obj
+
 
 # Godot source files
 
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index df4dbddedd36..fbb3cdf1f13c 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -278,6 +278,9 @@ def configure(env: "SConsEnvironment"):
     if not env["builtin_libwebp"]:
         env.ParseConfig("pkg-config libwebp --cflags --libs")
 
+    if not env["builtin_libjpeg_turbo"]:
+        env.ParseConfig("pkg-config libturbojpeg --cflags --libs")
+
     if not env["builtin_mbedtls"]:
         # mbedTLS only provides a pkgconfig file since 3.6.0, but we still support 2.28.x,
         # so fallback to manually specifying LIBS if it fails.