Option to use jemalloc when building with scons under linux.
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 13 May 2011 12:08:34 +0000 (12:08 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 13 May 2011 12:08:34 +0000 (12:08 +0000)
Disabled by default.

build_files/scons/config/linux2-config.py
build_files/scons/tools/Blender.py
build_files/scons/tools/btools.py

index d4e97c78c3843d09f9aef4791425adb58f2895aa..bc2917055fb68104f07fedfebc06eb9ade5a4d2c 100644 (file)
@@ -178,6 +178,14 @@ BF_EXPAT = '/usr'
 BF_EXPAT_LIB = 'expat'
 BF_EXPAT_LIBPATH = '/usr/lib'
 
+WITH_BF_JEMALLOC = False
+WITH_BF_STATICJEMALLOC = False
+BF_JEMALLOC = '/usr'
+BF_JEMALLOC_INC = '${BF_JEMALLOC}/include'
+BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib'
+BF_JEMALLOC_LIB = 'jemalloc'
+BF_JEMALLOC_LIB_STATIC = '${BF_JEMALLOC_LIBPATH}/libjemalloc.a'
+
 WITH_BF_OPENMP = True
 
 #Ray trace optimization
index ad4df1a60c1fe61c0fe49cb4a30bb1b4dc1e26e2..90c2c35bb98548721ee145eac770212b27eeb564 100644 (file)
@@ -203,6 +203,11 @@ def setup_staticlibs(lenv):
     if lenv['OURPLATFORM'] not in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
         libincs.append('/usr/lib')
 
+    if lenv['WITH_BF_JEMALLOC']:
+        libincs += Split(lenv['BF_JEMALLOC_LIBPATH'])
+        if lenv['WITH_BF_STATICJEMALLOC']:
+            statlibs += Split(lenv['BF_JEMALLOC_LIB_STATIC'])
+
     return statlibs, libincs
 
 def setup_syslibs(lenv):
@@ -263,6 +268,9 @@ def setup_syslibs(lenv):
     if not lenv['WITH_BF_STATICLIBSAMPLERATE']:
         syslibs += Split(lenv['BF_LIBSAMPLERATE_LIB'])
 
+    if lenv['WITH_BF_JEMALLOC']:
+        if not lenv['WITH_BF_STATICJEMALLOC']:
+            syslibs += Split(lenv['BF_JEMALLOC_LIB'])
 
     syslibs += lenv['LLIBS']
 
index fcc782bd824245e4606efda1c1da50f6e32df348..fda88d7d5a93f7a822b25879733f737584073c47 100644 (file)
@@ -134,7 +134,8 @@ def validate_arguments(args, bc):
             'WITH_BF_RAYOPTIMIZATION',
             'BF_RAYOPTIMIZATION_SSE_FLAGS',
             'BF_NO_ELBEEM',
-            'WITH_BF_CXX_GUARDEDALLOC'
+            'WITH_BF_CXX_GUARDEDALLOC',
+            'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC'
             ]
     
     # Have options here that scons expects to be lists
@@ -429,6 +430,14 @@ def read_opts(env, cfg, args):
         ('BF_EXPAT_LIB', 'Expat library', ''),
         ('BF_EXPAT_LIBPATH', 'Expat library path', ''),
         
+        (BoolVariable('WITH_BF_JEMALLOC', 'Use jemalloc if true', False)),
+        (BoolVariable('WITH_BF_STATICJEMALLOC', 'Staticly link to jemalloc', False)),
+        ('BF_JEMALLOC', 'jemalloc base path', ''),
+        ('BF_JEMALLOC_INC', 'jemalloc include path', ''),
+        ('BF_JEMALLOC_LIB', 'jemalloc library', ''),
+        ('BF_JEMALLOC_LIBPATH', 'jemalloc library path', ''),
+        ('BF_JEMALLOC_LIB_STATIC', 'jemalloc static library', ''),
+
         (BoolVariable('WITH_BF_PLAYER', 'Build blenderplayer if true', False)),
         (BoolVariable('WITH_BF_NOBLENDER', 'Do not build blender if true', False)),