diff options
Diffstat (limited to 'build_files/scons')
-rw-r--r-- | build_files/scons/tools/btools.py | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 4554cad055d..3e1f497bec0 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -56,10 +56,16 @@ def get_version(): raise Exception("%s: missing version string" % fname) +def get_revision(): + build_rev = os.popen('svnversion').read()[:-1] # remove \n + if build_rev == '' or build_rev==None: + build_rev = 'UNKNOWN' + + return 'r' + build_rev # This is used in creating the local config directories VERSION, VERSION_DISPLAY = get_version() - +REVISION = get_revision() def print_arguments(args, bc): if len(args): @@ -175,7 +181,7 @@ def print_targets(targs, bc): def validate_targets(targs, bc): valid_list = ['.', 'blender', 'blenderstatic', 'blenderplayer', 'webplugin', 'blendernogame', 'blenderstaticnogame', 'blenderlite', 'release', - 'everything', 'clean', 'install-bin', 'install', 'nsis'] + 'everything', 'clean', 'install-bin', 'install', 'nsis','buildslave'] oklist = [] for t in targs: if t in valid_list: @@ -496,6 +502,67 @@ def read_opts(env, cfg, args): return localopts +def buildbot_zip(src, dest, package_name, extension): + import zipfile + ln = len(src)+1 # one extra to remove leading os.sep when cleaning root for package_root + flist = list() + + # create list of tuples containing file and archive name + for root, dirs, files in os.walk(src): + package_root = os.path.join(package_name, root[ln:]) + flist.extend([(os.path.join(root, file), os.path.join(package_root, file)) for file in files]) + + if extension == '.zip': + package = zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED) + package.comment = package_name + ' is a zip-file containing the Blender software. Visit http://www.blender.org for more information.' + for entry in flist: + package.write(entry[0], entry[1]) + package.close() + else: + import tarfile + package = tarfile.open(dest, 'w:bz2') + for entry in flist: + package.add(entry[0], entry[1], recursive=False) + package.close() + bb_zip_name = os.path.normpath(src + os.sep + '..' + os.sep + 'buildbot_upload.zip') + print("creating %s" % (bb_zip_name)) + bb_zip = zipfile.ZipFile(bb_zip_name, 'w', zipfile.ZIP_DEFLATED) + print("writing %s to %s" % (dest, bb_zip_name)) + bb_zip.write(dest, os.path.split(dest)[1]) + bb_zip.close() + print("done.") + +def buildslave_print(target, source, env): + return "Running buildslave target" + +def buildslave(target=None, source=None, env=None): + """ + Builder for buildbot integration. Used by buildslaves of http://builder.blender.org only. + """ + + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'): + extension = '.zip' + else: + extension = '.tar.bz2' + + outdir = os.path.abspath(env['BF_INSTALLDIR']) + package_name = 'blender-' + env['OURPLATFORM'].split('-')[0] + '-'+VERSION+'-'+REVISION + package_dir = os.path.normpath(outdir + os.sep + '..' + os.sep + package_name) + package_archive = os.path.normpath(outdir + os.sep + '..' + os.sep + package_name + extension) + + try: + if os.path.exists(package_archive): + os.remove(package_archive) + if os.path.exists(package_dir): + shutil.rmtree(package_dir) + except Exception, ex: + sys.stderr.write('Failed to clean up old package files: ' + str(ex) + '\n') + return 1 + + buildbot_zip(outdir, package_archive, package_name, extension) + + return 0 + def NSIS_print(target, source, env): return "Creating NSIS installer for Blender" |