Blender V4.5
bpy_app_build_options.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <Python.h>
10
11#include "../generic/python_compat.hh" /* IWYU pragma: keep. */
12
13#include "BLI_utildefines.h"
14
16
17static PyTypeObject BlenderAppBuildOptionsType;
18
19static PyStructSequence_Field app_builtopts_info_fields[] = {
20 /* names mostly follow CMake options, lowercase, after `WITH_` */
21 {"bullet", nullptr},
22 {"codec_avi", nullptr},
23 {"codec_ffmpeg", nullptr},
24 {"codec_sndfile", nullptr},
25 {"compositor_cpu", nullptr},
26 {"cycles", nullptr},
27 {"cycles_osl", nullptr},
28 {"freestyle", nullptr},
29 {"image_cineon", nullptr},
30 {"image_dds", nullptr},
31 {"image_hdr", nullptr},
32 {"image_openexr", nullptr},
33 {"image_openjpeg", nullptr},
34 {"image_tiff", nullptr},
35 {"image_webp", nullptr},
36 {"input_ndof", nullptr},
37 {"audaspace", nullptr},
38 {"international", nullptr},
39 {"openal", nullptr},
40 {"opensubdiv", nullptr},
41 {"sdl", nullptr},
42 {"coreaudio", nullptr},
43 {"jack", nullptr},
44 {"pulseaudio", nullptr},
45 {"wasapi", nullptr},
46 {"libmv", nullptr},
47 {"mod_oceansim", nullptr},
48 {"mod_remesh", nullptr},
49 {"collada", nullptr},
50 {"io_wavefront_obj", nullptr},
51 {"io_ply", nullptr},
52 {"io_stl", nullptr},
53 {"io_fbx", nullptr},
54 {"io_gpencil", nullptr},
55 {"opencolorio", nullptr},
56 {"openmp", nullptr},
57 {"openvdb", nullptr},
58 {"alembic", nullptr},
59 {"usd", nullptr},
60 {"fluid", nullptr},
61 {"xr_openxr", nullptr},
62 {"potrace", nullptr},
63 {"pugixml", nullptr},
64 {"haru", nullptr},
65 {"experimental_features", nullptr},
66 /* Sentinel (this line prevents `clang-format` wrapping into columns). */
67 {nullptr},
68};
69
70static PyStructSequence_Desc app_builtopts_info_desc = {
71 /*name*/ "bpy.app.build_options",
72 /*doc*/ "This module contains information about options blender is built with",
74 /*n_in_sequence*/ ARRAY_SIZE(app_builtopts_info_fields) - 1,
75};
76
77static PyObject *make_builtopts_info()
78{
79 PyObject *builtopts_info;
80 int pos = 0;
81
82 builtopts_info = PyStructSequence_New(&BlenderAppBuildOptionsType);
83 if (builtopts_info == nullptr) {
84 return nullptr;
85 }
86
87#define SetObjIncref(item) \
88 PyStructSequence_SET_ITEM(builtopts_info, pos++, (Py_IncRef(item), item))
89
90#ifdef WITH_BULLET
91 SetObjIncref(Py_True);
92#else
93 SetObjIncref(Py_False);
94#endif
95
96 /* AVI */
97 SetObjIncref(Py_False);
98
99#ifdef WITH_FFMPEG
100 SetObjIncref(Py_True);
101#else
102 SetObjIncref(Py_False);
103#endif
104
105#ifdef WITH_SNDFILE
106 SetObjIncref(Py_True);
107#else
108 SetObjIncref(Py_False);
109#endif
110
111 /* Compositor. */
112 SetObjIncref(Py_True);
113
114#ifdef WITH_CYCLES
115 SetObjIncref(Py_True);
116#else
117 SetObjIncref(Py_False);
118#endif
119
120#ifdef WITH_CYCLES_OSL
121 SetObjIncref(Py_True);
122#else
123 SetObjIncref(Py_False);
124#endif
125
126#ifdef WITH_FREESTYLE
127 SetObjIncref(Py_True);
128#else
129 SetObjIncref(Py_False);
130#endif
131
132#ifdef WITH_IMAGE_CINEON
133 SetObjIncref(Py_True);
134#else
135 SetObjIncref(Py_False);
136#endif
137
138 /* DDS */
139 SetObjIncref(Py_True);
140
141 /* HDR */
142 SetObjIncref(Py_True);
143
144#ifdef WITH_IMAGE_OPENEXR
145 SetObjIncref(Py_True);
146#else
147 SetObjIncref(Py_False);
148#endif
149
150#ifdef WITH_IMAGE_OPENJPEG
151 SetObjIncref(Py_True);
152#else
153 SetObjIncref(Py_False);
154#endif
155
156 /* TIFF */
157 SetObjIncref(Py_True);
158
159#ifdef WITH_IMAGE_WEBP
160 SetObjIncref(Py_True);
161#else
162 SetObjIncref(Py_False);
163#endif
164
165#ifdef WITH_INPUT_NDOF
166 SetObjIncref(Py_True);
167#else
168 SetObjIncref(Py_False);
169#endif
170
171#ifdef WITH_AUDASPACE
172 SetObjIncref(Py_True);
173#else
174 SetObjIncref(Py_False);
175#endif
176
177#ifdef WITH_INTERNATIONAL
178 SetObjIncref(Py_True);
179#else
180 SetObjIncref(Py_False);
181#endif
182
183#ifdef WITH_OPENAL
184 SetObjIncref(Py_True);
185#else
186 SetObjIncref(Py_False);
187#endif
188
189#ifdef WITH_OPENSUBDIV
190 SetObjIncref(Py_True);
191#else
192 SetObjIncref(Py_False);
193#endif
194
195#ifdef WITH_SDL
196 SetObjIncref(Py_True);
197#else
198 SetObjIncref(Py_False);
199#endif
200
201#ifdef WITH_COREAUDIO
202 SetObjIncref(Py_True);
203#else
204 SetObjIncref(Py_False);
205#endif
206
207#ifdef WITH_JACK
208 SetObjIncref(Py_True);
209#else
210 SetObjIncref(Py_False);
211#endif
212
213#ifdef WITH_PULSEAUDIO
214 SetObjIncref(Py_True);
215#else
216 SetObjIncref(Py_False);
217#endif
218
219#ifdef WITH_WASAPI
220 SetObjIncref(Py_True);
221#else
222 SetObjIncref(Py_False);
223#endif
224
225#ifdef WITH_LIBMV
226 SetObjIncref(Py_True);
227#else
228 SetObjIncref(Py_False);
229#endif
230
231#ifdef WITH_OCEANSIM
232 SetObjIncref(Py_True);
233#else
234 SetObjIncref(Py_False);
235#endif
236
237#ifdef WITH_MOD_REMESH
238 SetObjIncref(Py_True);
239#else
240 SetObjIncref(Py_False);
241#endif
242
243#ifdef WITH_COLLADA
244 SetObjIncref(Py_True);
245#else
246 SetObjIncref(Py_False);
247#endif
248
249#ifdef WITH_IO_WAVEFRONT_OBJ
250 SetObjIncref(Py_True);
251#else
252 SetObjIncref(Py_False);
253#endif
254
255#ifdef WITH_IO_PLY
256 SetObjIncref(Py_True);
257#else
258 SetObjIncref(Py_False);
259#endif
260
261#ifdef WITH_IO_STL
262 SetObjIncref(Py_True);
263#else
264 SetObjIncref(Py_False);
265#endif
266
267#ifdef WITH_IO_FBX
268 SetObjIncref(Py_True);
269#else
270 SetObjIncref(Py_False);
271#endif
272
273#ifdef WITH_IO_GREASE_PENCIL
274 SetObjIncref(Py_True);
275#else
276 SetObjIncref(Py_False);
277#endif
278
279#ifdef WITH_OPENCOLORIO
280 SetObjIncref(Py_True);
281#else
282 SetObjIncref(Py_False);
283#endif
284
285#ifdef _OPENMP
286 SetObjIncref(Py_True);
287#else
288 SetObjIncref(Py_False);
289#endif
290
291#ifdef WITH_OPENVDB
292 SetObjIncref(Py_True);
293#else
294 SetObjIncref(Py_False);
295#endif
296
297#ifdef WITH_ALEMBIC
298 SetObjIncref(Py_True);
299#else
300 SetObjIncref(Py_False);
301#endif
302
303#ifdef WITH_USD
304 SetObjIncref(Py_True);
305#else
306 SetObjIncref(Py_False);
307#endif
308
309#ifdef WITH_FLUID
310 SetObjIncref(Py_True);
311#else
312 SetObjIncref(Py_False);
313#endif
314
315#ifdef WITH_XR_OPENXR
316 SetObjIncref(Py_True);
317#else
318 SetObjIncref(Py_False);
319#endif
320
321#ifdef WITH_POTRACE
322 SetObjIncref(Py_True);
323#else
324 SetObjIncref(Py_False);
325#endif
326
327#ifdef WITH_PUGIXML
328 SetObjIncref(Py_True);
329#else
330 SetObjIncref(Py_False);
331#endif
332
333#ifdef WITH_HARU
334 SetObjIncref(Py_True);
335#else
336 SetObjIncref(Py_False);
337#endif
338
339#ifdef WITH_EXPERIMENTAL_FEATURES
340 SetObjIncref(Py_True);
341#else
342 SetObjIncref(Py_False);
343#endif
344
345#undef SetObjIncref
346
347 return builtopts_info;
348}
349
351{
352 PyObject *ret;
353
354 PyStructSequence_InitType(&BlenderAppBuildOptionsType, &app_builtopts_info_desc);
355
357
358 /* prevent user from creating new instances */
359 BlenderAppBuildOptionsType.tp_init = nullptr;
360 BlenderAppBuildOptionsType.tp_new = nullptr;
361 /* Without this we can't do `set(sys.modules)` #29635. */
362 BlenderAppBuildOptionsType.tp_hash = (hashfunc)Py_HashPointer;
363
364 return ret;
365}
#define ARRAY_SIZE(arr)
static PyObject * make_builtopts_info()
PyObject * BPY_app_build_options_struct()
#define SetObjIncref(item)
static PyTypeObject BlenderAppBuildOptionsType
static PyStructSequence_Field app_builtopts_info_fields[]
static PyStructSequence_Desc app_builtopts_info_desc
uint pos
header-only compatibility defines.
#define Py_HashPointer
return ret