Skip to content

Commit

Permalink
Macos universal build (#99)
Browse files Browse the repository at this point in the history
* Added macos universal binary build.

Added a new macos_arch build option that allows specifying universal,
x86_64, or arm64 (apple silicon). This defaults to universal which
includes both x86_64 and arm64 builds.

* Changed godot and godot-cpp references to version 3.4 for CI script.

* Updated github runner to macos-11 for macos build.

The macos-latest runner still points to version 10.15, which doesn't
support the arm64 architecture for cross-compiling to create the
universal build.
  • Loading branch information
langfort authored Nov 25, 2021
1 parent 1273d53 commit 2729dd1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/all_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
env:
PROJECT_FOLDER: fmod-gdnative
TARGET: release
GODOT_VERSION: 3.3.4
UTOPIA_GODOT_CPP_REF: utopia-3.3.4-stable
GODOT_VERSION: 3.4
UTOPIA_GODOT_CPP_REF: godot-3.4-stable
FMOD_VERSION: 20203

jobs:
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Cloning godot-cpp
uses: actions/checkout@v2
with:
repository: utopia-rise/godot-cpp
repository: godotengine/godot-cpp
path: godot-cpp
ref: ${{env.UTOPIA_GODOT_CPP_REF}}
submodules: recursive
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
- name: Cloning godot-cpp
uses: actions/checkout@v2
with:
repository: utopia-rise/godot-cpp
repository: godotengine/godot-cpp
path: godot-cpp
ref: ${{env.UTOPIA_GODOT_CPP_REF}}
submodules: recursive
Expand All @@ -153,7 +153,8 @@ jobs:

macos-compilation:
name: MacOS Compilation
runs-on: "macos-latest"
# Use macos-11 since macos-latest still points to version 10.15, which doesn't support arm64
runs-on: "macos-11"
env:
FMOD_EXECUTABLE: fmodstudioapi20203osx.dmg
steps:
Expand Down Expand Up @@ -196,7 +197,7 @@ jobs:
- name: Cloning godot-cpp
uses: actions/checkout@v2
with:
repository: utopia-rise/godot-cpp
repository: godotengine/godot-cpp
path: godot-cpp
ref: ${{env.UTOPIA_GODOT_CPP_REF}}
submodules: recursive
Expand Down Expand Up @@ -264,7 +265,7 @@ jobs:
- name: Cloning godot-cpp
uses: actions/checkout@v2
with:
repository: utopia-rise/godot-cpp
repository: godotengine/godot-cpp
path: godot-cpp
ref: ${{env.UTOPIA_GODOT_CPP_REF}}
submodules: recursive
Expand Down Expand Up @@ -333,7 +334,7 @@ jobs:
- name: Cloning godot-cpp
uses: actions/checkout@v2
with:
repository: utopia-rise/godot-cpp
repository: godotengine/godot-cpp
path: godot-cpp
ref: ${{env.UTOPIA_GODOT_CPP_REF}}
submodules: recursive
Expand Down
20 changes: 16 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ opts.Add(
'Path to the FMOD library',
"../libs/fmod/"
)
opts.Add(EnumVariable(
'macos_arch',
'Target macOS architecture',
'universal',
['universal', 'x86_64', 'arm64']
))

env = Environment(ENV = os.environ)
opts.Update(env)
Expand Down Expand Up @@ -222,17 +228,23 @@ elif env['platform'] == 'osx':
'Only 64-bit builds are supported for the macOS target.'
)

env.Append(CCFLAGS=['-g', '-std=c++14', '-arch', 'x86_64'])
if env["macos_arch"] == "universal":
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
else:
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
env.Append(CCFLAGS=["-arch", env["macos_arch"]])

env.Append(CCFLAGS=['-std=c++14'])

env.Append(LINKFLAGS=[
'-arch',
'x86_64',
'-framework',
'Cocoa',
'-Wl,-undefined,dynamic_lookup',
])

if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og', 'g'])
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])

Expand Down

0 comments on commit 2729dd1

Please sign in to comment.