Build: move "make update" on macOS and Linux to Python script
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 20 Aug 2019 10:05:03 +0000 (12:05 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 30 Aug 2019 15:57:18 +0000 (17:57 +0200)
Differential Revision: https://developer.blender.org/D5545

GNUmakefile
build_files/utils/make_update.py [new file with mode: 0755]

index d17596d203d67b857c77f75078ad3ce45fad48c1..92d1efca21d0d76f0b9a806fdb118a95330b43bf 100644 (file)
@@ -531,17 +531,7 @@ icons_geom: .FORCE
            "$(BLENDER_DIR)/release/datafiles/blender_icons_geom_update.py"
 
 update: .FORCE
-       if [ "$(OS_NCASE)" = "darwin" ] && [ ! -d "../lib/$(OS_NCASE)" ]; then \
-               svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/$(OS_NCASE) ../lib/$(OS_NCASE) ; \
-       fi
-       if [ -d "../lib" ]; then \
-               svn cleanup ../lib/* ; \
-               svn update ../lib/* ; \
-       fi
-       git pull --rebase
-       git submodule update --init --recursive
-       git submodule foreach git checkout master
-       git submodule foreach git pull --rebase origin master
+       python3 ./build_files/utils/make_update.py
 
 format: .FORCE
        PATH="../lib/${OS_NCASE}/llvm/bin/:$(PATH)" \
diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py
new file mode 100755 (executable)
index 0000000..d737c37
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+
+import os
+import re
+import subprocess
+import sys
+
+def call(cmd):
+    print(" ".join(cmd))
+    retcode = subprocess.call(cmd)
+    if retcode != 0:
+      sys.exit(retcode)
+
+def print_stage(text):
+    print("")
+    print(text)
+    print("")
+
+# Setup for precompiled libraries and tests from svn
+lib_dirpath = os.path.join('..', 'lib')
+svn_url = "https://svn.blender.org/svnroot/bf-blender/trunk/lib/"
+
+# Checkout precompiled libraries
+if sys.platform == 'darwin':
+    lib_platform = "darwin"
+elif sys.platform == 'win32':
+    # Windows checkout is usually handled by bat scripts since python3 to run
+    # this script is bundled as part of the precompiled libraries. However it
+    # is used by the buildbot.
+    lib_platform = "win64_vc14"
+else:
+    # No precompiled libraries for Linux.
+    lib_platform = None
+
+if lib_platform:
+    lib_platform_dirpath = os.path.join(lib_dirpath, lib_platform)
+
+    if not os.path.exists(lib_platform_dirpath):
+        print_stage("Checking out Precompiled Libraries")
+
+        svn_url_platform = svn_url + lib_platform
+        call(["svn", "checkout", svn_url_platform, lib_platform_dirpath])
+
+# Update precompiled libraries and tests
+print_stage("Updating Precompiled Libraries and Tests")
+
+if os.path.isdir(lib_dirpath):
+  for dirname in os.listdir(lib_dirpath):
+    if dirname == ".svn":
+        continue
+
+    dirpath = os.path.join(lib_dirpath, dirname)
+    svn_dirpath = os.path.join(dirpath, ".svn")
+    svn_root_dirpath = os.path.join(lib_dirpath, ".svn")
+
+    if os.path.isdir(dirpath) and \
+       (os.path.exists(svn_dirpath) or os.path.exists(svn_root_dirpath)):
+        call(["svn", "cleanup", dirpath])
+        call(["svn", "update", dirpath])
+
+# Update blender repository and submodules
+print_stage("Updating Blender Git Repository and Submodules")
+
+call(["git", "pull", "--rebase"])
+call(["git", "submodule", "update", "--init", "--recursive"])
+call(["git", "submodule", "foreach", "git", "checkout", "master"])
+call(["git", "submodule", "foreach", "git", "pull", "--rebase", "origin", "master"])