Blender V5.0
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 {"io_wavefront_obj", nullptr},
50 {"io_ply", nullptr},
51 {"io_stl", nullptr},
52 {"io_fbx", nullptr},
53 {"io_gpencil", nullptr},
54 {"opencolorio", nullptr},
55 {"openmp", nullptr},
56 {"openvdb", nullptr},
57 {"alembic", nullptr},
58 {"usd", nullptr},
59 {"fluid", nullptr},
60 {"xr_openxr", nullptr},
61 {"potrace", nullptr},
62 {"pugixml", nullptr},
63 {"haru", nullptr},
64 {"experimental_features", nullptr},
65 /* Sentinel (this line prevents `clang-format` wrapping into columns). */
66 {nullptr},
67};
68
69static PyStructSequence_Desc app_builtopts_info_desc = {
70 /*name*/ "bpy.app.build_options",
71 /*doc*/ "This module contains information about options blender is built with",
73 /*n_in_sequence*/ ARRAY_SIZE(app_builtopts_info_fields) - 1,
74};
75
76static PyObject *make_builtopts_info()
77{
78 PyObject *builtopts_info;
79 int pos = 0;
80
81 builtopts_info = PyStructSequence_New(&BlenderAppBuildOptionsType);
82 if (builtopts_info == nullptr) {
83 return nullptr;
84 }
85
86#define SetObjIncref(item) \
87 PyStructSequence_SET_ITEM(builtopts_info, pos++, (Py_IncRef(item), item))
88
89#ifdef WITH_BULLET
90 SetObjIncref(Py_True);
91#else
92 SetObjIncref(Py_False);
93#endif
94
95 /* AVI */
96 SetObjIncref(Py_False);
97
98#ifdef WITH_FFMPEG
99 SetObjIncref(Py_True);
100#else
101 SetObjIncref(Py_False);
102#endif
103
104#ifdef WITH_SNDFILE
105 SetObjIncref(Py_True);
106#else
107 SetObjIncref(Py_False);
108#endif
109
110 /* Compositor. */
111 SetObjIncref(Py_True);
112
113#ifdef WITH_CYCLES
114 SetObjIncref(Py_True);
115#else
116 SetObjIncref(Py_False);
117#endif
118
119#ifdef WITH_CYCLES_OSL
120 SetObjIncref(Py_True);
121#else
122 SetObjIncref(Py_False);
123#endif
124
125#ifdef WITH_FREESTYLE
126 SetObjIncref(Py_True);
127#else
128 SetObjIncref(Py_False);
129#endif
130
131#ifdef WITH_IMAGE_CINEON
132 SetObjIncref(Py_True);
133#else
134 SetObjIncref(Py_False);
135#endif
136
137 /* DDS */
138 SetObjIncref(Py_True);
139
140 /* HDR */
141 SetObjIncref(Py_True);
142
143#ifdef WITH_IMAGE_OPENEXR
144 SetObjIncref(Py_True);
145#else
146 SetObjIncref(Py_False);
147#endif
148
149#ifdef WITH_IMAGE_OPENJPEG
150 SetObjIncref(Py_True);
151#else
152 SetObjIncref(Py_False);
153#endif
154
155 /* TIFF */
156 SetObjIncref(Py_True);
157
158#ifdef WITH_IMAGE_WEBP
159 SetObjIncref(Py_True);
160#else
161 SetObjIncref(Py_False);
162#endif
163
164#ifdef WITH_INPUT_NDOF
165 SetObjIncref(Py_True);
166#else
167 SetObjIncref(Py_False);
168#endif
169
170#ifdef WITH_AUDASPACE
171 SetObjIncref(Py_True);
172#else
173 SetObjIncref(Py_False);
174#endif
175
176#ifdef WITH_INTERNATIONAL
177 SetObjIncref(Py_True);
178#else
179 SetObjIncref(Py_False);
180#endif
181
182#ifdef WITH_OPENAL
183 SetObjIncref(Py_True);
184#else
185 SetObjIncref(Py_False);
186#endif
187
188#ifdef WITH_OPENSUBDIV
189 SetObjIncref(Py_True);
190#else
191 SetObjIncref(Py_False);
192#endif
193
194#ifdef WITH_SDL
195 SetObjIncref(Py_True);
196#else
197 SetObjIncref(Py_False);
198#endif
199
200#ifdef WITH_COREAUDIO
201 SetObjIncref(Py_True);
202#else
203 SetObjIncref(Py_False);
204#endif
205
206#ifdef WITH_JACK
207 SetObjIncref(Py_True);
208#else
209 SetObjIncref(Py_False);
210#endif
211
212#ifdef WITH_PULSEAUDIO
213 SetObjIncref(Py_True);
214#else
215 SetObjIncref(Py_False);
216#endif
217
218#ifdef WITH_WASAPI
219 SetObjIncref(Py_True);
220#else
221 SetObjIncref(Py_False);
222#endif
223
224#ifdef WITH_LIBMV
225 SetObjIncref(Py_True);
226#else
227 SetObjIncref(Py_False);
228#endif
229
230#ifdef WITH_OCEANSIM
231 SetObjIncref(Py_True);
232#else
233 SetObjIncref(Py_False);
234#endif
235
236#ifdef WITH_MOD_REMESH
237 SetObjIncref(Py_True);
238#else
239 SetObjIncref(Py_False);
240#endif
241
242#ifdef WITH_IO_WAVEFRONT_OBJ
243 SetObjIncref(Py_True);
244#else
245 SetObjIncref(Py_False);
246#endif
247
248#ifdef WITH_IO_PLY
249 SetObjIncref(Py_True);
250#else
251 SetObjIncref(Py_False);
252#endif
253
254#ifdef WITH_IO_STL
255 SetObjIncref(Py_True);
256#else
257 SetObjIncref(Py_False);
258#endif
259
260#ifdef WITH_IO_FBX
261 SetObjIncref(Py_True);
262#else
263 SetObjIncref(Py_False);
264#endif
265
266#ifdef WITH_IO_GREASE_PENCIL
267 SetObjIncref(Py_True);
268#else
269 SetObjIncref(Py_False);
270#endif
271
272#ifdef WITH_OPENCOLORIO
273 SetObjIncref(Py_True);
274#else
275 SetObjIncref(Py_False);
276#endif
277
278#ifdef _OPENMP
279 SetObjIncref(Py_True);
280#else
281 SetObjIncref(Py_False);
282#endif
283
284#ifdef WITH_OPENVDB
285 SetObjIncref(Py_True);
286#else
287 SetObjIncref(Py_False);
288#endif
289
290#ifdef WITH_ALEMBIC
291 SetObjIncref(Py_True);
292#else
293 SetObjIncref(Py_False);
294#endif
295
296#ifdef WITH_USD
297 SetObjIncref(Py_True);
298#else
299 SetObjIncref(Py_False);
300#endif
301
302#ifdef WITH_FLUID
303 SetObjIncref(Py_True);
304#else
305 SetObjIncref(Py_False);
306#endif
307
308#ifdef WITH_XR_OPENXR
309 SetObjIncref(Py_True);
310#else
311 SetObjIncref(Py_False);
312#endif
313
314#ifdef WITH_POTRACE
315 SetObjIncref(Py_True);
316#else
317 SetObjIncref(Py_False);
318#endif
319
320#ifdef WITH_PUGIXML
321 SetObjIncref(Py_True);
322#else
323 SetObjIncref(Py_False);
324#endif
325
326#ifdef WITH_HARU
327 SetObjIncref(Py_True);
328#else
329 SetObjIncref(Py_False);
330#endif
331
332#ifdef WITH_EXPERIMENTAL_FEATURES
333 SetObjIncref(Py_True);
334#else
335 SetObjIncref(Py_False);
336#endif
337
338#undef SetObjIncref
339
340 return builtopts_info;
341}
342
344{
345 PyObject *ret;
346
347 PyStructSequence_InitType(&BlenderAppBuildOptionsType, &app_builtopts_info_desc);
348
350
351 /* prevent user from creating new instances */
352 BlenderAppBuildOptionsType.tp_init = nullptr;
353 BlenderAppBuildOptionsType.tp_new = nullptr;
354 /* Without this we can't do `set(sys.modules)` #29635. */
355 BlenderAppBuildOptionsType.tp_hash = (hashfunc)Py_HashPointer;
356
357 return ret;
358}
#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