[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35327] trunk/blender: Py/RNA API: WITH_PYTHON_SAFETY
Campbell Barton
ideasman42 at gmail.com
Thu Mar 3 13:00:38 CET 2011
Revision: 35327
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35327
Author: campbellbarton
Date: 2011-03-03 12:00:35 +0000 (Thu, 03 Mar 2011)
Log Message:
-----------
Py/RNA API: WITH_PYTHON_SAFETY
compile time option which enables extra safety checks.
since this is noticeably slower I rather not enable by default yet.
Modified Paths:
--------------
trunk/blender/CMakeLists.txt
trunk/blender/build_files/scons/tools/btools.py
trunk/blender/source/blender/python/SConscript
trunk/blender/source/blender/python/intern/CMakeLists.txt
trunk/blender/source/blender/python/intern/bpy_rna.h
Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt 2011-03-03 11:22:54 UTC (rev 35326)
+++ trunk/blender/CMakeLists.txt 2011-03-03 12:00:35 UTC (rev 35327)
@@ -69,6 +69,7 @@
# Blender internal features
option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
option(WITH_PYTHON "Enable Embedded Python API" ON)
+option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency)." OFF)
option(WITH_PYTHON_MODULE "Enable building as a python module (experemental)" OFF)
option(WITH_BUILDINFO "Include extra build details" ON)
option(WITH_IK_ITASC "Enable ITASC IK solver" ON)
Modified: trunk/blender/build_files/scons/tools/btools.py
===================================================================
--- trunk/blender/build_files/scons/tools/btools.py 2011-03-03 11:22:54 UTC (rev 35326)
+++ trunk/blender/build_files/scons/tools/btools.py 2011-03-03 12:00:35 UTC (rev 35327)
@@ -72,7 +72,7 @@
def validate_arguments(args, bc):
opts_list = [
- 'WITH_BF_PYTHON', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'WITH_BF_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL',
+ 'WITH_BF_PYTHON', 'WITH_BF_PYTHON_SAFETY', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'WITH_BF_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL',
'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH', 'WITH_BF_STATICOPENAL', 'BF_OPENAL_LIB_STATIC',
'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH',
'BF_LIBSAMPLERATE', 'BF_LIBSAMPLERATE_INC', 'BF_LIBSAMPLERATE_LIB', 'BF_LIBSAMPLERATE_LIBPATH', 'WITH_BF_STATICLIBSAMPLERATE', 'BF_LIBSAMPLERATE_LIB_STATIC',
@@ -211,6 +211,7 @@
localopts.AddVariables(
('LCGDIR', 'location of cvs lib dir'),
(BoolVariable('WITH_BF_PYTHON', 'Compile with python', True)),
+ (BoolVariable('WITH_BF_PYTHON_SAFETY', 'Internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency)', False)),
('BF_PYTHON', 'base path for python', ''),
('BF_PYTHON_VERSION', 'Python version to use', ''),
('BF_PYTHON_INC', 'include path for Python headers', ''),
Modified: trunk/blender/source/blender/python/SConscript
===================================================================
--- trunk/blender/source/blender/python/SConscript 2011-03-03 11:22:54 UTC (rev 35326)
+++ trunk/blender/source/blender/python/SConscript 2011-03-03 12:00:35 UTC (rev 35327)
@@ -1,24 +1,37 @@
#!/usr/bin/python
+
+# TODO, split into 2 files.
+
Import ('env')
-sources = env.Glob('intern/*.c')
-
incs = '. ../editors/include ../makesdna ../makesrna ../blenlib ../blenkernel ../nodes'
incs += ' ../imbuf ../blenloader ../render/extern/include ../windowmanager'
incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include'
incs += ' #intern/audaspace/intern ' + env['BF_PYTHON_INC']
+is_debug = (env['OURPLATFORM'] in ('win32-mingw', 'win32-vc','win64-vc') and env['BF_DEBUG'])
+
+# generic
defs = []
-if env['BF_BUILDINFO']:
- defs.append('BUILD_DATE')
+if is_debug:
+ defs.append('_DEBUG')
-if env['OURPLATFORM'] in ('win32-mingw', 'win32-vc','win64-vc') and env['BF_DEBUG']:
+sources = env.Glob('generic/*.c')
+env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [362,165]) # ketsji is 360
+
+
+# bpy
+defs = []
+
+if is_debug:
defs.append('_DEBUG')
-env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [361,160])
+if env['WITH_BF_PYTHON_SAFETY']:
+ defs.append('WITH_PYTHON_SAFETY')
+if env['BF_BUILDINFO']:
+ defs.append('BUILD_DATE')
-# generic
-sources = env.Glob('generic/*.c')
-env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [362,165]) # ketsji is 360
+sources = env.Glob('intern/*.c')
+env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [361,160])
Modified: trunk/blender/source/blender/python/intern/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/intern/CMakeLists.txt 2011-03-03 11:22:54 UTC (rev 35326)
+++ trunk/blender/source/blender/python/intern/CMakeLists.txt 2011-03-03 12:00:35 UTC (rev 35327)
@@ -76,4 +76,8 @@
add_definitions(-DWITH_PYTHON_MODULE)
endif()
+if(WITH_PYTHON_SAFETY)
+ add_definitions(-DWITH_PYTHON_SAFETY)
+endif()
+
blender_add_lib(bf_python "${SRC}" "${INC}")
Modified: trunk/blender/source/blender/python/intern/bpy_rna.h
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.h 2011-03-03 11:22:54 UTC (rev 35326)
+++ trunk/blender/source/blender/python/intern/bpy_rna.h 2011-03-03 12:00:35 UTC (rev 35327)
@@ -29,23 +29,31 @@
#ifndef BPY_RNA_H
#define BPY_RNA_H
+/* --- bpy build options --- */
+#ifdef WITH_PYTHON_SAFETY
-/* --- bpy build options --- */
/* play it safe and keep optional for now, need to test further now this affects looping on 10000's of verts for eg. */
-// #define USE_WEAKREFS
+#define USE_WEAKREFS
/* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */
-//#define USE_PYRNA_INVALIDATE_GC
+/* #define USE_PYRNA_INVALIDATE_GC */
/* different method */
-//#define USE_PYRNA_INVALIDATE_WEAKREF
+#define USE_PYRNA_INVALIDATE_WEAKREF
/* support for inter references, currently only needed for corner case */
-// #define USE_PYRNA_STRUCT_REFERENCE
+#define USE_PYRNA_STRUCT_REFERENCE
/* use real collection iterators rather then faking with a list */
#define USE_PYRNA_ITER
+#else /* WITH_PYTHON_SAFETY */
+
+ /* default, no defines! */
+
+#endif /* !WITH_PYTHON_SAFETY */
+
+
/* sanity checks on above defs */
#if defined(USE_PYRNA_INVALIDATE_WEAKREF) && !defined(USE_WEAKREFS)
#define USE_WEAKREFS
More information about the Bf-blender-cvs
mailing list