Render Engines: fix crash when changing render engine during rendering
[blender.git] / SConstruct
index f0250808faf198c54183dd811b5c925200122e95..4af85f51a4b1884c59ad12589deccb66841feeac 100644 (file)
@@ -92,7 +92,7 @@ if platform=='win32':
 
 if not use_color=='1':
     B.bc.disable()
-    
+
  #on defaut white Os X terminal, some colors are totally unlegible
 if platform=='darwin':
     B.bc.OKGREEN = '\033[34m'
@@ -123,7 +123,7 @@ if bitness:
     B.bitness = bitness
 else: 
     B.bitness = tempbitness
-    
+
 
 # first check cmdline for toolset and we create env to work on
 quickie = B.arguments.get('BF_QUICK', None)
@@ -138,7 +138,7 @@ if quickie:
     B.quickie=string.split(quickie,',')
 else:
     B.quickie=[]
-    
+
 toolset = B.arguments.get('BF_TOOLSET', None)
 if toolset:
     print "Using " + toolset
@@ -264,13 +264,12 @@ if 'blenderlite' in B.targets:
     target_env_defs['WITH_BF_FLUID'] = False
     target_env_defs['WITH_BF_OCEANSIM'] = False
     target_env_defs['WITH_BF_SMOKE'] = False
-    target_env_defs['WITH_BF_DECIMATE'] = False
     target_env_defs['WITH_BF_BOOLEAN'] = False
     target_env_defs['WITH_BF_REMESH'] = False
     target_env_defs['WITH_BF_PYTHON'] = False
     target_env_defs['WITH_BF_3DMOUSE'] = False
     target_env_defs['WITH_BF_LIBMV'] = False
-    
+
     # Merge blenderlite, let command line to override
     for k,v in target_env_defs.iteritems():
         if k not in B.arguments:
@@ -280,8 +279,10 @@ if 'blenderlite' in B.targets:
 if env['OURPLATFORM']=='darwin':
     print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --"
     print "Available " + env['MACOSX_SDK_CHECK']
-    if not 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
-        print  B.bc.OKGREEN + "MacOSX10.5.sdk not available:" + B.bc.ENDC + " using MacOSX10.6.sdk"
+    if not 'Mac OS X 10.6' in env['MACOSX_SDK_CHECK']:
+        print  B.bc.OKGREEN + "Auto-setting available MacOSX SDK -> " + B.bc.ENDC + "MacOSX10.7.sdk"
+    elif not 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
+        print  B.bc.OKGREEN + "Auto-setting available MacOSX SDK -> " + B.bc.ENDC + "MacOSX10.6.sdk"
     else:
         print B.bc.OKGREEN + "Found recommended sdk :" + B.bc.ENDC + " using MacOSX10.5.sdk"
 
@@ -317,7 +318,7 @@ if env['WITH_BF_OPENMP'] == 1:
 
 if env['WITH_GHOST_COCOA'] == True:
     env.Append(CPPFLAGS=['-DGHOST_COCOA']) 
-    
+
 if env['USE_QTKIT'] == True:
     env.Append(CPPFLAGS=['-DUSE_QTKIT'])
 
@@ -364,6 +365,7 @@ else:
 
 # TODO, make optional
 env['CPPFLAGS'].append('-DWITH_AUDASPACE')
+env['CPPFLAGS'].append('-DWITH_AVI')
 
 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
 B.root_build_dir = env['BF_BUILDDIR']
@@ -372,7 +374,7 @@ if not B.root_build_dir[-1]==os.sep:
     B.root_build_dir += os.sep
 if not B.doc_build_dir[-1]==os.sep:
     B.doc_build_dir += os.sep
-    
+
 # We do a shortcut for clean when no quicklist is given: just delete
 # builddir without reading in SConscripts
 do_clean = None
@@ -420,16 +422,22 @@ if not quickie and do_clean:
 # with _any_ library but since we used a fixed python version this tends to
 # be most problematic.
 if env['WITH_BF_PYTHON']:
-       py_h = os.path.join(Dir(env.subst('${BF_PYTHON_INC}')).abspath, "Python.h")
+    found_python_h = found_pyconfig_h = False
+    for bf_python_inc in env.subst('${BF_PYTHON_INC}').split():
+        py_h = os.path.join(Dir(bf_python_inc).abspath, "Python.h")
+        if os.path.exists(py_h):
+            found_python_h = True
+        py_h = os.path.join(Dir(bf_python_inc).abspath, "pyconfig.h")
+        if os.path.exists(py_h):
+            found_pyconfig_h = True
 
-       if not os.path.exists(py_h):
-               print("\nMissing: \"" + env.subst('${BF_PYTHON_INC}') + os.sep + "Python.h\",\n"
-                         "  Set 'BF_PYTHON_INC' to point "
-                         "to a valid python include path.\n  Containing "
-                         "Python.h for python version \"" + env.subst('${BF_PYTHON_VERSION}') + "\"")
+    if not (found_python_h and found_pyconfig_h):
+        print("\nMissing: Python.h and/or pyconfig.h in\"" + env.subst('${BF_PYTHON_INC}') + "\",\n"
+              "  Set 'BF_PYTHON_INC' to point "
+              "to valid python include path(s).\n Containing "
+              "Python.h and pyconfig.h for python version \"" + env.subst('${BF_PYTHON_VERSION}') + "\"")
 
-               Exit()
-       del py_h
+        Exit()
 
 
 if not os.path.isdir ( B.root_build_dir):
@@ -443,9 +451,116 @@ if not os.path.isdir ( B.root_build_dir):
 # if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
 #     os.makedirs ( B.doc_build_dir )
 
+###################################
+# Ensure all data files are valid #
+###################################
+if not os.path.isdir ( B.root_build_dir + 'data_headers'):
+    os.makedirs ( B.root_build_dir + 'data_headers' )
+if not os.path.isdir ( B.root_build_dir + 'data_sources'):
+    os.makedirs ( B.root_build_dir + 'data_sources' )
+# use for includes
+env['DATA_HEADERS'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_headers")
+env['DATA_SOURCES'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_sources")
+def data_to_c(FILE_FROM, FILE_TO, VAR_NAME):
+    if os.sep == "\\":
+        FILE_FROM = FILE_FROM.replace("/", "\\")
+        FILE_TO   = FILE_TO.replace("/", "\\")
+
+    # first check if we need to bother.
+    if os.path.exists(FILE_TO):
+        if os.path.getmtime(FILE_FROM) < os.path.getmtime(FILE_TO):
+            return
+
+    print(B.bc.HEADER + "Generating: " + B.bc.ENDC + "%r" % os.path.basename(FILE_TO))
+    fpin = open(FILE_FROM, "rb")
+    fpin.seek(0, os.SEEK_END)
+    size = fpin.tell()
+    fpin.seek(0)
+
+    fpout = open(FILE_TO, "w")
+    fpout.write("int  %s_size = %d;\n" % (VAR_NAME, size))
+    fpout.write("char %s[] = {\n" % VAR_NAME)
+
+    while size > 0:
+        size -= 1
+        if size % 32 == 31:
+            fpout.write("\n")
+
+        fpout.write("%3d," % ord(fpin.read(1)))
+    fpout.write("\n  0};\n\n")
+
+    fpin.close()
+    fpout.close()
+
+def data_to_c_simple(FILE_FROM):
+       filename_only = os.path.basename(FILE_FROM)
+       FILE_TO = os.path.join(env['DATA_SOURCES'], filename_only + ".c")
+       VAR_NAME = "datatoc_" + filename_only.replace(".", "_")
+       
+       data_to_c(FILE_FROM, FILE_TO, VAR_NAME)
+       
+
+data_to_c("source/blender/compositor/operations/COM_OpenCLKernels.cl",
+          B.root_build_dir + "data_headers/COM_OpenCLKernels.cl.h",
+          "datatoc_COM_OpenCLKernels_cl")
+
+data_to_c_simple("release/datafiles/startup.blend")
+data_to_c_simple("release/datafiles/preview.blend")
+
+# --- glsl ---
+data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
+data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex.glsl")
+data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl")
+data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl")
+data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
+data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl")
+data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl")
+
+# --- blender ---
+data_to_c_simple("release/datafiles/bfont.pfb")
+data_to_c_simple("release/datafiles/bfont.ttf")
+data_to_c_simple("release/datafiles/bmonofont.ttf")
+
+data_to_c_simple("release/datafiles/splash.png")
+data_to_c_simple("release/datafiles/blender_icons.png")
+data_to_c_simple("release/datafiles/prvicons.png")
+
+data_to_c_simple("release/datafiles/brushicons/add.png")
+data_to_c_simple("release/datafiles/brushicons/blob.png")
+data_to_c_simple("release/datafiles/brushicons/blur.png")
+data_to_c_simple("release/datafiles/brushicons/clay.png")
+data_to_c_simple("release/datafiles/brushicons/claystrips.png")
+data_to_c_simple("release/datafiles/brushicons/clone.png")
+data_to_c_simple("release/datafiles/brushicons/crease.png")
+data_to_c_simple("release/datafiles/brushicons/darken.png")
+data_to_c_simple("release/datafiles/brushicons/draw.png")
+data_to_c_simple("release/datafiles/brushicons/fill.png")
+data_to_c_simple("release/datafiles/brushicons/flatten.png")
+data_to_c_simple("release/datafiles/brushicons/grab.png")
+data_to_c_simple("release/datafiles/brushicons/inflate.png")
+data_to_c_simple("release/datafiles/brushicons/layer.png")
+data_to_c_simple("release/datafiles/brushicons/lighten.png")
+data_to_c_simple("release/datafiles/brushicons/mask.png")
+data_to_c_simple("release/datafiles/brushicons/mix.png")
+data_to_c_simple("release/datafiles/brushicons/multiply.png")
+data_to_c_simple("release/datafiles/brushicons/nudge.png")
+data_to_c_simple("release/datafiles/brushicons/pinch.png")
+data_to_c_simple("release/datafiles/brushicons/scrape.png")
+data_to_c_simple("release/datafiles/brushicons/smear.png")
+data_to_c_simple("release/datafiles/brushicons/smooth.png")
+data_to_c_simple("release/datafiles/brushicons/snake_hook.png")
+data_to_c_simple("release/datafiles/brushicons/soften.png")
+data_to_c_simple("release/datafiles/brushicons/subtract.png")
+data_to_c_simple("release/datafiles/brushicons/texdraw.png")
+data_to_c_simple("release/datafiles/brushicons/thumb.png")
+data_to_c_simple("release/datafiles/brushicons/twist.png")
+data_to_c_simple("release/datafiles/brushicons/vertexdraw.png")
+
+##### END DATAFILES ##########
+
 Help(opts.GenerateHelpText(env))
 
-# default is new quieter output, but if you need to see the 
+# default is new quieter output, but if you need to see the
 # commands, do 'scons BF_QUIET=0'
 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
 if env['BF_QUIET']:
@@ -532,7 +647,7 @@ if env['OURPLATFORM']!='darwin':
     for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
         td, tf = os.path.split(targetdir)
         dotblenderinstall.append(env.Install(dir=td, source=srcfile))
-    
+
     if env['WITH_BF_PYTHON']:
         #-- local/VERSION/scripts
         scriptpaths=['release/scripts']
@@ -632,10 +747,10 @@ if env['OURPLATFORM']!='darwin':
 
     if env['WITH_BF_INTERNATIONAL']:
         internationalpaths=['release' + os.sep + 'datafiles']
-        
+
         def check_path(path, member):
             return (member in path.split(os.sep))
-        
+
         for intpath in internationalpaths:
             for dp, dn, df in os.walk(intpath):
                 if '.svn' in dn:
@@ -648,7 +763,7 @@ if env['OURPLATFORM']!='darwin':
                     pass
                 else:
                     continue
-                
+
                 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
                 dir += os.sep + os.path.basename(intpath) + dp[len(intpath):]
 
@@ -710,10 +825,6 @@ else:
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
     dllsources = []
 
-    if not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
-        # For MinGW and linuxcross static linking will be used
-        dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
-
     dllsources += ['${BF_ZLIB_LIBPATH}/zlib.dll']
     # Used when linking to libtiff was dynamic
     # keep it here until compilation on all platform would be ok
@@ -756,15 +867,19 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
     # strict: the x86 build fails on x64 Windows. We need to ship
     # both builds in x86 packages.
     if bitness == 32:
-        dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll') 
+        dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')
     dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
 
     if env['WITH_BF_OIIO'] and env['OURPLATFORM'] != 'win32-mingw':
         dllsources.append('${LCGDIR}/openimageio/bin/OpenImageIO.dll')
 
-    if env['WITH_BF_OCIO'] and env['OURPLATFORM'] != 'win32-mingw':
-        dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll')
+    if env['WITH_BF_OCIO']:
+        if not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
+            dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll')
 
+        else:
+            dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
+                       
     dllsources.append('#source/icons/blender.exe.manifest')
 
     windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
@@ -772,7 +887,7 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
 
 if env['OURPLATFORM'] == 'win64-mingw':
     dllsources = []
-    
+
     if env['WITH_BF_PYTHON']:
         if env['BF_DEBUG']:
             dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
@@ -791,10 +906,13 @@ if env['OURPLATFORM'] == 'win64-mingw':
 
     if env['WITH_BF_SDL']:
         dllsources.append('${LCGDIR}/sdl/lib/SDL.dll')
-       
-       if(env['WITH_BF_OPENMP']):
-               dllsources.append('${LCGDIR}/binaries/libgomp-1.dll')
-       
+
+    if(env['WITH_BF_OPENMP']):
+        dllsources.append('${LCGDIR}/binaries/libgomp-1.dll')
+               
+    if env['WITH_BF_OCIO']:
+        dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
+
     dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
     dllsources.append('${LCGDIR}/binaries/libgcc_s_sjlj-1.dll')
     dllsources.append('${LCGDIR}/binaries/libwinpthread-1.dll')