Sequencer UI bugfix: translate / crop also work on effect output, UI was
[blender.git] / SConstruct
index 354915541b89a6e42defdc43aa38479626d9ae9e..acdf6182504406a1ef6f19b4abfd7244d92a791b 100644 (file)
@@ -46,15 +46,22 @@ import glob
 import re
 from tempfile import mkdtemp
 
-import tools.Blender
-import tools.btools
-import tools.bcolors
+# store path to tools
+toolpath=os.path.join(".", "build_files", "scons", "tools")
+
+# needed for importing tools
+sys.path.append(toolpath)
+
+import Blender
+import btools
+import bcolors
 
 EnsureSConsVersion(1,0,0)
 
-BlenderEnvironment = tools.Blender.BlenderEnvironment
-btools = tools.btools
-B = tools.Blender
+BlenderEnvironment = Blender.BlenderEnvironment
+B = Blender
+
+VERSION = btools.VERSION # This is used in creating the local config directories
 
 ### globals ###
 platform = sys.platform
@@ -117,7 +124,7 @@ if toolset:
        print "Using " + toolset
        if toolset=='mstoolkit':
                env = BlenderEnvironment(ENV = os.environ)
-               env.Tool('mstoolkit', ['tools'])
+               env.Tool('mstoolkit', [toolpath])
        else:
                env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
                # xxx commented out, as was supressing warnings under mingw..
@@ -157,7 +164,7 @@ if crossbuild and platform not in ('win32-vc', 'win64-vc'):
 
 env['OURPLATFORM'] = platform
 
-configfile = 'config'+os.sep+platform+'-config.py'
+configfile = os.path.join("build_files", "scons", "config", platform + "-config.py")
 
 if os.path.exists(configfile):
        print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
@@ -166,10 +173,12 @@ else:
 
 if crossbuild and env['PLATFORM'] != 'win32':
        print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
-       env.Tool('crossmingw', ['tools'])
+       env.Tool('crossmingw', [toolpath])
        # todo: determine proper libs/includes etc.
        # Needed for gui programs, console programs should do without it
-       env.Append(LINKFLAGS=['-mwindows'])
+
+       # Now we don't need this option to have console window
+       # env.Append(LINKFLAGS=['-mwindows'])
 
 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
 # first read platform config. B.arguments will override
@@ -180,14 +189,26 @@ if os.path.exists(userconfig):
 else:
        print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
 
-opts = btools.read_opts(optfiles, B.arguments)
+opts = btools.read_opts(env, optfiles, B.arguments)
 opts.Update(env)
 
 if not env['BF_FANCY']:
        B.bc.disable()
 
+
+# remove install dir so old and new files are not mixed.
+# NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
+# TODO: perhaps we need an option (off by default) to not do this altogether...
+if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
+       scriptsDir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts')
+       if os.path.isdir(scriptsDir):
+               print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
+               shutil.rmtree(scriptsDir)
+
+
 SetOption('num_jobs', int(env['BF_NUMJOBS']))
-print "Build with %d parallel jobs" % (GetOption('num_jobs'))
+print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
+print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBUG'])
 
 # BLENDERPATH is a unix only option to enable typical style paths this is
 # spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
@@ -198,12 +219,6 @@ if env['WITH_BF_FHS']:
 else:
        BLENDERPATH = env['BF_INSTALLDIR']
 
-# disable elbeem (fluidsim) compilation?
-if env['BF_NO_ELBEEM'] == 1:
-       env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
-       env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
-       env['CCFLAGS'].append('-DDISABLE_ELBEEM')
-
 if env['WITH_BF_OPENMP'] == 1:
                if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
                                env['CCFLAGS'].append('/openmp')
@@ -237,40 +252,6 @@ if env.has_key('BF_DEBUG_LIBS'):
 
 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
 
-# see if this linux distro has libalut
-
-if env['OURPLATFORM'] == 'linux2' :
-       if env['WITH_BF_OPENAL']:
-               mylib_test_source_file = """
-               #include "AL/alut.h"
-               int main(int argc, char **argv)
-               {
-                       alutGetMajorVersion();
-                       return 0;
-               }
-               """
-
-               def CheckFreeAlut(context,env):
-                       context.Message( B.bc.OKGREEN + "Linux platform detected:\n  checking for FreeAlut... " + B.bc.ENDC )
-                       env['LIBS'] = 'alut'
-                       result = context.TryLink(mylib_test_source_file, '.c')
-                       context.Result(result)
-                       return result
-
-               env2 = env.Clone( LIBPATH = env['BF_OPENAL'] ) 
-               sconf_temp = mkdtemp()
-               conf = Configure( env2, {'CheckFreeAlut' : CheckFreeAlut}, sconf_temp, '/dev/null' )
-               if conf.CheckFreeAlut( env2 ):
-                       env['BF_OPENAL_LIB'] += ' alut'
-               del env2
-               root = ''
-               for root, dirs, files in os.walk(sconf_temp, topdown=False):
-                       for name in files:
-                               os.remove(os.path.join(root, name))
-                       for name in dirs:
-                               os.rmdir(os.path.join(root, name))
-               if root: os.rmdir(root)
-
 if len(B.quickdebug) > 0 and printdebug != 0:
        print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
        for l in B.quickdebug:
@@ -295,6 +276,7 @@ if 'blenderlite' in B.targets:
        target_env_defs['WITH_BF_GAMEENGINE'] = False
        target_env_defs['WITH_BF_OPENAL'] = False
        target_env_defs['WITH_BF_OPENEXR'] = False
+       target_env_defs['WITH_BF_OPENMP'] = False
        target_env_defs['WITH_BF_ICONV'] = False
        target_env_defs['WITH_BF_INTERNATIONAL'] = False
        target_env_defs['WITH_BF_OPENJPEG'] = False
@@ -317,6 +299,12 @@ if 'blenderlite' in B.targets:
                if k not in B.arguments:
                        env[k] = v
 
+# disable elbeem (fluidsim) compilation?
+if env['BF_NO_ELBEEM'] == 1:
+       env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
+       env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
+       env['CCFLAGS'].append('-DDISABLE_ELBEEM')
+
 if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-ming', 'win64-vc'):
        env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
        env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
@@ -392,7 +380,7 @@ else:
        if toolset=='msvc':
                B.msvc_hack(env)
 
-print B.bc.HEADER+'Building in '+B.bc.ENDC+B.root_build_dir
+print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
 env.SConsignFile(B.root_build_dir+'scons-signatures')
 B.init_lib_dict()
 
@@ -423,7 +411,7 @@ thestatlibs, thelibincs = B.setup_staticlibs(env)
 thesyslibs = B.setup_syslibs(env)
 
 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
-       env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
+       env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist + thestatlibs, [], thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
 if env['WITH_BF_PLAYER']:
        playerlist = B.create_blender_liblist(env, 'player')
        playerlist += B.create_blender_liblist(env, 'intern')
@@ -453,9 +441,11 @@ else:
        
        blenderinstall = env.Install(dir=dir, source=B.program_list)
 
-#-- .blender
-#- dont do .blender and scripts for darwin, it is already in the bundle
+#-- local path = config files in install dir: installdir\VERSION
+#- dont do config and scripts for darwin, it is already in the bundle
 dotblendlist = []
+datafileslist = []
+datafilestargetlist = []
 dottargetlist = []
 scriptinstall = []
 
@@ -474,22 +464,29 @@ if  env['OURPLATFORM']!='darwin':
                                        if f.endswith('.ttf'):
                                                continue
                                
-                               dotblendlist.append(os.path.join(dp, f))
-                               if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:]))      # skip bin/.blender
-                               else:                                   dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:]))      # skip bin
-                               
-                               # print dir+ os.sep + f
-                               print dir
-                               dottargetlist.append(dir + os.sep + f)
-                                       
+                               if 'locale' in dp:
+                                       datafileslist.append(os.path.join(dp,f))
+                                       if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + ['datafiles'] + dp.split(os.sep)[2:]))      # skip bin/.blender
+                                       else:                                   dir= os.path.join(*([BLENDERPATH] + [VERSION] + ['datafiles'] + dp.split(os.sep)[1:]))  # skip bin
+                                       datafilestargetlist.append(dir + os.sep + f)
 
+                               else:
+                                       dotblendlist.append(os.path.join(dp, f))
+                                       if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + ['config'] + dp.split(os.sep)[2:])) # skip bin/.blender
+                                       else:                                   dir= os.path.join(*([BLENDERPATH] + [VERSION] + ['config'] + dp.split(os.sep)[1:]))     # skip bin
+                                       
+                                       dottargetlist.append(dir + os.sep + f)
+                                       
                dotblenderinstall = []
                for targetdir,srcfile in zip(dottargetlist, dotblendlist):
                        td, tf = os.path.split(targetdir)
                        dotblenderinstall.append(env.Install(dir=td, source=srcfile))
+               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']:
-                       #-- .blender/scripts
+                       #-- local/VERSION/scripts
                        scriptpaths=['release/scripts']
                        for scriptpath in scriptpaths:
                                for dp, dn, df in os.walk(scriptpath):
@@ -497,7 +494,7 @@ if  env['OURPLATFORM']!='darwin':
                                                dn.remove('.svn')
                                        
                                        if env['WITH_BF_FHS']:          dir = BLENDERPATH
-                                       else:                                           dir = os.path.join(env['BF_INSTALLDIR'], '.blender')                            
+                                       else:                                           dir = os.path.join(env['BF_INSTALLDIR'], VERSION)                               
                                        dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
                                        
                                        source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
@@ -524,7 +521,11 @@ if env['OURPLATFORM']=='linux2':
 # TODO - add more libs, for now this lets blenderlite run
 if env['OURPLATFORM']=='linuxcross':
        dir=env['BF_INSTALLDIR']
-       source = ['../lib/windows/pthreads/lib/pthreadGC2.dll']
+       source = []
+
+       if env['WITH_BF_OPENMP']:
+               source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
+
        scriptinstall.append(env.Install(dir=dir, source=source))
 
 #-- plugins
@@ -577,51 +578,58 @@ elif env['OURPLATFORM']=='linux2':
 else:
                allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
 
-if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc'):
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
        dllsources = []
 
+       if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
+               # For MinGW and linuxcross static linking will be used
+               dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
+
+       #currently win64-vc doesn't appear to have libpng.dll
        if env['OURPLATFORM'] != 'win64-vc':
-               if env['OURPLATFORM'] != 'win32-mingw':
-                       # For MinGW static linking will be used
-                       dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']         
-               
-               dllsources += ['${BF_PNG_LIBPATH}/libpng.dll',
-                               '${BF_ZLIB_LIBPATH}/zlib.dll',
-                               '${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
-       dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
+               dllsources += ['${BF_PNG_LIBPATH}/libpng.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
+       # dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
+
+       if env['OURPLATFORM'] != 'linuxcross':
+               # pthreads library is already added
+               dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
+
        if env['WITH_BF_SDL']:
                if env['OURPLATFORM'] == 'win64-vc':
                        pass # we link statically already to SDL on win64
                else:
                        dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
+
        if env['WITH_BF_PYTHON']:
                if env['BF_DEBUG']:
                        dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
                else:
                        dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
+
        if env['WITH_BF_ICONV']:
                if env['OURPLATFORM'] == 'win64-vc':
                        pass # we link statically to iconv on win64
-               elif env['OURPLATFORM'] != 'win32-mingw':
-                       #gettext for MinGW is compiled staticly
+               elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
+                       #gettext for MinGW and cross-compilation is compiled staticly
                        dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
+
        if env['WITH_BF_OPENAL']:
                dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
                dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
+
        if env['WITH_BF_SNDFILE']:
                dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
+
        if env['WITH_BF_FFMPEG']:
-               dllsources += ['${LCGDIR}/ffmpeg/lib/avcodec-52.dll',
-                                               '${LCGDIR}/ffmpeg/lib/avformat-52.dll',
-                                               '${LCGDIR}/ffmpeg/lib/avdevice-52.dll',
-                                               '${LCGDIR}/ffmpeg/lib/avutil-50.dll',
-                                               '${LCGDIR}/ffmpeg/lib/swscale-0.dll',
-                                               '${LCGDIR}/ffmpeg/lib/libfaac-0.dll',
-                                               '${LCGDIR}/ffmpeg/lib/libfaad-2.dll',
-                                               '${LCGDIR}/ffmpeg/lib/libmp3lame-0.dll',
-                                               '${LCGDIR}/ffmpeg/lib/libx264-67.dll']
-       if env['WITH_BF_JACK']:
-               dllsources += ['${LCGDIR}/jack/lib/libjack.dll']
+               dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
+                                       '${BF_FFMPEG_LIBPATH}/avformat-52.dll',
+                                       '${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
+                                       '${BF_FFMPEG_LIBPATH}/avutil-50.dll',
+                                       '${BF_FFMPEG_LIBPATH}/swscale-0.dll']
        windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
        allinstall += windlls