From a091c57fc55b09459611870fa9c0a711c8713b14 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 17 Feb 2023 11:44:02 +0100 Subject: [PATCH 1/2] Make update: Add --architecture command line attribute Possible values are x86_64 and arm64. Allows to use make_update.py in a cross-compile environment, like building x86_64 macOS Blender from Apple Silicon machine. --- build_files/utils/make_update.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py index a6fecdce54f..49ff472ea3d 100755 --- a/build_files/utils/make_update.py +++ b/build_files/utils/make_update.py @@ -42,6 +42,7 @@ def parse_arguments() -> argparse.Namespace: parser.add_argument("--svn-branch", default=None) parser.add_argument("--git-command", default="git") parser.add_argument("--use-linux-libraries", action="store_true") + parser.add_argument("--architecture", type=str, choices=("x86_64", "arm64",)) return parser.parse_args() @@ -51,6 +52,18 @@ def get_blender_git_root() -> str: # Setup for precompiled libraries and tests from svn. +def get_effective_architecture(args: argparse.Namespace): + if args.architecture: + return args.architecture + + machine_lower = platform.machine().lower() + + if "ARM64" in platform.version(): + return "arm64" + + return machine_lower + + def svn_update(args: argparse.Namespace, release_version: Optional[str]) -> None: svn_non_interactive = [args.svn_command, '--non-interactive'] @@ -58,11 +71,12 @@ def svn_update(args: argparse.Namespace, release_version: Optional[str]) -> None svn_url = make_utils.svn_libraries_base_url(release_version, args.svn_branch) # Checkout precompiled libraries + architecture = get_effective_architecture(args) if sys.platform == 'darwin': # Check platform.version to detect arm64 with x86_64 python binary. - if platform.machine() == 'arm64' or ('ARM64' in platform.version()): + if architecture == 'arm64': lib_platform = "darwin_arm64" - elif platform.machine() == 'x86_64': + elif architecture == 'x86_64': lib_platform = "darwin" else: lib_platform = None -- 2.30.2 From 240c36ccbfb06f33c3bc48b1c339e168623f133a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 17 Feb 2023 13:01:33 +0100 Subject: [PATCH 2/2] Move comment to the function, so it stays close with the code. --- build_files/utils/make_update.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py index 49ff472ea3d..c5e3a5fafe6 100755 --- a/build_files/utils/make_update.py +++ b/build_files/utils/make_update.py @@ -56,12 +56,11 @@ def get_effective_architecture(args: argparse.Namespace): if args.architecture: return args.architecture - machine_lower = platform.machine().lower() - + # Check platform.version to detect arm64 with x86_64 python binary. if "ARM64" in platform.version(): return "arm64" - return machine_lower + return platform.machine().lower() def svn_update(args: argparse.Namespace, release_version: Optional[str]) -> None: @@ -73,7 +72,6 @@ def svn_update(args: argparse.Namespace, release_version: Optional[str]) -> None # Checkout precompiled libraries architecture = get_effective_architecture(args) if sys.platform == 'darwin': - # Check platform.version to detect arm64 with x86_64 python binary. if architecture == 'arm64': lib_platform = "darwin_arm64" elif architecture == 'x86_64': -- 2.30.2