Skip to content

Commit

Permalink
Add macOS ARM64 (Apple Silicon) support.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed Mar 9, 2021
1 parent 55c0a2e commit c519803
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 23 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit c519803

Please sign in to comment.