Blender V5.3
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.hh"
14
16
17namespace blender {
18
19static PyTypeObject BlenderAppBuildOptionsType;
20
21static PyStructSequence_Field app_builtopts_info_fields[] = {
22 /* names mostly follow CMake options, lowercase, after `WITH_` */
23 {"bullet", nullptr},
24 {"codec_avi", nullptr},
25 {"codec_ffmpeg", nullptr},
26 {"codec_sndfile", nullptr},
27 {"compositor_cpu", nullptr},
28 {"cycles", nullptr},
29 {"cycles_osl", nullptr},
30 {"freestyle", nullptr},
31 {"image_cineon", nullptr},
32 {"image_dds", nullptr},
33 {"image_hdr", nullptr},
34 {"image_openexr", nullptr},
35 {"image_openjpeg", nullptr},
36 {"image_tiff", nullptr},
37 {"image_webp", nullptr},
38 {"input_ndof", nullptr},
39 {"audaspace", nullptr},
40 {"international", nullptr},
41 {"openal", nullptr},
42 {"opensubdiv", nullptr},
43 {"sdl", nullptr},
44 {"coreaudio", nullptr},
45 {"jack", nullptr},
46 {"pulseaudio", nullptr},
47 {"wasapi", nullptr},
48 {"libmv", nullptr},
49 {"mod_oceansim", nullptr},
50 {"mod_remesh", nullptr},
51 {"io_wavefront_obj", nullptr},
52 {"io_ply", nullptr},
53 {"io_spz", nullptr},
54 {"io_stl", nullptr},
55 {"io_fbx", nullptr},
56 {"io_gpencil", nullptr},
57 {"opencolorio", nullptr},
58 {"openmp", nullptr},
59 {"openvdb", nullptr},
60 {"alembic", nullptr},
61 {"usd", nullptr},
62 {"fluid", nullptr},
63 {"xr_openxr", nullptr},
64 {"opentimelineio", nullptr},
65 {"potrace", nullptr},
66 {"pugixml", nullptr},
67 {"haru", nullptr},
68 {"experimental_features", nullptr},
69 /* Sentinel (this line prevents `clang-format` wrapping into columns). */
70 {nullptr},
71};
72
73static PyStructSequence_Desc app_builtopts_info_desc = {
74 /*name*/ "bpy.app.build_options",
75 /*doc*/ "This module contains information about options blender is built with",
77 /*n_in_sequence*/ ARRAY_SIZE(app_builtopts_info_fields) - 1,
78};
79
80static PyObject *make_builtopts_info()
81{
82 PyObject *builtopts_info;
83 int pos = 0;
84
85 builtopts_info = PyStructSequence_New(&BlenderAppBuildOptionsType);
86 if (builtopts_info == nullptr) {
87 return nullptr;
88 }
89
90#define SetObjIncref(item) \
91 PyStructSequence_SET_ITEM(builtopts_info, pos++, (Py_IncRef(item), item))
92
93#ifdef WITH_BULLET
94 SetObjIncref(Py_True);
95#else
96 SetObjIncref(Py_False);
97#endif
98
99 /* AVI */
100 SetObjIncref(Py_False);
101
102#ifdef WITH_FFMPEG
103 SetObjIncref(Py_True);
104#else
105 SetObjIncref(Py_False);
106#endif
107
108#ifdef WITH_SNDFILE
109 SetObjIncref(Py_True);
110#else
111 SetObjIncref(Py_False);
112#endif
113
114 /* Compositor. */
115 SetObjIncref(Py_True);
116
117#ifdef WITH_CYCLES
118 SetObjIncref(Py_True);
119#else
120 SetObjIncref(Py_False);
121#endif
122
123#ifdef WITH_CYCLES_OSL
124 SetObjIncref(Py_True);
125#else
126 SetObjIncref(Py_False);
127#endif
128
129#ifdef WITH_FREESTYLE
130 SetObjIncref(Py_True);
131#else
132 SetObjIncref(Py_False);
133#endif
134
135#ifdef WITH_IMAGE_CINEON
136 SetObjIncref(Py_True);
137#else
138 SetObjIncref(Py_False);
139#endif
140
141 /* DDS */
142 SetObjIncref(Py_True);
143
144 /* HDR */
145 SetObjIncref(Py_True);
146
147 /* OpenEXR */
148 SetObjIncref(Py_True);
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_IO_WAVEFRONT_OBJ
244 SetObjIncref(Py_True);
245#else
246 SetObjIncref(Py_False);
247#endif
248
249#ifdef WITH_IO_PLY
250 SetObjIncref(Py_True);
251#else
252 SetObjIncref(Py_False);
253#endif
254
255#ifdef WITH_IO_SPZ
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 /* OpenColorIO */
280 SetObjIncref(Py_True);
281
282#ifdef _OPENMP
283 SetObjIncref(Py_True);
284#else
285 SetObjIncref(Py_False);
286#endif
287
288#ifdef WITH_OPENVDB
289 SetObjIncref(Py_True);
290#else
291 SetObjIncref(Py_False);
292#endif
293
294#ifdef WITH_ALEMBIC
295 SetObjIncref(Py_True);
296#else
297 SetObjIncref(Py_False);
298#endif
299
300#ifdef WITH_USD
301 SetObjIncref(Py_True);
302#else
303 SetObjIncref(Py_False);
304#endif
305
306#ifdef WITH_FLUID
307 SetObjIncref(Py_True);
308#else
309 SetObjIncref(Py_False);
310#endif
311
312#ifdef WITH_XR_OPENXR
313 SetObjIncref(Py_True);
314#else
315 SetObjIncref(Py_False);
316#endif
317
318#ifdef WITH_OPENTIMELINEIO
319 SetObjIncref(Py_True);
320#else
321 SetObjIncref(Py_False);
322#endif
323
324#ifdef WITH_POTRACE
325 SetObjIncref(Py_True);
326#else
327 SetObjIncref(Py_False);
328#endif
329
330#ifdef WITH_PUGIXML
331 SetObjIncref(Py_True);
332#else
333 SetObjIncref(Py_False);
334#endif
335
336#ifdef WITH_HARU
337 SetObjIncref(Py_True);
338#else
339 SetObjIncref(Py_False);
340#endif
341
342#ifdef WITH_EXPERIMENTAL_FEATURES
343 SetObjIncref(Py_True);
344#else
345 SetObjIncref(Py_False);
346#endif
347
348#undef SetObjIncref
349
350 return builtopts_info;
351}
352
354{
355 PyObject *ret;
356
357 PyStructSequence_InitType(&BlenderAppBuildOptionsType, &app_builtopts_info_desc);
358
360
361 /* prevent user from creating new instances */
362 BlenderAppBuildOptionsType.tp_init = nullptr;
363 BlenderAppBuildOptionsType.tp_new = nullptr;
364 /* Without this we can't do `set(sys.modules)` #29635. */
365 BlenderAppBuildOptionsType.tp_hash = reinterpret_cast<hashfunc>(Py_HashPointer);
366
367 return ret;
368}
369
370} // namespace blender
#define SetObjIncref(item)
BMesh Iterators.
static PyObject * make_builtopts_info()
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
static PyStructSequence_Field app_builtopts_info_fields[]
static PyTypeObject BlenderAppBuildOptionsType
PyObject * BPY_app_build_options_struct()
static PyStructSequence_Desc app_builtopts_info_desc
header-only compatibility defines.
#define Py_HashPointer