Skip to content

Commit

Permalink
Merge pull request #60 from bruvzg/macos_m1
Browse files Browse the repository at this point in the history
Add macOS ARM64 (Apple Silicon) support.
  • Loading branch information
twaritwaikar authored Sep 28, 2021
2 parents d598850 + 094424c commit e9f0844
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
scons platform=windows target=release
build-macos-debug:
runs-on: macos-latest
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- name: macOS Debug
Expand All @@ -64,7 +64,7 @@ jobs:
scons platform=osx target=debug use_llvm=yes
build-macos-release:
runs-on: macos-latest
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- name: macOS Release
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/godotengine/godot-cpp
branch = 3.x
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ Required build tools:
2. Run ```. ./build_libs_mac.sh Release```.
3. Run ```scons platform=osx target=release```.

**Note:** [Compiling for the Apple Silicon architecture is not supported yet.](https://github.com/godotengine/godot-git-plugin/issues/68)

#### Debug build

Replace `Release` with `Debug` and `release` with `debug` in the above instructions for a debug build. You will also have to do the same in the paths mentioned in `demo/git_api.gdnlib` before opening the demo project in Godot.
13 changes: 8 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ if env['platform'] == "osx":
cpp_library += '.osx'
libgit2_lib_path += 'osx/'
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64', '-arch', 'arm64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-arch', 'arm64'])
else:
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-arch', 'arm64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-arch', 'arm64'])

elif env['platform'] in ('x11', 'linux'):
env['target_path'] += 'x11/'
Expand Down Expand Up @@ -82,7 +82,10 @@ else:
cpp_library += '.release'
env['target_path'] += 'release/'

cpp_library += '.' + str(bits)
if env['platform'] == 'osx':
cpp_library += '.universal'
else:
cpp_library += '.' + str(bits)

# make sure our binding library properly includes
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
Expand Down
11 changes: 9 additions & 2 deletions build_libs_mac.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/sh
git submodule init;
git submodule update --init --recursive;

cd godot-git-plugin/thirdparty/libgit2/
mkdir build
cd build/
rm -f CMakeCache.txt
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DUSE_ICONV=OFF
cmake .. -DCMAKE_C_FLAGS="-arch arm64 -arch x86_64" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DUSE_ICONV=OFF
cmake --build . --config $1
cd ../../../../
mkdir -p "demo/bin/osx/"
Expand All @@ -20,5 +21,11 @@ fi

cd godot-cpp/;
CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
scons platform=osx target=$1 generate_bindings=yes bits=64 -j$CORES;
scons platform=osx target=$1 generate_bindings=yes macos_arch=x86_64 -j$CORES;
scons platform=osx target=$1 generate_bindings=yes macos_arch=arm64 -j$CORES;
shopt -s nocasematch; if [[ "release" =~ "$1" ]]; then
lipo -create ./bin/libgodot-cpp.osx.release.64.a ./bin/libgodot-cpp.osx.release.arm64.a -output ./bin/libgodot-cpp.osx.release.universal.a
else
lipo -create ./bin/libgodot-cpp.osx.debug.64.a ./bin/libgodot-cpp.osx.debug.arm64.a -output ./bin/libgodot-cpp.osx.debug.universal.a
fi
cd ..
2 changes: 1 addition & 1 deletion godot-cpp
Submodule godot-cpp updated 56 files
+46 −19 .github/workflows/ci.yml
+1 −0 .gitignore
+2 −2 CMakeLists.txt
+27 −13 README.md
+40 −7 SConstruct
+34 −30 binding_generator.py
+1 −1 godot-headers
+30 −0 include/core/AABB.hpp
+30 −0 include/core/Array.hpp
+30 −0 include/core/Basis.hpp
+30 −0 include/core/CameraMatrix.hpp
+30 −0 include/core/Color.hpp
+30 −0 include/core/CoreTypes.hpp
+31 −3 include/core/Defs.hpp
+30 −0 include/core/Dictionary.hpp
+44 −1 include/core/Godot.hpp
+30 −0 include/core/GodotGlobal.hpp
+30 −0 include/core/GodotProfiling.hpp
+51 −0 include/core/Math.hpp
+30 −0 include/core/NodePath.hpp
+30 −0 include/core/Plane.hpp
+30 −0 include/core/PoolArrays.hpp
+30 −0 include/core/Quat.hpp
+30 −0 include/core/RID.hpp
+30 −0 include/core/Rect2.hpp
+30 −0 include/core/Ref.hpp
+34 −2 include/core/String.hpp
+30 −0 include/core/TagDB.hpp
+30 −0 include/core/Transform.hpp
+30 −0 include/core/Transform2D.hpp
+30 −2 include/core/Variant.hpp
+30 −0 include/core/Vector2.hpp
+30 −0 include/core/Vector3.hpp
+30 −0 include/core/Wrapped.hpp
+30 −0 src/core/AABB.cpp
+30 −0 src/core/Array.cpp
+30 −0 src/core/Basis.cpp
+5 −5 src/core/CameraMatrix.cpp
+30 −0 src/core/Color.cpp
+30 −0 src/core/Dictionary.cpp
+30 −0 src/core/GodotGlobal.cpp
+30 −0 src/core/NodePath.cpp
+30 −0 src/core/Plane.cpp
+30 −0 src/core/PoolArrays.cpp
+30 −0 src/core/Quat.cpp
+30 −0 src/core/RID.cpp
+30 −0 src/core/Rect2.cpp
+41 −2 src/core/String.cpp
+30 −0 src/core/TagDB.cpp
+30 −0 src/core/Transform.cpp
+30 −0 src/core/Transform2D.cpp
+30 −2 src/core/Variant.cpp
+33 −3 src/core/Vector2.cpp
+31 −1 src/core/Vector3.cpp
+1 −0 test/SConstruct
+30 −0 test/src/init.cpp
2 changes: 2 additions & 0 deletions godot-git-plugin/src/git_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef GIT_COMMON_H
#define GIT_COMMON_H

#include <cstdio>

#include <Godot.hpp>

#include <git2.h>
Expand Down

0 comments on commit e9f0844

Please sign in to comment.