From 89df4a46fcbbe11ca478418af59161c87ddbb9f1 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 4 Oct 2009 20:11:55 +0000 Subject: [PATCH] * Unzip python bundle at the end of the build process. Patch by b333rt, thanks! * remove /ARCH setting - is used only when building x86 --- config/win64-vc-config.py | 2 +- tools/Blender.py | 67 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/config/win64-vc-config.py b/config/win64-vc-config.py index 5bb01ff16b5..5f088489b34 100644 --- a/config/win64-vc-config.py +++ b/config/win64-vc-config.py @@ -164,7 +164,7 @@ CXX = 'cl.exe' CFLAGS = [] CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/wd4244', '/wd4305', '/wd4800', '/wd4065', '/wd4267'] CXXFLAGS = ['/EHsc'] -BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast', '/arch:SSE2'] +BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast'] BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr'] diff --git a/tools/Blender.py b/tools/Blender.py index 1b0573cfda4..04f2676deb3 100644 --- a/tools/Blender.py +++ b/tools/Blender.py @@ -327,6 +327,59 @@ def set_quiet_output(env): env['BUILDERS']['Library'] = static_lib env['BUILDERS']['Program'] = program + +def unzip_pybundle(from_zip,to_dir,exclude_re): + import zipfile + + zip= zipfile.ZipFile(from_zip, mode='r') + exclude_re= list(exclude_re) #single re object or list of re objects + debug= 0 #list files instead of unpacking + good= [] + if debug: print '\nFiles not being unpacked:\n' + for name in zip.namelist(): + is_bad= 0 + for r in exclude_re: + if r.match(name): + is_bad=1 + if debug: print name + break + if not is_bad: + good.append(name) + if debug: + print '\nFiles being unpacked:\n' + for g in good: + print g + else: + zip.extractall(to_dir, good) + +def my_winpybundle_print(target, source, env): + pass + +def WinPyBundle(target=None, source=None, env=None): + import shutil, re + py_zip= env.subst( env['LCGDIR'] ) + if py_zip[0]=='#': + py_zip= py_zip[1:] + py_zip+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '.zip' + + py_target = env.subst( env['BF_INSTALLDIR'] ) + if py_target[0]=='#': + py_target=py_target[1:] + py_target+= '/.blender/python/lib/' + def printexception(func,path,ex): + if os.path.exists(path): #do not report if path does not exist. eg on a fresh build. + print str(func) + ' failed on ' + str(path) + print "Trying to remove existing py bundle." + shutil.rmtree(py_target, False, printexception) + exclude_re=[re.compile('.*/test/.*'), + re.compile('^config/.*'), + re.compile('^distutils/.*'), + re.compile('^idlelib/.*'), + re.compile('^lib2to3/.*'), + re.compile('^tkinter/.*')] + print "Unpacking '" + py_zip + "' to '" + py_target + "'" + unzip_pybundle(py_zip,py_target,exclude_re) + def my_appit_print(target, source, env): a = '%s' % (target[0]) d, f = os.path.split(a) @@ -392,10 +445,10 @@ def AppIt(target=None, source=None, env=None): # extract copy system python, be sure to update other build systems # when making changes to the files that are copied. -def my_pyinst_print(target, source, env): +def my_unixpybundle_print(target, source, env): pass -def PyInstall(target=None, source=None, env=None): +def UnixPyBundle(target=None, source=None, env=None): # Any Unix except osx #-- .blender/python/lib/python3.1 @@ -522,6 +575,9 @@ class BlenderEnvironment(SConsEnvironment): 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']) @@ -602,8 +658,11 @@ class BlenderEnvironment(SConsEnvironment): elif os.sep == '/': # any unix if lenv['WITH_BF_PYTHON']: if not lenv['WITHOUT_BF_INSTALL'] and not lenv['WITHOUT_BF_PYTHON_INSTALL']: - lenv.AddPostAction(prog,Action(PyInstall,strfunction=my_pyinst_print)) - + lenv.AddPostAction(prog,Action(UnixPyBundle,strfunction=my_unixpybundle_print)) + elif lenv['OURPLATFORM'].startswith('win'): # windows + if lenv['WITH_BF_PYTHON']: + if not lenv['WITHOUT_BF_PYTHON_INSTALL']: + lenv.AddPostAction(prog,Action(WinPyBundle,strfunction=my_winpybundle_print)) return prog def Glob(lenv, pattern):