From 81849e7c9dcd7c41df0b309a04fed34429580748 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 31 Aug 2019 14:24:52 +0200 Subject: Buildbot: support building releases, make non-releases more consistent * Auto detect rc and release version cycle in BKE_blender_version.h. * On Windows, generate zip and installer if a release is detected. * On macOS, always generate a dmg instead of zip. * Use standard package names without hash if a release is detected. * Buildbot package names now match platform names in releases. Ref T67056 Differential Revision: https://developer.blender.org/D5643 --- build_files/buildbot/buildbot_utils.py | 20 ++++++++++ build_files/buildbot/slave_pack.py | 68 +++++++++++++++++++++++----------- 2 files changed, 66 insertions(+), 22 deletions(-) (limited to 'build_files') diff --git a/build_files/buildbot/buildbot_utils.py b/build_files/buildbot/buildbot_utils.py index 653f8ac2d97..6891b91aa1e 100644 --- a/build_files/buildbot/buildbot_utils.py +++ b/build_files/buildbot/buildbot_utils.py @@ -66,8 +66,28 @@ class VersionInfo: version_number = int(self._parse_header_file(blender_h, 'BLENDER_VERSION')) self.version = "%d.%d" % (version_number // 100, version_number % 100) + self.version_char = self._parse_header_file(blender_h, 'BLENDER_VERSION_CHAR') + self.version_cycle = self._parse_header_file(blender_h, 'BLENDER_VERSION_CYCLE') + self.version_cycle_number = self._parse_header_file(blender_h, 'BLENDER_VERSION_CYCLE_NUMBER') self.hash = self._parse_header_file(buildinfo_h, 'BUILD_HASH')[1:-1] + if self.version_cycle == "release": + # Final release + self.full_version = self.version + self.version_char + self.is_development_build = False + elif self.version_cycle == "rc": + # Release candidate + version_cycle = self.version_cycle + self.version_cycle_number + if len(self.version_char) == 0: + self.full_version = self.version + version_cycle + else: + self.full_version = self.version + self.version_char + '-' + version_cycle + self.is_development_build = False + else: + # Development build + self.full_version = self.version + '-' + self.hash + self.is_development_build = True + def _parse_header_file(self, filename, define): import re regex = re.compile("^#\s*define\s+%s\s+(.*)" % define) diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index b81b12c0af4..45331cce61f 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -29,15 +29,15 @@ import sys def get_package_name(builder, platform=None): info = buildbot_utils.VersionInfo(builder) - package_name = 'blender-' + info.version + '-' + info.hash + package_name = 'blender-' + info.full_version if platform: package_name += '-' + platform - if builder.branch != 'master': + if builder.branch != 'master' and info.is_development_build: package_name = builder.branch + "-" + package_name return package_name -def create_buildbot_upload_zip(builder, package_filepath, package_filename): +def create_buildbot_upload_zip(builder, package_files): import zipfile buildbot_upload_zip = os.path.join(builder.upload_dir, "buildbot_upload.zip") @@ -46,7 +46,8 @@ def create_buildbot_upload_zip(builder, package_filepath, package_filename): try: z = zipfile.ZipFile(buildbot_upload_zip, "w", compression=zipfile.ZIP_STORED) - z.write(package_filepath, arcname=package_filename) + for filepath, filename in package_files: + z.write(filepath, arcname=filename) z.close() except Exception as ex: sys.stderr.write('Create buildbot_upload.zip failed: ' + str(ex) + '\n') @@ -74,38 +75,61 @@ def cleanup_files(dirpath, extension): if os.path.isfile(filepath) and f.endswith(extension): os.remove(filepath) -def find_file(dirpath, extension): - for f in os.listdir(dirpath): - filepath = os.path.join(dirpath, f) - if os.path.isfile(filepath) and f.endswith(extension): - return f - return None - def pack_mac(builder): + info = buildbot_utils.VersionInfo(builder) + os.chdir(builder.build_dir) - cleanup_files(builder.build_dir, '.zip') + cleanup_files(builder.build_dir, '.dmg') - package_name = get_package_name(builder, 'OSX-10.9-x86_64') - package_filename = package_name + '.zip' + package_name = get_package_name(builder, 'macOS') + package_filename = package_name + '.dmg' + package_filepath = os.path.join(builder.build_dir, package_filename) + + release_dir = os.path.join(builder.blender_dir, 'release', 'darwin') + bundle_sh = os.path.join(release_dir, 'bundle.sh') + if info.is_development_build: + background_image = os.path.join(release_dir, 'buildbot', 'background.tif') - buildbot_utils.call(['cpack', '-G', 'ZIP']) - package_filepath = find_file(builder.build_dir, '.zip') + command = [bundle_sh] + command += ['--source', builder.install_dir] + command += ['--dmg', package_filepath] + command += ['--background-image', background_image] + buildbot_utils.call(command) - create_buildbot_upload_zip(builder, package_filepath, package_filename) + create_buildbot_upload_zip(builder, [(package_filepath, package_filename)]) def pack_win(builder): + info = buildbot_utils.VersionInfo(builder) + os.chdir(builder.build_dir) cleanup_files(builder.build_dir, '.zip') - package_name = get_package_name(builder, 'win' + str(builder.bits)) + # CPack will add the platform name + cpack_name = get_package_name(builder, None) + package_name = get_package_name(builder, 'windows' + str(builder.bits)) + + command = ['cmake', '-DCPACK_OVERRIDE_PACKAGENAME:STRING=' + cpack_name, '.'] + buildbot_utils.call(builder.command_prefix + command) + command = ['cpack', '-G', 'ZIP'] + buildbot_utils.call(builder.command_prefix + command) + package_filename = package_name + '.zip' + package_filepath = os.path.join(builder.build_dir, package_filename) + package_files = [(package_filepath, package_filename)] + + if info.version_cycle == 'release': + # Installer only for final release builds, otherwise will get + # 'this product is already installed' messages. + command = ['cpack', '-G', 'WIX'] + buildbot_utils.call(builder.command_prefix + command) - buildbot_utils.call(['cpack', '-G', 'ZIP']) - package_filepath = find_file(builder.build_dir, '.zip') + package_filename = package_name + '.msi' + package_filepath = os.path.join(builder.build_dir, package_filename) + package_files += [(package_filepath, package_filename)] - create_buildbot_upload_zip(builder, package_filepath, package_filename) + create_buildbot_upload_zip(builder, package_files) def pack_linux(builder): @@ -147,7 +171,7 @@ def pack_linux(builder): create_tar_bz2(builder.install_dir, package_filepath, package_name) # Create buildbot_upload.zip - create_buildbot_upload_zip(builder, package_filepath, package_filename) + create_buildbot_upload_zip(builder, [(package_filepath, package_filename)]) if __name__ == "__main__": -- cgit v1.2.3