From c5198030ef23668414d1610dd0bfe0150a574ce1 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 9 Mar 2021 10:58:15 +0200 Subject: [PATCH] Add macOS ARM64 (Apple Silicon) support. --- .github/workflows/ci.yml | 2 +- SConstruct | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 129afd9a19..a4347ee509 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,7 +128,7 @@ jobs: - name: Build godot-cpp run: | - scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu) + scons target=release macos_arch=x86_64 generate_bindings=yes -j $(sysctl -n hw.logicalcpu) - name: Upload artifact uses: actions/upload-artifact@v2.2.2 diff --git a/SConstruct b/SConstruct index 3d9863cd57..7aeede8070 100644 --- a/SConstruct +++ b/SConstruct @@ -149,6 +149,12 @@ opts.Add(EnumVariable( 'arm64', ['armv7', 'arm64', 'x86_64'] )) +opts.Add(EnumVariable( + 'macos_arch', + 'Target macOS architecture', + 'universal', + ['universal', 'arm64', 'x86_64'] +)) opts.Add(BoolVariable( 'ios_simulator', 'Target iOS Simulator', @@ -217,14 +223,28 @@ elif env['platform'] == 'osx': 'Only 64-bit builds are supported for the macOS target.' ) - env.Append(CCFLAGS=['-std=c++14', '-arch', 'x86_64']) + if env['macos_arch'] == 'universal': + env.Append(CCFLAGS=['-std=c++14', '-arch', 'x86_64', '-arch', 'arm64']) + else: + env.Append(CCFLAGS=['-std=c++14', '-arch', env['macos_arch']]) if env['macos_deployment_target'] != 'default': env.Append(CCFLAGS=['-mmacosx-version-min=' + env['macos_deployment_target']]) + if env['macos_arch'] == 'universal': + env.Append(LINKFLAGS=[ + '-arch', + 'x86_64', + '-arch', + 'arm64' + ]) + else: + env.Append(LINKFLAGS=[ + '-arch', + env['macos_arch'] + ]) + env.Append(LINKFLAGS=[ - '-arch', - 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup',