==SCons==
[blender.git] / tools / Blender.py
index 2c761ca4a18d21ff7066ec8a423cd223f7d912a9..4a631f847981610b1ca60498b7aba8eb570b382a 100644 (file)
@@ -81,8 +81,6 @@ def add_lib_to_dict(dict = None, libtype = None, libname = None, priority = 100)
         print "Wrong type combinations for libtype and priority. Only str and int or list and list"
         Exit()
 
-#libs = init_lib_dict(libs)
-
 def create_blender_liblist(lenv = None, libtype = None):
     if not lenv or not libtype:
         print "missing arg"
@@ -96,7 +94,6 @@ def create_blender_liblist(lenv = None, libtype = None):
         curlib = libs[libtype]
         for sk in sortlist:
             v = curlib[sk]
-        #for k,v in sorted(libs[libtype].iteritems()):
             lst.append('#' + root_build_dir + 'lib/'+lenv['LIBPREFIX'] + v + lenv['LIBSUFFIX'])
 
     return lst
@@ -112,17 +109,18 @@ def setup_staticlibs(lenv):
         lenv['BF_OPENGL_LIBPATH'],
         lenv['BF_SDL_LIBPATH'],
         lenv['BF_JPEG_LIBPATH'],
-        lenv['BF_TIFF_LIBPATH'],
         lenv['BF_PNG_LIBPATH'],
-        lenv['BF_GETTEXT_LIBPATH'],
         lenv['BF_ZLIB_LIBPATH'],
-        lenv['BF_OPENAL_LIBPATH'],
-        lenv['BF_FREETYPE_LIBPATH'],
-#        lenv['BF_QUICKTIME_LIBPATH'],
         lenv['BF_ICONV_LIBPATH']
         ]
     libincs += Split(lenv['BF_OPENEXR_LIBPATH'])
 
+    if lenv['WITH_BF_INTERNATIONAL']:
+        libincs += Split(lenv['BF_GETTEXT_LIBPATH'])
+        libincs += Split(lenv['BF_FREETYPE_LIBPATH'])
+    if lenv['WITH_BF_OPENAL']:
+        libincs += Split(lenv['BF_OPENAL_LIBPATH'])
+
     return statlibs, libincs
 
 def setup_syslibs(lenv):
@@ -130,17 +128,17 @@ def setup_syslibs(lenv):
         lenv['BF_PYTHON_LIB'],
         lenv['BF_JPEG_LIB'],
         lenv['BF_PNG_LIB'],
-        lenv['BF_ZLIB_LIB'],
-        lenv['BF_OPENAL_LIB'],
-        lenv['BF_FREETYPE_LIB'],
-        lenv['BF_GETTEXT_LIB']
-
-        #here libs for linking
+        lenv['BF_ZLIB_LIB']
         ]
+    if lenv['WITH_BF_INTERNATIONAL']:
+        syslibs += Split(lenv['BF_FREETYPE_LIB'])
+        syslibs += Split(lenv['BF_GETTEXT_LIB'])
+    if lenv['WITH_BF_OPENAL']:
+       syslibs += Split(lenv['BF_OPENAL_LIB'])
     if lenv['OURPLATFORM']=='win32vc':
-            syslibs += Split(lenv['BF_ICONV_LIB'])
-    syslibs += Split(lenv['BF_TIFF_LIB'])
-    syslibs += Split(lenv['BF_OPENEXR_LIB'])
+        syslibs += Split(lenv['BF_ICONV_LIB'])
+    if lenv['WITH_BF_OPENEXR']:
+        syslibs += Split(lenv['BF_OPENEXR_LIB'])
     syslibs += Split(lenv['BF_SDL_LIB'])
     syslibs += Split(lenv['BF_OPENGL_LIB'])
     syslibs += Split(lenv['LLIBS'])
@@ -171,7 +169,7 @@ def buildinfo(lenv, build_type):
     build_date = time.strftime ("%Y-%m-%d")
     build_time = time.strftime ("%H:%M:%S")
     obj = []
-    if True: #user_options_dict['USE_BUILDINFO'] == 1:
+    if lenv['BF_BUILDINFO']==1: #user_options_dict['USE_BUILDINFO'] == 1:
         if sys.platform=='win32':
             build_info_file = open("source/creator/winbuildinfo.h", 'w')
             build_info_file.write("char *build_date=\"%s\";\n"%build_date)
@@ -257,11 +255,57 @@ def set_quiet_output(env):
     env['BUILDERS']['Library'] = static_lib
     env['BUILDERS']['Program'] = program
 
+def  my_appit_print(target, source, env):
+    a = '%s' % (target[0])
+    d, f = os.path.split(a)
+    return "making bundle for " + f
+
+def AppIt(target=None, source=None, env=None):
+    import shutil
+    import commands
+    import os.path
+    
+    a = '%s' % (target[0])
+    builddir, b = os.path.split(a)
+    bldroot = env.Dir('.').abspath
+    binary = env['BINARYKIND']
+    
+    sourcedir = bldroot + '/source/darwin/%s.app'%binary
+    sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary
+    targetinfo = builddir +'/' + "%s.app/Contents/Info.plist"%binary
+    cmd = builddir + '/' +'%s.app'%binary
+    
+    if os.path.isdir(cmd):
+        shutil.rmtree(cmd)
+    shutil.copytree(sourcedir, cmd)
+    cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
+    commands.getoutput(cmd)
+    cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,builddir, binary, binary)
+    commands.getoutput(cmd)
+    cmd = 'mkdir %s/%s.app/Contents/MacOS/.blender/'%(builddir, binary)
+    print cmd
+    commands.getoutput(cmd)
+    cmd = builddir + '/%s.app/Contents/MacOS/.blender'%binary
+    shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd)
+    shutil.copy(bldroot + '/bin/.blender/.Blanguages', cmd)
+    cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
+    commands.getoutput(cmd) 
+    cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
+    commands.getoutput(cmd) 
+    cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
+    commands.getoutput(cmd)
+    cmd = 'chmod +x  %s/%s.app/Contents/MacOS/%s'%(builddir,binary, binary)
+    commands.getoutput(cmd)
+    cmd = 'find %s/%s.app -name CVS -prune -exec rm -rf {} \;'%(builddir, binary)
+    commands.getoutput(cmd)
+    cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary)
+    commands.getoutput(cmd)
 
 #### END ACTION STUFF #########
 
 class BlenderEnvironment(SConsEnvironment):
 
+
     def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None):
         if not self or not libname or not sources:
             print bc.FAIL+'Cannot continue. Missing argument for BuildBlenderLib '+libname+bc.ENDC
@@ -291,7 +335,7 @@ class BlenderEnvironment(SConsEnvironment):
         # note: libs is a global
         add_lib_to_dict(libs, libtype, libname, priority)
 
-    def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None):
+    def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None, binarykind=''):
         print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC
         lenv = self.Copy()
         if lenv['OURPLATFORM']=='win32-vc':
@@ -309,15 +353,9 @@ class BlenderEnvironment(SConsEnvironment):
         prog = lenv.Program(target=builddir+'bin/'+progname, source=sources)
         SConsEnvironment.Default(self, prog)
         program_list.append(prog)
-
-## TODO: have register for libs/programs, so that we test only that
-#  which have expressed their need to be tested in their own sconscript
-    def BlenderUnitTest(env, source, **kwargs):
-        test = env.Program(source, **kwargs)
-        env.AddPostAction(test, test[0].abspath)
-        env.Alias('check', test)
-        env.AlwaysBuild(test)
-        return test
+        if  lenv['OURPLATFORM']=='darwin':
+            lenv['BINARYKIND'] = binarykind
+            lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print))
 
     def Glob(lenv, pattern):
         path = string.replace(GetBuildPath(lenv,'SConscript'),'SConscript', '')