SCons
[blender.git] / tools / Blender.py
1 #!/usr/bin/env python
2
3 """
4 tools.BlenderEnvironment
5
6 This environment builds on SCons.Script.SConscript.SConsEnvironment
7
8 * library repository
9 * custom printout
10 * wrapper functions
11
12 TODO: clean up and sanitise code - crosscheck with btools and SConstruct
13 to kill any code duplication
14
15 """
16
17 import os
18 import os.path
19 import string
20 import glob
21 import time
22 import sys
23
24 from SCons.Script.SConscript import SConsEnvironment
25 import SCons.Action
26 import SCons.Util
27 import SCons.Builder
28 import SCons.Tool
29 import bcolors
30 bc = bcolors.bcolors()
31
32 Split = SCons.Util.Split
33 Action = SCons.Action.Action
34 Builder = SCons.Builder.Builder
35 GetBuildPath = SConsEnvironment.GetBuildPath
36
37 # a few globals
38 root_build_dir = ''
39 doc_build_dir = ''
40 quickie = None # Anything else than None if BF_QUICK has been passed
41 quicklist = [] # The list of libraries/programs to compile during a quickie
42 program_list = [] # A list holding Nodes to final binaries, used to create installs
43 arguments = None
44 targets = None
45 resources = []
46
47 #some internals
48 blenderdeps = [] # don't manipulate this one outside this module!
49
50 ##### LIB STUFF ##########
51
52 possible_types = ['core'] # can be set in ie. SConstruct
53 libs = {}
54 vcp = []
55
56 def getresources():
57         return resources
58
59 def init_lib_dict():
60         for pt in possible_types:
61                 libs[pt] = {}
62
63 # helper func for add_lib_to_dict
64 def internal_lib_to_dict(dict = None, libtype = None, libname = None, priority = 100):
65         if not libname in dict[libtype]:
66                 done = None
67                 while not done:
68                         if dict[libtype].has_key(priority):
69                                 priority = priority + 1
70                         else:
71                                 done = True
72                 dict[libtype][priority] = libname
73
74 # libtype and priority can both be lists, for defining lib in multiple places
75 def add_lib_to_dict(env, dict = None, libtype = None, libname = None, priority = 100):
76         if not dict or not libtype or not libname:
77                 print "Passed wrong arg"
78                 env.Exit()
79
80         if type(libtype) is str and type(priority) is int:
81                 internal_lib_to_dict(dict, libtype, libname, priority)
82         elif type(libtype) is list and type(priority) is list:
83                 if len(libtype)==len(priority):
84                         for lt, p in zip(libtype, priority):
85                                 internal_lib_to_dict(dict, lt, libname, p)
86                 else:
87                         print "libtype and priority lists are unequal in length"
88                         env.Exit()
89         else:
90                 print "Wrong type combinations for libtype and priority. Only str and int or list and list"
91                 env.Exit()
92
93 def create_blender_liblist(lenv = None, libtype = None):
94         if not lenv or not libtype:
95                 print "missing arg"
96
97         lst = []
98         if libtype in possible_types:
99                 curlib = libs[libtype]
100                 sortlist = curlib.keys()
101                 sortlist.sort()
102                 for sk in sortlist:
103                         v = curlib[sk]
104                         target = os.path.abspath(os.getcwd() + os.sep + root_build_dir + 'lib' + os.sep +lenv['LIBPREFIX'] + v + lenv['LIBSUFFIX'])
105                         lst.append(target)
106
107         return lst
108
109 ## TODO: static linking
110 def setup_staticlibs(lenv):
111         statlibs = [
112                 #here libs for static linking
113         ]
114         libincs = [
115                 '/usr/lib',
116                 lenv['BF_OPENGL_LIBPATH'],
117                 lenv['BF_JPEG_LIBPATH'],
118                 lenv['BF_PNG_LIBPATH'],
119                 lenv['BF_ZLIB_LIBPATH'],
120                 lenv['BF_ICONV_LIBPATH']
121                 ]
122
123         libincs += Split(lenv['BF_FREETYPE_LIBPATH'])
124         if lenv['WITH_BF_PYTHON']:
125                 libincs += Split(lenv['BF_PYTHON_LIBPATH'])
126         if lenv['WITH_BF_SDL']:
127                 libincs += Split(lenv['BF_SDL_LIBPATH'])
128         if lenv['WITH_BF_FFMPEG']:
129                 libincs += Split(lenv['BF_FFMPEG_LIBPATH'])
130         if lenv['WITH_BF_OPENEXR']:
131                 libincs += Split(lenv['BF_OPENEXR_LIBPATH'])
132                 if lenv['WITH_BF_STATICOPENEXR']:
133                         statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC'])
134         if lenv['WITH_BF_INTERNATIONAL']:
135                 libincs += Split(lenv['BF_GETTEXT_LIBPATH'])
136         if lenv['WITH_BF_OPENAL']:
137                 libincs += Split(lenv['BF_OPENAL_LIBPATH'])
138                 if lenv['WITH_BF_STATICOPENAL']:
139                         statlibs += Split(lenv['BF_OPENAL_LIB_STATIC'])
140         if lenv['WITH_BF_STATICOPENGL']:
141                 statlibs += Split(lenv['BF_OPENGL_LIB_STATIC'])
142         if lenv['WITH_BF_STATICCXX']:
143                 statlibs += Split(lenv['BF_CXX_LIB_STATIC'])
144
145         if lenv['WITH_BF_PYTHON'] and lenv['WITH_BF_STATICPYTHON']:
146                 statlibs += Split(lenv['BF_PYTHON_LIB_STATIC'])
147
148         if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
149                 libincs += Split(lenv['BF_PTHREADS_LIBPATH'])
150
151         return statlibs, libincs
152
153 def setup_syslibs(lenv):
154         syslibs = [
155                 
156                 lenv['BF_JPEG_LIB'],
157                 lenv['BF_PNG_LIB'],
158                 lenv['BF_ZLIB_LIB']
159                 ]
160
161         syslibs += Split(lenv['BF_FREETYPE_LIB'])
162         if lenv['WITH_BF_PYTHON'] and not lenv['WITH_BF_STATICPYTHON']:
163                 if lenv['BF_DEBUG'] and lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
164                         syslibs.append(lenv['BF_PYTHON_LIB']+'_d')
165                 else:
166                         syslibs.append(lenv['BF_PYTHON_LIB'])
167         if lenv['WITH_BF_INTERNATIONAL']:
168                 syslibs += Split(lenv['BF_GETTEXT_LIB'])
169         if lenv['WITH_BF_OPENAL']:
170                 if not lenv['WITH_BF_STATICOPENAL']:
171                         syslibs += Split(lenv['BF_OPENAL_LIB'])
172         if lenv['WITH_BF_OPENMP'] and lenv['CC'] != 'icc':
173                 if lenv['CC'] == 'cl.exe':
174                         syslibs += ['vcomp']
175                 else:
176                         syslibs += ['gomp']
177         if lenv['WITH_BF_ICONV']:
178                 syslibs += Split(lenv['BF_ICONV_LIB'])
179         if lenv['WITH_BF_OPENEXR']:
180                 if not lenv['WITH_BF_STATICOPENEXR']:
181                         syslibs += Split(lenv['BF_OPENEXR_LIB'])
182         if lenv['WITH_BF_FFMPEG']:
183                 syslibs += Split(lenv['BF_FFMPEG_LIB'])
184                 if lenv['WITH_BF_OGG']:
185                         syslibs += Split(lenv['BF_OGG_LIB'])
186         if lenv['WITH_BF_SDL']:
187                 syslibs += Split(lenv['BF_SDL_LIB'])
188         if not lenv['WITH_BF_STATICOPENGL']:
189                 syslibs += Split(lenv['BF_OPENGL_LIB'])
190         if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw','linuxcross', 'win64-vc'):
191                 syslibs += Split(lenv['BF_PTHREADS_LIB'])
192         if lenv['WITH_BF_LCMS']:
193                 syslibs.append(lenv['BF_LCMS_LIB'])
194
195
196         syslibs += lenv['LLIBS']
197
198         return syslibs
199
200 def propose_priorities():
201         print bc.OKBLUE+"Priorities:"+bc.ENDC
202         for t in possible_types:
203                 print bc.OKGREEN+"\t"+t+bc.ENDC
204                 new_priority = 0
205                 curlib = libs[t]
206                 sortlist = curlib.keys()
207                 sortlist.sort()
208
209                 for sk in sortlist:
210                         v = curlib[sk]
211                         #for p,v in sorted(libs[t].iteritems()):
212                         print "\t\t",new_priority, v
213                         new_priority += 5
214
215 ## TODO: see if this can be made in an emitter
216 def buildinfo(lenv, build_type):
217         """
218         Generate a buildinfo object
219         """
220         build_date = time.strftime ("%Y-%m-%d")
221         build_time = time.strftime ("%H:%M:%S")
222         build_rev = os.popen('svnversion').read()[:-1] # remove \n
223
224         obj = []
225         if lenv['BF_BUILDINFO']:
226                 if sys.platform=='win32':
227                         build_info_file = open("source/creator/winbuildinfo.h", 'w')
228                         build_info_file.write("char *build_date=\"%s\";\n"%build_date)
229                         build_info_file.write("char *build_time=\"%s\";\n"%build_time)
230                         build_info_file.write("char *build_rev=\"%s\";\n"%build_rev)
231                         build_info_file.write("char *build_platform=\"win32\";\n")
232                         build_info_file.write("char *build_type=\"dynamic\";\n")
233                         build_info_file.close()
234                         lenv.Append (CPPDEFINES = ['NAN_BUILDINFO', 'BUILD_DATE'])
235                 else:
236                         lenv.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
237                                                                                 'BUILD_DATE=\'"%s"\''%(build_date),
238                                                                                 'BUILD_TYPE=\'"dynamic"\'',
239                                                                                 'BUILD_REV=\'"%s"\''%(build_rev),
240                                                                                 'NAN_BUILDINFO',
241                                                                                 'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
242                 obj = [lenv.Object (root_build_dir+'source/creator/%s_buildinfo'%build_type,
243                                                 [root_build_dir+'source/creator/buildinfo.c'])]
244         return obj
245
246 ##### END LIB STUFF ############
247
248 ##### ACTION STUFF #############
249
250 def my_compile_print(target, source, env):
251         a = '%s' % (source[0])
252         d, f = os.path.split(a)
253         return bc.OKBLUE+"Compiling"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
254
255 def my_moc_print(target, source, env):
256         a = '%s' % (source[0])
257         d, f = os.path.split(a)
258         return bc.OKBLUE+"Creating MOC"+bc.ENDC+ " ==> '"+bc.OKGREEN+"%s" %(f) + "'"+bc.ENDC
259
260 def my_linking_print(target, source, env):
261         t = '%s' % (target[0])
262         d, f = os.path.split(t)
263         return bc.OKBLUE+"Linking library"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
264
265 def my_program_print(target, source, env):
266         t = '%s' % (target[0])
267         d, f = os.path.split(t)
268         return bc.OKBLUE+"Linking program"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
269
270 def msvc_hack(env):
271         static_lib = SCons.Tool.createStaticLibBuilder(env)
272         program = SCons.Tool.createProgBuilder(env)
273         
274         env['BUILDERS']['Library'] = static_lib
275         env['BUILDERS']['StaticLibrary'] = static_lib
276         env['BUILDERS']['Program'] = program
277                 
278 def set_quiet_output(env):
279         mycaction = Action("$CCCOM", strfunction=my_compile_print)
280         myshcaction = Action("$SHCCCOM", strfunction=my_compile_print)
281         mycppaction = Action("$CXXCOM", strfunction=my_compile_print)
282         myshcppaction = Action("$SHCXXCOM", strfunction=my_compile_print)
283         mylibaction = Action("$ARCOM", strfunction=my_linking_print)
284         mylinkaction = Action("$LINKCOM", strfunction=my_program_print)
285
286         static_ob, shared_ob = SCons.Tool.createObjBuilders(env)
287         static_ob.add_action('.c', mycaction)
288         static_ob.add_action('.cpp', mycppaction)
289         shared_ob.add_action('.c', myshcaction)
290         shared_ob.add_action('.cpp', myshcppaction)
291
292         static_lib = SCons.Builder.Builder(action = mylibaction,
293                                                                            emitter = '$LIBEMITTER',
294                                                                            prefix = '$LIBPREFIX',
295                                                                            suffix = '$LIBSUFFIX',
296                                                                            src_suffix = '$OBJSUFFIX',
297                                                                            src_builder = 'StaticObject')
298
299         program = SCons.Builder.Builder(action = mylinkaction,
300                                                                         emitter = '$PROGEMITTER',
301                                                                         prefix = '$PROGPREFIX',
302                                                                         suffix = '$PROGSUFFIX',
303                                                                         src_suffix = '$OBJSUFFIX',
304                                                                         src_builder = 'Object',
305                                                                         target_scanner = SCons.Defaults.ProgScan)
306
307         env['BUILDERS']['Object'] = static_ob
308         env['BUILDERS']['StaticObject'] = static_ob
309         env['BUILDERS']['StaticLibrary'] = static_lib
310         env['BUILDERS']['Library'] = static_lib
311         env['BUILDERS']['Program'] = program
312
313 def  my_appit_print(target, source, env):
314         a = '%s' % (target[0])
315         d, f = os.path.split(a)
316         return "making bundle for " + f
317
318 def AppIt(target=None, source=None, env=None):
319         import shutil
320         import commands
321         import os.path
322         
323         
324         a = '%s' % (target[0])
325         builddir, b = os.path.split(a)
326
327         bldroot = env.Dir('.').abspath
328         binary = env['BINARYKIND']
329          
330         if b=='verse':
331                 print bc.OKBLUE+"no bundle for verse"+bc.ENDC 
332                 return 0
333         
334         sourcedir = bldroot + '/source/darwin/%s.app'%binary
335         sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary
336         targetinfo = builddir +'/' + "%s.app/Contents/Info.plist"%binary
337         cmd = builddir + '/' +'%s.app'%binary
338         
339         if os.path.isdir(cmd):
340                 shutil.rmtree(cmd)
341         shutil.copytree(sourcedir, cmd)
342         cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
343         commands.getoutput(cmd)
344         cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,builddir, binary, binary)
345         commands.getoutput(cmd)
346         cmd = 'mkdir %s/%s.app/Contents/MacOS/.blender/'%(builddir, binary)
347         print cmd
348         commands.getoutput(cmd)
349         cmd = builddir + '/%s.app/Contents/MacOS/.blender'%binary
350         shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd)
351         shutil.copy(bldroot + '/bin/.blender/.Blanguages', cmd)
352         cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
353         commands.getoutput(cmd) 
354         cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
355         commands.getoutput(cmd) 
356         cmd = 'cp %s/bin/.blender/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
357         commands.getoutput(cmd) 
358         cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
359         commands.getoutput(cmd)
360         cmd = 'cp -R %s/release/ui %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
361         commands.getoutput(cmd)
362         cmd = 'chmod +x  %s/%s.app/Contents/MacOS/%s'%(builddir,binary, binary)
363         commands.getoutput(cmd)
364         cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(builddir, binary)
365         commands.getoutput(cmd)
366         cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary)
367         commands.getoutput(cmd)
368
369 #### END ACTION STUFF #########
370
371 def bsc(env, target, source):
372         
373         bd = os.path.dirname(target[0].abspath)
374         bscfile = '\"'+target[0].abspath+'\"'
375         bscpathcollect = '\"'+bd + os.sep + '*.sbr\"'
376         bscpathtmp = '\"'+bd + os.sep + 'bscmake.tmp\"'
377
378         os.system('dir /b/s '+bscpathcollect+' >'+bscpathtmp)
379
380         myfile = open(bscpathtmp[1:-1], 'r')
381         lines = myfile.readlines()
382         myfile.close()
383
384         newfile = open(bscpathtmp[1:-1], 'w')
385         for l in lines:
386                 newfile.write('\"'+l[:-1]+'\"\n')
387         newfile.close()
388                                 
389         os.system('bscmake /nologo /n /o'+bscfile+' @'+bscpathtmp)
390         os.system('del '+bscpathtmp)
391
392 class BlenderEnvironment(SConsEnvironment):
393
394         def BlenderRes(self=None, libname=None, source=None, libtype=['core'], priority=[100]):
395                 global libs
396                 if not self or not libname or not source:
397                         print bc.FAIL+'Cannot continue.  Missing argument for BlenderRes '+libname+bc.ENDC
398                         self.Exit()
399                 if self['OURPLATFORM'] not in ('win32-vc','win32-mingw','linuxcross', 'win64-vc'):
400                         print bc.FAIL+'BlenderRes is for windows only!'+bc.END
401                         self.Exit()
402                 
403                 print bc.HEADER+'Configuring resource '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC
404                 lenv = self.Clone()
405                 res = lenv.RES('#'+root_build_dir+'lib/'+libname, source)
406                 
407                 SConsEnvironment.Default(self, res)
408                 resources.append(res)
409
410         def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None, cc_compileflags=None, cxx_compileflags=None):
411                 global vcp
412                 if not self or not libname or not sources:
413                         print bc.FAIL+'Cannot continue. Missing argument for BuildBlenderLib '+libname+bc.ENDC
414                         self.Exit()
415
416                 def list_substring(quickie, libname):
417                         for q in quickie:
418                                 if libname.find(q) != -1:
419                                         return True
420                         return False
421
422                 if list_substring(quickie, libname) or len(quickie)==0:
423                         if list_substring(quickdebug, libname):
424                                 print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname +bc.ENDC+bc.OKBLUE+ " (debug mode)" + bc.ENDC
425                         else:
426                                 print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname + bc.ENDC
427                         lenv = self.Clone()
428                         lenv.Append(CPPPATH=includes)
429                         lenv.Append(CPPDEFINES=defines)
430                         if lenv['BF_DEBUG'] or (libname in quickdebug):
431                                         lenv.Append(CFLAGS = lenv['BF_DEBUG_CFLAGS'])
432                                         lenv.Append(CCFLAGS = lenv['BF_DEBUG_CCFLAGS'])
433                                         lenv.Append(CXXFLAGS = lenv['BF_DEBUG_CXXFLAGS'])
434                         else:
435                                         lenv.Append(CFLAGS = lenv['REL_CFLAGS'])
436                                         lenv.Append(CCFLAGS = lenv['REL_CCFLAGS'])
437                                         lenv.Append(CXXFLAGS = lenv['REL_CXXFLAGS'])
438                         if lenv['BF_PROFILE']:
439                                         lenv.Append(CFLAGS = lenv['BF_PROFILE_CFLAGS'])
440                                         lenv.Append(CCFLAGS = lenv['BF_PROFILE_CCFLAGS'])
441                                         lenv.Append(CXXFLAGS = lenv['BF_PROFILE_CXXFLAGS'])
442                         if compileflags:
443                                 lenv.Replace(CFLAGS = compileflags)
444                         if cc_compileflags:
445                                 lenv.Replace(CCFLAGS = cc_compileflags)
446                         if cxx_compileflags:
447                                 lenv.Replace(CXXFLAGS = cxx_compileflags)
448                         lenv.Append(CFLAGS = lenv['C_WARN'])
449                         lenv.Append(CCFLAGS = lenv['CC_WARN'])
450                         lenv.Append(CXXFLAGS = lenv['CXX_WARN'])
451
452                         if lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
453                                 if lenv['BF_DEBUG']:
454                                         lenv.Append(CCFLAGS = ['/MTd'])
455                                 else:
456                                         lenv.Append(CCFLAGS = ['/MT'])
457                         
458                         targetdir = root_build_dir+'lib/' + libname
459                         if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
460                                 targetdir = '#'+targetdir
461                         lib = lenv.Library(target= targetdir, source=sources)
462                         SConsEnvironment.Default(self, lib) # we add to default target, because this way we get some kind of progress info during build
463                         if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
464                                 #if targetdir[0] == '#':
465                                 #       targetdir = targetdir[1:-1]
466                                 print "! ",targetdir+ '.vcproj' # + self['MSVSPROJECTSUFFIX']
467                                 vcproject = self.MSVSProject(target = targetdir + '.vcproj', # + self['MSVSPROJECTSUFFIX'],
468                                                  srcs = sources,
469                                                  buildtarget = lib,
470                                                  variant = 'Release',
471                                                  auto_build_solution=0)
472                                 vcp.append(vcproject)
473                                 SConsEnvironment.Default(self, vcproject)
474                 else:
475                         print bc.WARNING+'Not building '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC+' for '+bc.OKBLUE+'BF_QUICK'+bc.ENDC
476                 # note: libs is a global
477                 add_lib_to_dict(self, libs, libtype, libname, priority)
478
479         def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None, binarykind=''):
480                 global vcp
481                 print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC
482                 lenv = self.Clone()
483                 if lenv['OURPLATFORM'] in ('win32-vc', 'cygwin', 'win64-vc'):
484                         lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
485                         lenv.Append(LINKFLAGS = ['/FORCE:MULTIPLE'])
486                         if lenv['BF_DEBUG']:
487                                 lenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:'+progname+'.pdb'])
488                 if  lenv['OURPLATFORM']=='linux2':
489                         lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
490                         if lenv['WITH_BF_PYTHON']:
491                                 lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
492                 if  lenv['OURPLATFORM']=='sunos5':
493                         lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
494                         if lenv['WITH_BF_PYTHON']:
495                                 lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
496                         if lenv['CXX'].endswith('CC'):
497                                  lenv.Replace(LINK = '$CXX')
498                 if  lenv['OURPLATFORM']=='darwin':
499                         lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
500                         if lenv['WITH_BF_PYTHON']:
501                                 lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
502                         lenv.Append(LINKFLAGS = lenv['BF_OPENGL_LINKFLAGS'])
503                 if lenv['BF_PROFILE']:
504                         lenv.Append(LINKFLAGS = lenv['BF_PROFILE_LINKFLAGS'])
505                 lenv.Append(CPPPATH=includes)
506                 if root_build_dir[0]==os.sep or root_build_dir[1]==':':
507                         lenv.Append(LIBPATH=root_build_dir + '/lib')
508                 lenv.Append(LIBPATH=libpath)
509                 lenv.Append(LIBS=libs)
510                 if lenv['WITH_BF_QUICKTIME']:
511                          lenv.Append(LIBS = lenv['BF_QUICKTIME_LIB'])
512                          lenv.Append(LIBPATH = lenv['BF_QUICKTIME_LIBPATH'])
513                 prog = lenv.Program(target=builddir+'bin/'+progname, source=sources)
514                 if lenv['BF_DEBUG'] and lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc') and lenv['BF_BSC']:
515                         f = lenv.File(progname + '.bsc', builddir)
516                         brs = lenv.Command(f, prog, [bsc])
517                         SConsEnvironment.Default(self, brs)
518                 SConsEnvironment.Default(self, prog)
519                 if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc') and progname == 'blender':
520                         print "! ",builddir + "/" + progname + '.sln'
521                         sln = self.MSVSProject(target = builddir + "/" + progname + '.sln',
522                                          projects= vcp,
523                                          variant = 'Release')
524                         SConsEnvironment.Default(self, sln)
525                 program_list.append(prog)
526                 if  lenv['OURPLATFORM']=='darwin':
527                         lenv['BINARYKIND'] = binarykind
528                         lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print))
529                 return prog
530
531         def Glob(lenv, pattern):
532                 path = string.replace(GetBuildPath(lenv,'SConscript'),'SConscript', '')
533                 files = []
534                 for i in glob.glob(path + pattern):
535                         files.append(string.replace(i, path, ''))
536                 return files