diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-04 08:43:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-04 08:43:49 +0400 |
commit | 1e762a29eec29c193f29f41444b243a7836dbdea (patch) | |
tree | c18fb4d6bc51a82251a339e9dbff750b1c262ecc | |
parent | 9dbe85c17ea0e3a9279780e51a9caea69ea056ed (diff) |
change bpy.app.build_options from frozen set to PyStructSequence_Field, mathes similar members of bpy.app and less error prone (typos won't fail silently).
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 2 | ||||
-rw-r--r-- | source/blender/python/SConscript | 12 | ||||
-rw-r--r-- | source/blender/python/intern/CMakeLists.txt | 20 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app_build_options.c | 221 |
4 files changed, 196 insertions, 59 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 4b5e2839cf1..58c433d3772 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -513,7 +513,7 @@ class USERPREF_PT_system(Panel): sub.active = system.use_weight_color_range sub.template_color_ramp(system, "weight_color_range", expand=True) - if 'INTERNATIONAL' in bpy.app.build_options: + if bpy.app.build_options.international: column.separator() column.prop(system, "use_international_fonts") if system.use_international_fonts: diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index 0a117f842e5..c28987eb156 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -130,6 +130,12 @@ if env['WITH_BF_TIFF']: if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') +if env['WITH_BF_OPENAL']: + defs.append('WITH_OPENAL') + +if env['WITH_BF_SDL']: + defs.append('WITH_SDL') + if env['WITH_BF_JACK']: defs.append('WITH_JACK') @@ -151,12 +157,12 @@ if env['WITH_BF_REMESH']: if env['WITH_BF_SMOKE']: defs.append('WITH_SMOKE') -if env['WITH_BF_OPENAL']: - defs.append('WITH_OPENAL') - if env['WITH_BF_COLLADA']: defs.append('WITH_COLLADA') +if env['WITH_BF_OIIO']: + defs.append('WITH_OCIO') + if env['WITH_BF_PLAYER']: defs.append('WITH_PLAYER') diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index b94869c6ca5..575185ece2d 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -185,12 +185,16 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -if(WITH_JACK) - add_definitions(-DWITH_JACK) +if(WITH_OPENAL) + add_definitions(-DWITH_OPENAL) endif() -if(WITH_LIBMV) - add_definitions(-DWITH_LIBMV) +if(WITH_SDL) + add_definitions(-DWITH_SDL) +endif() + +if(WITH_JACK) + add_definitions(-DWITH_JACK) endif() if(WITH_LIBMV) @@ -217,14 +221,14 @@ if(WITH_MOD_SMOKE) add_definitions(-DWITH_SMOKE) endif() -if(WITH_OPENAL) - add_definitions(-DWITH_OPENAL) -endif() - if(WITH_OPENCOLLADA) add_definitions(-DWITH_COLLADA) endif() +if(WITH_OPENCOLORIO) + add_definitions(-DWITH_OCIO) +endif() + if(WITH_PLAYER) add_definitions(-DWITH_PLAYER) endif() diff --git a/source/blender/python/intern/bpy_app_build_options.c b/source/blender/python/intern/bpy_app_build_options.c index 607613b592c..0036b377d3c 100644 --- a/source/blender/python/intern/bpy_app_build_options.c +++ b/source/blender/python/intern/bpy_app_build_options.c @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Bastien Montagne + * Contributor(s): Sergey Sharybin * * ***** END GPL LICENSE BLOCK ***** */ @@ -29,148 +29,275 @@ #include "bpy_app_build_options.h" -static PyObject *make_build_options(void) +static PyTypeObject BlenderAppBuildOptionsType; + +static PyStructSequence_Field app_builtopts_info_fields[] = { + /* names mostly follow CMake options, lowecases, after WITH_ */ + {(char *)"bullet", NULL}, + {(char *)"codec_avi", NULL}, + {(char *)"codec_ffmpeg", NULL}, + {(char *)"codec_quicktime", NULL}, + {(char *)"codec_sndfile", NULL}, + {(char *)"compositor", NULL}, + {(char *)"cycles", NULL}, + {(char *)"cycles_osl", NULL}, + {(char *)"gameengine", NULL}, + {(char *)"image_cineon", NULL}, + {(char *)"image_dds", NULL}, + {(char *)"image_frameserver", NULL}, + {(char *)"image_hdr", NULL}, + {(char *)"image_openexr", NULL}, + {(char *)"image_openjpeg", NULL}, + {(char *)"image_redcode", NULL}, + {(char *)"image_tiff", NULL}, + {(char *)"input_ndof", NULL}, + {(char *)"audaspace", NULL}, + {(char *)"international", NULL}, + {(char *)"openal", NULL}, + {(char *)"sdl", NULL}, + {(char *)"jack", NULL}, + {(char *)"libmv", NULL}, + {(char *)"mod_boolean", NULL}, + {(char *)"mod_fluid", NULL}, + {(char *)"mod_oceansim", NULL}, + {(char *)"mod_remesh", NULL}, + {(char *)"mod_smoke", NULL}, + {(char *)"collada", NULL}, + {(char *)"opencolorio", NULL}, + {(char *)"player", NULL}, + {NULL} +}; + + +static PyStructSequence_Desc app_builtopts_info_desc = { + (char *)"bpy.app.build_options", /* name */ + (char *)"This module contains information about FFmpeg blender is linked against", /* doc */ + app_builtopts_info_fields, /* fields */ + (sizeof(app_builtopts_info_fields) / sizeof(PyStructSequence_Field)) - 1 +}; + +static PyObject *make_builtopts_info(void) { - PyObject *build_options = PyFrozenSet_New(NULL); + PyObject *builtopts_info; + int pos = 0; -#define SetStrItem(str) \ - PySet_Add(build_options, PyUnicode_FromString(str)); + builtopts_info = PyStructSequence_New(&BlenderAppBuildOptionsType); + if (builtopts_info == NULL) { + return NULL; + } -#ifdef WITH_AUDASPACE - SetStrItem("AUDASPACE"); -#endif +#define SetObjIncref(item) \ + PyStructSequence_SET_ITEM(builtopts_info, pos++, (Py_IncRef(item), item)) #ifdef WITH_BULLET - SetStrItem("BULLET"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_AVI - SetStrItem("CODEC_AVI"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_FFMPEG - SetStrItem("CODEC_FFMPEG"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_QUICKTIME - SetStrItem("CODEC_QUICKTIME"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_SNDFILE - SetStrItem("CODEC_SNDFILE"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_COMPOSITOR - SetStrItem("COMPOSITOR"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_CYCLES - SetStrItem("CYCLES"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_CYCLES_OSL - SetStrItem("CYCLES_OSL"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_GAMEENGINE - SetStrItem("GAMEENGINE"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_CINEON - SetStrItem("IMAGE_CINEON"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_DDS - SetStrItem("IMAGE_DDS"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_FRAMESERVER - SetStrItem("IMAGE_FRAMESERVER"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_HDR - SetStrItem("IMAGE_HDR"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_OPENEXR - SetStrItem("IMAGE_OPENEXR"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_OPENJPEG - SetStrItem("IMAGE_OPENJPEG"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_REDCODE - SetStrItem("IMAGE_REDCODE"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_TIFF - SetStrItem("IMAGE_TIFF"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_INPUT_NDOF - SetStrItem("INPUT_NDOF"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); +#endif + +#ifdef WITH_AUDASPACE + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_INTERNATIONAL - SetStrItem("INTERNATIONAL"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); +#endif + +#ifdef WITH_OPENAL + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); +#endif + +#ifdef WITH_SDL + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_JACK - SetStrItem("JACK"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_LIBMV - SetStrItem("LIBMV"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_MOD_BOOLEAN - SetStrItem("MOD_BOOLEAN"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_MOD_FLUID - SetStrItem("MOD_FLUID"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_OCEANSIM - SetStrItem("MOD_OCEANSIM"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_MOD_REMESH - SetStrItem("MOD_REMESH"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_SMOKE - SetStrItem("MOD_SMOKE"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif -#ifdef WITH_OPENAL - SetStrItem("OPENAL"); +#ifdef WITH_COLLADA + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif -#ifdef WITH_COLLADA - SetStrItem("COLLADA"); +#ifdef WITH_OCIO + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif #ifdef WITH_PLAYER - SetStrItem("PLAYER"); + SetObjIncref(Py_True); +#else + SetObjIncref(Py_False); #endif -#undef SetStrItem +#undef SetObjIncref - if (PyErr_Occurred()) { - Py_CLEAR(build_options); - return NULL; - } - - return build_options; + return builtopts_info; } PyObject *BPY_app_build_options_struct(void) { PyObject *ret; - ret = make_build_options(); + PyStructSequence_InitType(&BlenderAppBuildOptionsType, &app_builtopts_info_desc); + + ret = make_builtopts_info(); + + /* prevent user from creating new instances */ + BlenderAppBuildOptionsType.tp_init = NULL; + BlenderAppBuildOptionsType.tp_new = NULL; + BlenderAppBuildOptionsType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */ return ret; } |