- BGE, Some sensors, stored the event manager in 2 places (became confusing to do...
[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.path
18 import string
19 import glob
20 import time
21 import sys
22
23 from SCons.Script.SConscript import SConsEnvironment
24 import SCons.Action
25 import SCons.Util
26 import SCons.Builder
27 import SCons.Tool
28 import bcolors
29 bc = bcolors.bcolors()
30
31 Split = SCons.Util.Split
32 Action = SCons.Action.Action
33 Builder = SCons.Builder.Builder
34 GetBuildPath = SConsEnvironment.GetBuildPath
35
36 # a few globals
37 root_build_dir = ''
38 doc_build_dir = ''
39 quickie = None # Anything else than None if BF_QUICK has been passed
40 quicklist = [] # The list of libraries/programs to compile during a quickie
41 program_list = [] # A list holding Nodes to final binaries, used to create installs
42 arguments = None
43 targets = None
44 resources = []
45
46 #some internals
47 blenderdeps = [] # don't manipulate this one outside this module!
48
49 ##### LIB STUFF ##########
50
51 possible_types = ['core'] # can be set in ie. SConstruct
52 libs = {}
53 vcp = []
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 = root_build_dir + 'lib/'+lenv['LIBPREFIX'] + v + lenv['LIBSUFFIX']
104                         if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
105                                 target = '#'+target
106                         lst.append(target)
107
108         return lst
109
110 ## TODO: static linking
111 def setup_staticlibs(lenv):
112         statlibs = [
113                 #here libs for static linking
114         ]
115         libincs = [
116                 '/usr/lib',
117                 lenv['BF_OPENGL_LIBPATH'],
118                 lenv['BF_JPEG_LIBPATH'],
119                 lenv['BF_PNG_LIBPATH'],
120                 lenv['BF_ZLIB_LIBPATH'],
121                 lenv['BF_ICONV_LIBPATH']
122                 ]
123
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                 libincs += Split(lenv['BF_FREETYPE_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         if lenv['WITH_BF_STATICCXX']:
144                 statlibs += Split(lenv['BF_CXX_LIB_STATIC'])
145
146         if lenv['WITH_BF_PYTHON'] and lenv['WITH_BF_STATICPYTHON']:
147                 statlibs += Split(lenv['BF_PYTHON_LIB_STATIC'])
148
149         if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross'):
150                 libincs += Split(lenv['BF_PTHREADS_LIBPATH'])
151
152         return statlibs, libincs
153
154 def setup_syslibs(lenv):
155         syslibs = [
156                 
157                 lenv['BF_JPEG_LIB'],
158                 lenv['BF_PNG_LIB'],
159                 lenv['BF_ZLIB_LIB']
160                 ]
161
162         if lenv['WITH_BF_PYTHON'] and not lenv['WITH_BF_STATICPYTHON']:
163                 if lenv['BF_DEBUG'] and lenv['OURPLATFORM'] in ('win32-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_FREETYPE_LIB'])
169                 syslibs += Split(lenv['BF_GETTEXT_LIB'])
170         if lenv['WITH_BF_OPENAL']:
171                 if not lenv['WITH_BF_STATICOPENAL']:
172                         syslibs += Split(lenv['BF_OPENAL_LIB'])
173         if lenv['WITH_BF_OPENMP'] and lenv['CC'] != 'icc':
174                 if lenv['CC'] == 'cl.exe':
175                         syslibs += ['vcomp']
176                 else:
177                         syslibs += ['gomp']
178         if lenv['WITH_BF_ICONV']:
179                 syslibs += Split(lenv['BF_ICONV_LIB'])
180         if lenv['WITH_BF_OPENEXR']:
181                 if not lenv['WITH_BF_STATICOPENEXR']:
182                         syslibs += Split(lenv['BF_OPENEXR_LIB'])
183         if lenv['WITH_BF_FFMPEG']:
184                 syslibs += Split(lenv['BF_FFMPEG_LIB'])
185                 if lenv['WITH_BF_OGG']:
186                         syslibs += Split(lenv['BF_OGG_LIB'])
187         if lenv['WITH_BF_SDL']:
188                 syslibs += Split(lenv['BF_SDL_LIB'])
189         if not lenv['WITH_BF_STATICOPENGL']:
190                 syslibs += Split(lenv['BF_OPENGL_LIB'])
191         if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw','linuxcross'):
192                 syslibs += Split(lenv['BF_PTHREADS_LIB'])
193
194         syslibs += lenv['LLIBS']
195
196         return syslibs
197
198 def propose_priorities():
199         print bc.OKBLUE+"Priorities:"+bc.ENDC
200         for t in possible_types:
201                 print bc.OKGREEN+"\t"+t+bc.ENDC
202                 new_priority = 0
203                 curlib = libs[t]
204                 sortlist = curlib.keys()
205                 sortlist.sort()
206
207                 for sk in sortlist:
208                         v = curlib[sk]
209                         #for p,v in sorted(libs[t].iteritems()):
210                         print "\t\t",new_priority, v
211                         new_priority += 5
212
213 ## TODO: see if this can be made in an emitter
214 def buildinfo(lenv, build_type):
215         """
216         Generate a buildinfo object
217         """
218         build_date = time.strftime ("%Y-%m-%d")
219         build_time = time.strftime ("%H:%M:%S")
220         build_rev = os.popen('svnversion').read()[:-1] # remove \n
221
222         obj = []
223         if lenv['BF_BUILDINFO']:
224                 if sys.platform=='win32':
225                         build_info_file = open("source/creator/winbuildinfo.h", 'w')
226                         build_info_file.write("char *build_date=\"%s\";\n"%build_date)
227                         build_info_file.write("char *build_time=\"%s\";\n"%build_time)
228                         build_info_file.write("char *build_rev=\"%s\";\n"%build_rev)
229                         build_info_file.write("char *build_platform=\"win32\";\n")
230                         build_info_file.write("char *build_type=\"dynamic\";\n")
231                         build_info_file.close()
232                         lenv.Append (CPPDEFINES = ['NAN_BUILDINFO', 'BUILD_DATE'])
233                 else:
234                         lenv.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
235                                                                                 'BUILD_DATE=\'"%s"\''%(build_date),
236                                                                                 'BUILD_TYPE=\'"dynamic"\'',
237                                                                                 'BUILD_REV=\'"%s"\''%(build_rev),
238                                                                                 'NAN_BUILDINFO',
239                                                                                 'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
240                 obj = [lenv.Object (root_build_dir+'source/creator/%s_buildinfo'%build_type,
241                                                 [root_build_dir+'source/creator/buildinfo.c'])]
242         return obj
243
244 ##### END LIB STUFF ############
245
246 ##### ACTION STUFF #############
247
248 def my_compile_print(target, source, env):
249         a = '%s' % (source[0])
250         d, f = os.path.split(a)
251         return bc.OKBLUE+"Compiling"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
252
253 def my_moc_print(target, source, env):
254         a = '%s' % (source[0])
255         d, f = os.path.split(a)
256         return bc.OKBLUE+"Creating MOC"+bc.ENDC+ " ==> '"+bc.OKGREEN+"%s" %(f) + "'"+bc.ENDC
257
258 def my_linking_print(target, source, env):
259         t = '%s' % (target[0])
260         d, f = os.path.split(t)
261         return bc.OKBLUE+"Linking library"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
262
263 def my_program_print(target, source, env):
264         t = '%s' % (target[0])
265         d, f = os.path.split(t)
266         return bc.OKBLUE+"Linking program"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
267
268 def msvc_hack(env):
269         static_lib = SCons.Tool.createStaticLibBuilder(env)
270         program = SCons.Tool.createProgBuilder(env)
271         
272         env['BUILDERS']['Library'] = static_lib
273         env['BUILDERS']['StaticLibrary'] = static_lib
274         env['BUILDERS']['Program'] = program
275                 
276 def set_quiet_output(env):
277         mycaction = Action("$CCCOM", strfunction=my_compile_print)
278         myshcaction = Action("$SHCCCOM", strfunction=my_compile_print)
279         mycppaction = Action("$CXXCOM", strfunction=my_compile_print)
280         myshcppaction = Action("$SHCXXCOM", strfunction=my_compile_print)
281         mylibaction = Action("$ARCOM", strfunction=my_linking_print)
282         mylinkaction = Action("$LINKCOM", strfunction=my_program_print)
283
284         static_ob, shared_ob = SCons.Tool.createObjBuilders(env)
285         static_ob.add_action('.c', mycaction)
286         static_ob.add_action('.cpp', mycppaction)
287         shared_ob.add_action('.c', myshcaction)
288         shared_ob.add_action('.cpp', myshcppaction)
289
290         static_lib = SCons.Builder.Builder(action = mylibaction,
291                                                                            emitter = '$LIBEMITTER',
292                                                                            prefix = '$LIBPREFIX',
293                                                                            suffix = '$LIBSUFFIX',
294                                                                            src_suffix = '$OBJSUFFIX',
295                                                                            src_builder = 'StaticObject')
296
297         program = SCons.Builder.Builder(action = mylinkaction,
298                                                                         emitter = '$PROGEMITTER',
299                                                                         prefix = '$PROGPREFIX',
300                                                                         suffix = '$PROGSUFFIX',
301                                                                         src_suffix = '$OBJSUFFIX',
302                                                                         src_builder = 'Object',
303                                                                         target_scanner = SCons.Defaults.ProgScan)
304
305         env['BUILDERS']['Object'] = static_ob
306         env['BUILDERS']['StaticObject'] = static_ob
307         env['BUILDERS']['StaticLibrary'] = static_lib
308         env['BUILDERS']['Library'] = static_lib
309         env['BUILDERS']['Program'] = program
310
311 def  my_appit_print(target, source, env):
312         a = '%s' % (target[0])
313         d, f = os.path.split(a)
314         return "making bundle for " + f
315
316 def AppIt(target=None, source=None, env=None):
317         import shutil
318         import commands
319         import os.path
320         
321         
322         a = '%s' % (target[0])
323         builddir, b = os.path.split(a)
324
325         bldroot = env.Dir('.').abspath
326         binary = env['BINARYKIND']
327          
328         if b=='verse':
329                 print bc.OKBLUE+"no bundle for verse"+bc.ENDC 
330                 return 0
331         
332         sourcedir = bldroot + '/source/darwin/%s.app'%binary
333         sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary
334         targetinfo = builddir +'/' + "%s.app/Contents/Info.plist"%binary
335         cmd = builddir + '/' +'%s.app'%binary
336         
337         if os.path.isdir(cmd):
338                 shutil.rmtree(cmd)
339         shutil.copytree(sourcedir, cmd)
340         cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
341         commands.getoutput(cmd)
342         cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,builddir, binary, binary)
343         commands.getoutput(cmd)
344         cmd = 'mkdir %s/%s.app/Contents/MacOS/.blender/'%(builddir, binary)
345         print cmd
346         commands.getoutput(cmd)
347         cmd = builddir + '/%s.app/Contents/MacOS/.blender'%binary
348         shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd)
349         shutil.copy(bldroot + '/bin/.blender/.Blanguages', cmd)
350         cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
351         commands.getoutput(cmd) 
352         cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
353         commands.getoutput(cmd) 
354         cmd = 'cp %s/bin/.blender/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
355         commands.getoutput(cmd) 
356         cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
357         commands.getoutput(cmd)
358         cmd = 'chmod +x  %s/%s.app/Contents/MacOS/%s'%(builddir,binary, binary)
359         commands.getoutput(cmd)
360         cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(builddir, binary)
361         commands.getoutput(cmd)
362         cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary)
363         commands.getoutput(cmd)
364
365 #### END ACTION STUFF #########
366
367 def bsc(env, target, source):
368         
369         bd = os.path.dirname(target[0].abspath)
370         bscfile = '\"'+target[0].abspath+'\"'
371         bscpathcollect = '\"'+bd + os.sep + '*.sbr\"'
372         bscpathtmp = '\"'+bd + os.sep + 'bscmake.tmp\"'
373
374         os.system('dir /b/s '+bscpathcollect+' >'+bscpathtmp)
375
376         myfile = open(bscpathtmp[1:-1], 'r')
377         lines = myfile.readlines()
378         myfile.close()
379
380         newfile = open(bscpathtmp[1:-1], 'w')
381         for l in lines:
382                 newfile.write('\"'+l[:-1]+'\"\n')
383         newfile.close()
384                                 
385         os.system('bscmake /nologo /n /o'+bscfile+' @'+bscpathtmp)
386         os.system('del '+bscpathtmp)
387
388 class BlenderEnvironment(SConsEnvironment):
389
390         def BlenderRes(self=None, libname=None, source=None, libtype=['core'], priority=[100]):
391                 global libs
392                 if not self or not libname or not source:
393                         print bc.FAIL+'Cannot continue.  Missing argument for BlenderRes '+libname+bc.ENDC
394                         self.Exit()
395                 if self['OURPLATFORM'] not in ('win32-vc','win32-mingw','linuxcross'):
396                         print bc.FAIL+'BlenderRes is for windows only!'+bc.END
397                         self.Exit()
398                 
399                 print bc.HEADER+'Configuring resource '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC
400                 lenv = self.Clone()
401                 res = lenv.RES('#'+root_build_dir+'lib/'+libname, source)
402                 
403                 SConsEnvironment.Default(self, res)
404                 resources.append(res)
405
406         def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None, cc_compileflags=None, cxx_compileflags=None):
407                 global vcp
408                 if not self or not libname or not sources:
409                         print bc.FAIL+'Cannot continue. Missing argument for BuildBlenderLib '+libname+bc.ENDC
410                         self.Exit()
411
412                 def list_substring(quickie, libname):
413                         for q in quickie:
414                                 if libname.find(q) != -1:
415                                         return True
416                         return False
417
418                 if list_substring(quickie, libname) or len(quickie)==0:
419                         if list_substring(quickdebug, libname):
420                                 print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname +bc.ENDC+bc.OKBLUE+ " (debug mode)" + bc.ENDC
421                         else:
422                                 print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname + bc.ENDC
423                         lenv = self.Clone()
424                         lenv.Append(CPPPATH=includes)
425                         lenv.Append(CPPDEFINES=defines)
426                         if lenv['BF_DEBUG'] or (libname in quickdebug):
427                                         lenv.Append(CFLAGS = lenv['BF_DEBUG_CFLAGS'])
428                                         lenv.Append(CCFLAGS = lenv['BF_DEBUG_CCFLAGS'])
429                                         lenv.Append(CXXFLAGS = lenv['BF_DEBUG_CXXFLAGS'])
430                         else:
431                                         lenv.Append(CFLAGS = lenv['REL_CFLAGS'])
432                                         lenv.Append(CCFLAGS = lenv['REL_CCFLAGS'])
433                                         lenv.Append(CXXFLAGS = lenv['REL_CXXFLAGS'])
434                         if lenv['BF_PROFILE']:
435                                         lenv.Append(CFLAGS = lenv['BF_PROFILE_CFLAGS'])
436                                         lenv.Append(CCFLAGS = lenv['BF_PROFILE_CCFLAGS'])
437                                         lenv.Append(CXXFLAGS = lenv['BF_PROFILE_CXXFLAGS'])
438                         if compileflags:
439                                 lenv.Replace(CFLAGS = compileflags)
440                         if cc_compileflags:
441                                 lenv.Replace(CCFLAGS = cc_compileflags)
442                         if cxx_compileflags:
443                                 lenv.Replace(CXXFLAGS = cxx_compileflags)
444                         lenv.Append(CFLAGS = lenv['C_WARN'])
445                         lenv.Append(CCFLAGS = lenv['CC_WARN'])
446                         lenv.Append(CXXFLAGS = lenv['CXX_WARN'])
447                         
448                         targetdir = root_build_dir+'lib/' + libname
449                         if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
450                                 targetdir = '#'+targetdir
451                         lib = lenv.Library(target= targetdir, source=sources)
452                         SConsEnvironment.Default(self, lib) # we add to default target, because this way we get some kind of progress info during build
453                         if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
454                                 #if targetdir[0] == '#':
455                                 #       targetdir = targetdir[1:-1]
456                                 print "! ",targetdir+ '.vcproj' # + self['MSVSPROJECTSUFFIX']
457                                 vcproject = self.MSVSProject(target = targetdir + '.vcproj', # + self['MSVSPROJECTSUFFIX'],
458                                                  srcs = sources,
459                                                  buildtarget = lib,
460                                                  variant = 'Release',
461                                                  auto_build_solution=0)
462                                 vcp.append(vcproject)
463                                 SConsEnvironment.Default(self, vcproject)
464                 else:
465                         print bc.WARNING+'Not building '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC+' for '+bc.OKBLUE+'BF_QUICK'+bc.ENDC
466                 # note: libs is a global
467                 add_lib_to_dict(self, libs, libtype, libname, priority)
468
469         def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None, binarykind=''):
470                 global vcp
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']:
474                         lenv.Append(LINKFLAGS = Split(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']=='win32-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                 if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc') and progname == 'blender':
509                         print "! ",builddir + "/" + progname + '.sln'
510                         sln = self.MSVSProject(target = builddir + "/" + progname + '.sln',
511                                          projects= vcp,
512                                          variant = 'Release')
513                         SConsEnvironment.Default(self, sln)
514                 program_list.append(prog)
515                 if  lenv['OURPLATFORM']=='darwin':
516                         lenv['BINARYKIND'] = binarykind
517                         lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print))
518                 return prog
519
520         def Glob(lenv, pattern):
521                 path = string.replace(GetBuildPath(lenv,'SConscript'),'SConscript', '')
522                 files = []
523                 for i in glob.glob(path + pattern):
524                         files.append(string.replace(i, path, ''))
525                 return files