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