[Bf-blender-cvs] [81849e7c9dc] master: Buildbot: support building releases, make non-releases more consistent

Brecht Van Lommel noreply at git.blender.org
Tue Sep 3 12:29:15 CEST 2019


Commit: 81849e7c9dcd7c41df0b309a04fed34429580748
Author: Brecht Van Lommel
Date:   Sat Aug 31 14:24:52 2019 +0200
Branches: master
https://developer.blender.org/rB81849e7c9dcd7c41df0b309a04fed34429580748

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

===================================================================

M	build_files/buildbot/buildbot_utils.py
M	build_files/buildbot/slave_pack.py
A	release/darwin/buildbot/background.tif
M	release/darwin/bundle.sh
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/windowmanager/intern/wm_splash_screen.c

===================================================================

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__":
diff --git a/release/darwin/buildbot/background.tif b/release/darwin/buildbot/background.tif
new file mode 100644
index 00000000000..5253a6bf439
Binary files /dev/null and b/release/darwin/buildbot/background.tif differ
diff --git a/release/darwin/bundle.sh b/release/darwin/bundle.sh
index b0f489e6fc2..91ce4f61d37 100755
--- a/release/darwin/bundle.sh
+++ b/release/darwin/bundle.sh
@@ -54,6 +54,11 @@ while [[ $# -gt 0 ]]; do
             shift
             shift
             ;;
+        --background-image)
+            _background_image="$2"
+            shift
+            shift
+            ;;
         -h|--help)
             echo "Usage:"
             echo " $(basename "$0") --source DIR --dmg IMAGENAME "
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index db93193bfe3..65086f57616 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -37,6 +37,8 @@
 #define BLENDER_VERSION_CHAR
 /** alpha/beta/rc/release, docs use this. */
 #define BLENDER_VERSION_CYCLE alpha
+/** Optionally set to 1,2,... for example to to get alpha1 or rc2. */
+#define BLENDER_VERSION_CYCLE_NUMBER
 
 /** Defined in from blender.c */
 extern char versionstr[];
diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c
index 8629997030f..9cbcab9e3b2 100644
--- a/source/blender/windowmanager/intern/wm_splash_screen.c
+++ b/source/blender/windowmanager/intern/wm_splash_screen.c
@@ -139,6 +139,11 @@ static void wm_block_splash_add_labels(uiBlock *block, int x, int y)
                BLENDER_VERSION % 100,
                version_suffix);
 
+  const char *cycle_number_suffix = STRINGIFY(BLENDER_VERSION_CYCLE_NUMBER);
+  if (strlen(cycle_number_suffix)) {
+    BLI_snprintf(version_buf, sizeof(version_buf), "%s %s", version_buf, cycle_number_suffix);
+  }
+
   wm_block_splash_add_label(block, version_buf, x, &y);
 
 #ifdef WITH_BUILDINFO



More information about the Bf-blender-cvs mailing list