Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
[blender.git] / source / blender / python / intern / bpy_app_build_options.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Sergey Sharybin
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/python/intern/bpy_app_build_options.c
24  *  \ingroup pythonintern
25  */
26
27 #include <Python.h>
28 #include "BLI_utildefines.h"
29
30 #include "bpy_app_build_options.h"
31
32 static PyTypeObject BlenderAppBuildOptionsType;
33
34 static PyStructSequence_Field app_builtopts_info_fields[] = {
35         /* names mostly follow CMake options, lowercase, after WITH_ */
36         {(char *)"bullet", NULL},
37         {(char *)"codec_avi", NULL},
38         {(char *)"codec_ffmpeg", NULL},
39         {(char *)"codec_quicktime", NULL},
40         {(char *)"codec_sndfile", NULL},
41         {(char *)"compositor", NULL},
42         {(char *)"cycles", NULL},
43         {(char *)"cycles_osl", NULL},
44         {(char *)"gameengine", NULL},
45         {(char *)"image_cineon", NULL},
46         {(char *)"image_dds", NULL},
47         {(char *)"image_frameserver", NULL},
48         {(char *)"image_hdr", NULL},
49         {(char *)"image_openexr", NULL},
50         {(char *)"image_openjpeg", NULL},
51         {(char *)"image_redcode", NULL},
52         {(char *)"image_tiff", NULL},
53         {(char *)"input_ndof", NULL},
54         {(char *)"audaspace", NULL},
55         {(char *)"international", NULL},
56         {(char *)"openal", NULL},
57         {(char *)"sdl", NULL},
58         {(char *)"jack", NULL},
59         {(char *)"libmv", NULL},
60         {(char *)"mod_boolean", NULL},
61         {(char *)"mod_fluid", NULL},
62         {(char *)"mod_oceansim", NULL},
63         {(char *)"mod_remesh", NULL},
64         {(char *)"mod_smoke", NULL},
65         {(char *)"collada", NULL},
66         {(char *)"opencolorio", NULL},
67         {(char *)"player", NULL},
68         {NULL}
69 };
70
71
72 static PyStructSequence_Desc app_builtopts_info_desc = {
73         (char *)"bpy.app.build_options",     /* name */
74         (char *)"This module contains information about options blender is built with",    /* doc */
75         app_builtopts_info_fields,    /* fields */
76         (sizeof(app_builtopts_info_fields) / sizeof(PyStructSequence_Field)) - 1
77 };
78
79 static PyObject *make_builtopts_info(void)
80 {
81         PyObject *builtopts_info;
82         int pos = 0;
83
84         builtopts_info = PyStructSequence_New(&BlenderAppBuildOptionsType);
85         if (builtopts_info == NULL) {
86                 return NULL;
87         }
88
89 #define SetObjIncref(item) \
90         PyStructSequence_SET_ITEM(builtopts_info, pos++, (Py_IncRef(item), item))
91
92 #ifdef WITH_BULLET
93         SetObjIncref(Py_True);
94 #else
95         SetObjIncref(Py_False);
96 #endif
97
98 #ifdef WITH_AVI
99         SetObjIncref(Py_True);
100 #else
101         SetObjIncref(Py_False);
102 #endif
103
104 #ifdef WITH_FFMPEG
105         SetObjIncref(Py_True);
106 #else
107         SetObjIncref(Py_False);
108 #endif
109
110 #ifdef WITH_QUICKTIME
111         SetObjIncref(Py_True);
112 #else
113         SetObjIncref(Py_False);
114 #endif
115
116 #ifdef WITH_SNDFILE
117         SetObjIncref(Py_True);
118 #else
119         SetObjIncref(Py_False);
120 #endif
121
122 #ifdef WITH_COMPOSITOR
123         SetObjIncref(Py_True);
124 #else
125         SetObjIncref(Py_False);
126 #endif
127
128 #ifdef WITH_CYCLES
129         SetObjIncref(Py_True);
130 #else
131         SetObjIncref(Py_False);
132 #endif
133
134 #ifdef WITH_CYCLES_OSL
135         SetObjIncref(Py_True);
136 #else
137         SetObjIncref(Py_False);
138 #endif
139
140 #ifdef WITH_GAMEENGINE
141         SetObjIncref(Py_True);
142 #else
143         SetObjIncref(Py_False);
144 #endif
145
146 #ifdef WITH_CINEON
147         SetObjIncref(Py_True);
148 #else
149         SetObjIncref(Py_False);
150 #endif
151
152 #ifdef WITH_DDS
153         SetObjIncref(Py_True);
154 #else
155         SetObjIncref(Py_False);
156 #endif
157
158 #ifdef WITH_FRAMESERVER
159         SetObjIncref(Py_True);
160 #else
161         SetObjIncref(Py_False);
162 #endif
163
164 #ifdef WITH_HDR
165         SetObjIncref(Py_True);
166 #else
167         SetObjIncref(Py_False);
168 #endif
169
170 #ifdef WITH_OPENEXR
171         SetObjIncref(Py_True);
172 #else
173         SetObjIncref(Py_False);
174 #endif
175
176 #ifdef WITH_OPENJPEG
177         SetObjIncref(Py_True);
178 #else
179         SetObjIncref(Py_False);
180 #endif
181
182 #ifdef WITH_REDCODE
183         SetObjIncref(Py_True);
184 #else
185         SetObjIncref(Py_False);
186 #endif
187
188 #ifdef WITH_TIFF
189         SetObjIncref(Py_True);
190 #else
191         SetObjIncref(Py_False);
192 #endif
193
194 #ifdef WITH_INPUT_NDOF
195         SetObjIncref(Py_True);
196 #else
197         SetObjIncref(Py_False);
198 #endif
199
200 #ifdef WITH_AUDASPACE
201         SetObjIncref(Py_True);
202 #else
203         SetObjIncref(Py_False);
204 #endif
205
206 #ifdef WITH_INTERNATIONAL
207         SetObjIncref(Py_True);
208 #else
209         SetObjIncref(Py_False);
210 #endif
211
212 #ifdef WITH_OPENAL
213         SetObjIncref(Py_True);
214 #else
215         SetObjIncref(Py_False);
216 #endif
217
218 #ifdef WITH_SDL
219         SetObjIncref(Py_True);
220 #else
221         SetObjIncref(Py_False);
222 #endif
223
224 #ifdef WITH_JACK
225         SetObjIncref(Py_True);
226 #else
227         SetObjIncref(Py_False);
228 #endif
229
230 #ifdef WITH_LIBMV
231         SetObjIncref(Py_True);
232 #else
233         SetObjIncref(Py_False);
234 #endif
235
236 #ifdef WITH_MOD_BOOLEAN
237         SetObjIncref(Py_True);
238 #else
239         SetObjIncref(Py_False);
240 #endif
241
242 #ifdef WITH_MOD_FLUID
243         SetObjIncref(Py_True);
244 #else
245         SetObjIncref(Py_False);
246 #endif
247
248 #ifdef WITH_OCEANSIM
249         SetObjIncref(Py_True);
250 #else
251         SetObjIncref(Py_False);
252 #endif
253
254 #ifdef WITH_MOD_REMESH
255         SetObjIncref(Py_True);
256 #else
257         SetObjIncref(Py_False);
258 #endif
259
260 #ifdef WITH_SMOKE
261         SetObjIncref(Py_True);
262 #else
263         SetObjIncref(Py_False);
264 #endif
265
266 #ifdef WITH_COLLADA
267         SetObjIncref(Py_True);
268 #else
269         SetObjIncref(Py_False);
270 #endif
271
272 #ifdef WITH_OCIO
273         SetObjIncref(Py_True);
274 #else
275         SetObjIncref(Py_False);
276 #endif
277
278 #ifdef WITH_PLAYER
279         SetObjIncref(Py_True);
280 #else
281         SetObjIncref(Py_False);
282 #endif
283
284 #undef SetObjIncref
285
286         return builtopts_info;
287 }
288
289 PyObject *BPY_app_build_options_struct(void)
290 {
291         PyObject *ret;
292
293         PyStructSequence_InitType(&BlenderAppBuildOptionsType, &app_builtopts_info_desc);
294
295         ret = make_builtopts_info();
296
297         /* prevent user from creating new instances */
298         BlenderAppBuildOptionsType.tp_init = NULL;
299         BlenderAppBuildOptionsType.tp_new = NULL;
300         BlenderAppBuildOptionsType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */
301
302         return ret;
303 }