def BlenderProg(self=None, builddir=None, progname=None, sources=None, libs=None, libpath=None, binarykind=''): global vcp print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC lenv = self.Clone() lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS']) if lenv['OURPLATFORM'] in ('win32-vc', 'cygwin', 'win64-vc'): if lenv['BF_DEBUG']: lenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:'+progname+'.pdb','/NODEFAULTLIB:libcmt']) if lenv['OURPLATFORM']=='linux': if lenv['WITH_BF_PYTHON']: lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS']) if lenv['OURPLATFORM']=='sunos5': if lenv['WITH_BF_PYTHON']: lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS']) if lenv['CXX'].endswith('CC'): lenv.Replace(LINK = '$CXX') if lenv['OURPLATFORM']=='darwin': if lenv['WITH_BF_PYTHON']: lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS']) lenv.Append(LINKFLAGS = lenv['BF_OPENGL_LINKFLAGS']) if lenv['BF_PROFILE']: lenv.Append(LINKFLAGS = lenv['BF_PROFILE_LINKFLAGS']) if root_build_dir[0]==os.sep or root_build_dir[1]==':': lenv.Append(LIBPATH=root_build_dir + '/lib') lenv.Append(LIBPATH=libpath) lenv.Append(LIBS=libs) if lenv['WITH_BF_QUICKTIME']: lenv.Append(LIBS = lenv['BF_QUICKTIME_LIB']) lenv.Append(LIBPATH = lenv['BF_QUICKTIME_LIBPATH']) prog = lenv.Program(target=builddir+'bin/'+progname, source=sources) if lenv['BF_DEBUG'] and lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc') and lenv['BF_BSC']: f = lenv.File(progname + '.bsc', builddir) brs = lenv.Command(f, prog, [bsc]) SConsEnvironment.Default(self, brs) SConsEnvironment.Default(self, prog) if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc') and progname == 'blender': print "! ",builddir + "/" + progname + '.sln' sln = self.MSVSProject(target = builddir + "/" + progname + '.sln', projects= vcp, variant = 'Release') SConsEnvironment.Default(self, sln) program_list.append(prog) if lenv['OURPLATFORM']=='darwin': lenv['BINARYKIND'] = binarykind lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print)) elif os.sep == '/' and lenv['OURPLATFORM'] != 'linuxcross': # any unix (except cross-compilation) if lenv['WITH_BF_PYTHON']: if not lenv['WITHOUT_BF_INSTALL'] and not lenv['WITHOUT_BF_PYTHON_INSTALL'] and not BlenderEnvironment.PyBundleActionAdded: lenv.AddPostAction(prog,Action(UnixPyBundle,strfunction=my_unixpybundle_print)) BlenderEnvironment.PyBundleActionAdded = True elif lenv['OURPLATFORM'].startswith('win') or lenv['OURPLATFORM'] == 'linuxcross': # windows or cross-compilation if lenv['WITH_BF_PYTHON']: if not lenv['WITHOUT_BF_PYTHON_INSTALL'] and not BlenderEnvironment.PyBundleActionAdded: lenv.AddPostAction(prog,Action(WinPyBundle,strfunction=my_winpybundle_print)) BlenderEnvironment.PyBundleActionAdded = True return prog
def BlenderRes(self=None, libname=None, source=None, libtype=['core'], priority=[100]): global libs if not self or not libname or not source: print bc.FAIL+'Cannot continue. Missing argument for BlenderRes '+libname+bc.ENDC self.Exit() if self['OURPLATFORM'] not in ('win32-vc','win32-mingw','linuxcross', 'win64-vc', 'win64-mingw'): print bc.FAIL+'BlenderRes is for windows only!'+bc.END self.Exit() print bc.HEADER+'Configuring resource '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC lenv = self.Clone() if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'): res = lenv.RES('#'+root_build_dir+'lib/'+libname, source) else: res = lenv.RES(root_build_dir+'lib/'+libname, source) SConsEnvironment.Default(self, res) resources.append(res)
def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority=100, compileflags=None, cc_compileflags=None, cxx_compileflags=None, cc_compilerchange=None, cxx_compilerchange=None): global vcp # sanity check # run once in a while to check we dont have duplicates if 0: for name, dirs in (("source", sources), ("include", includes)): files_clean = [os.path.normpath(f) for f in dirs] files_clean_set = set(files_clean) if len(files_clean) != len(files_clean_set): for f in sorted(files_clean_set): if f != '.' and files_clean.count(f) > 1: raise Exception("Found duplicate %s %r" % (name, f)) del name, dirs, files_clean, files_clean_set, f # end sanity check if not self or not libname or not sources: print bc.FAIL + 'Cannot continue. Missing argument for BuildBlenderLib ' + libname + bc.ENDC self.Exit() def list_substring(quickie, libname): for q in quickie: if q in libname: return True return False if list_substring(quickie, libname) or len(quickie) == 0: if list_substring(quickdebug, libname): print bc.HEADER + 'Configuring library ' + bc.ENDC + bc.OKGREEN + libname + bc.ENDC + bc.OKBLUE + " (debug mode)" + bc.ENDC else: print bc.HEADER + 'Configuring library ' + bc.ENDC + bc.OKGREEN + libname + bc.ENDC lenv = self.Clone() lenv.Append(CPPPATH=includes) lenv.Append(CPPDEFINES=defines) if lenv['BF_DEBUG'] or (libname in quickdebug): lenv.Append(CFLAGS=lenv['BF_DEBUG_CFLAGS']) lenv.Append(CCFLAGS=lenv['BF_DEBUG_CCFLAGS']) lenv.Append(CXXFLAGS=lenv['BF_DEBUG_CXXFLAGS']) else: lenv.Append(CFLAGS=lenv['REL_CFLAGS']) lenv.Append(CCFLAGS=lenv['REL_CCFLAGS']) lenv.Append(CXXFLAGS=lenv['REL_CXXFLAGS']) if lenv['BF_PROFILE']: lenv.Append(CFLAGS=lenv['BF_PROFILE_CFLAGS']) lenv.Append(CCFLAGS=lenv['BF_PROFILE_CCFLAGS']) lenv.Append(CXXFLAGS=lenv['BF_PROFILE_CXXFLAGS']) if compileflags: lenv.Replace(CFLAGS=compileflags) if cc_compileflags: lenv.Replace(CCFLAGS=cc_compileflags) if cxx_compileflags: lenv.Replace(CXXFLAGS=cxx_compileflags) if cc_compilerchange: lenv.Replace(CC=cc_compilerchange) if cxx_compilerchange: lenv.Replace(CXX=cxx_compilerchange) lenv.Append(CFLAGS=lenv['C_WARN']) lenv.Append(CCFLAGS=lenv['CC_WARN']) lenv.Append(CXXFLAGS=lenv['CXX_WARN']) if lenv['OURPLATFORM'] == 'win64-vc': lenv.Append(LINKFLAGS=['/MACHINE:X64']) if lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc'): if lenv['BF_DEBUG']: lenv.Append(CCFLAGS=['/MTd']) else: lenv.Append(CCFLAGS=['/MT']) targetdir = root_build_dir + 'lib/' + libname if not (root_build_dir[0] == os.sep or root_build_dir[1] == ':'): targetdir = '#' + targetdir lib = lenv.Library(target=targetdir, source=sources) SConsEnvironment.Default( self, lib ) # we add to default target, because this way we get some kind of progress info during build if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc'): #if targetdir[0] == '#': # targetdir = targetdir[1:-1] print "! ", targetdir + '.vcproj' # + self['MSVSPROJECTSUFFIX'] vcproject = self.MSVSProject( target=targetdir + '.vcproj', # + self['MSVSPROJECTSUFFIX'], srcs=sources, buildtarget=lib, variant='Release', auto_build_solution=0) vcp.append(vcproject) SConsEnvironment.Default(self, vcproject) else: print bc.WARNING + 'Not building ' + bc.ENDC + bc.OKGREEN + libname + bc.ENDC + ' for ' + bc.OKBLUE + 'BF_QUICK' + bc.ENDC # note: libs is a global add_lib_to_dict(self, libs, libtype, libname, priority)
def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority=100, compileflags=None, cc_compileflags=None, cxx_compileflags=None): global vcp if not self or not libname or not sources: print bc.FAIL + 'Cannot continue. Missing argument for BuildBlenderLib ' + libname + bc.ENDC self.Exit() def list_substring(quickie, libname): for q in quickie: if libname.find(q) != -1: return True return False if list_substring(quickie, libname) or len(quickie) == 0: if list_substring(quickdebug, libname): print bc.HEADER + 'Configuring library ' + bc.ENDC + bc.OKGREEN + libname + bc.ENDC + bc.OKBLUE + " (debug mode)" + bc.ENDC else: print bc.HEADER + 'Configuring library ' + bc.ENDC + bc.OKGREEN + libname + bc.ENDC lenv = self.Clone() lenv.Append(CPPPATH=includes) lenv.Append(CPPDEFINES=defines) if lenv['BF_DEBUG'] or (libname in quickdebug): lenv.Append(CFLAGS=lenv['BF_DEBUG_CFLAGS']) lenv.Append(CCFLAGS=lenv['BF_DEBUG_CCFLAGS']) lenv.Append(CXXFLAGS=lenv['BF_DEBUG_CXXFLAGS']) else: lenv.Append(CFLAGS=lenv['REL_CFLAGS']) lenv.Append(CCFLAGS=lenv['REL_CCFLAGS']) lenv.Append(CXXFLAGS=lenv['REL_CXXFLAGS']) if lenv['BF_PROFILE']: lenv.Append(CFLAGS=lenv['BF_PROFILE_CFLAGS']) lenv.Append(CCFLAGS=lenv['BF_PROFILE_CCFLAGS']) lenv.Append(CXXFLAGS=lenv['BF_PROFILE_CXXFLAGS']) if compileflags: lenv.Replace(CFLAGS=compileflags) if cc_compileflags: lenv.Replace(CCFLAGS=cc_compileflags) if cxx_compileflags: lenv.Replace(CXXFLAGS=cxx_compileflags) lenv.Append(CFLAGS=lenv['C_WARN']) lenv.Append(CCFLAGS=lenv['CC_WARN']) lenv.Append(CXXFLAGS=lenv['CXX_WARN']) if lenv['OURPLATFORM'] == 'win64-vc': lenv.Append(LINKFLAGS=['/MACHINE:X64']) if lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc'): if lenv['BF_DEBUG']: lenv.Append(CCFLAGS=['/MTd']) else: lenv.Append(CCFLAGS=['/MT']) targetdir = root_build_dir + 'lib/' + libname if not (root_build_dir[0] == os.sep or root_build_dir[1] == ':'): targetdir = '#' + targetdir lib = lenv.Library(target=targetdir, source=sources) SConsEnvironment.Default( self, lib ) # we add to default target, because this way we get some kind of progress info during build if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc'): #if targetdir[0] == '#': # targetdir = targetdir[1:-1] print "! ", targetdir + '.vcproj' # + self['MSVSPROJECTSUFFIX'] vcproject = self.MSVSProject( target=targetdir + '.vcproj', # + self['MSVSPROJECTSUFFIX'], srcs=sources, buildtarget=lib, variant='Release', auto_build_solution=0) vcp.append(vcproject) SConsEnvironment.Default(self, vcproject) else: print bc.WARNING + 'Not building ' + bc.ENDC + bc.OKGREEN + libname + bc.ENDC + ' for ' + bc.OKBLUE + 'BF_QUICK' + bc.ENDC # note: libs is a global add_lib_to_dict(self, libs, libtype, libname, priority)