diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e12071..cf10db5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: path: | demo/ - macos: + macos-x64: runs-on: macos-11 steps: - uses: actions/checkout@v2 @@ -50,11 +50,28 @@ jobs: run: | git submodule update --init --recursive brew install scons openssl@1.1 - scons platform=osx target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json macos_arch=x86_64 use_llvm=yes -j $(sysctl -n hw.logicalcpu) + scons platform=osx target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json macos_arch=x86_64 macos_ssl_path=/usr/local/opt/openssl@1.1/ use_llvm=yes -j $(sysctl -n hw.logicalcpu) otool -L demo/addons/godot-git-plugin/osx/libgitapi.dylib - uses: actions/upload-artifact@v2 with: - name: godot-git-plugin-macos-release-${{ github.sha }} + name: godot-git-plugin-macos-release-x64-${{ github.sha }} + if-no-files-found: error + path: | + demo/ + + macos-arm64: + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - name: build-macos-release + run: | + git submodule update --init --recursive + brew install scons openssl@1.1 + scons platform=osx target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json macos_arch=arm64 macos_ssl_path=/usr/local/opt/openssl@1.1/ use_llvm=yes -j $(sysctl -n hw.logicalcpu) + otool -L demo/addons/godot-git-plugin/osx/libgitapi.dylib + - uses: actions/upload-artifact@v2 + with: + name: godot-git-plugin-macos-release-arm64-${{ github.sha }} if-no-files-found: error path: | demo/ diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index ed78090..bda9652 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -1,6 +1,6 @@ name: clang-format -on: [push] +on: [push, pull_request] jobs: clang-format: diff --git a/README.md b/README.md index 2a65a87..35c9fd7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This section onwards is only meant to be used if you intend to compile the plugi - [SCons](https://scons.org/pages/download.html) (v3.0.1+) - C++17 and C90 compilers detectable by SCons and present in `PATH`. -- For Mac users, `brew install openssl@1.1` +- For Mac users, run `brew install openssl` and use the `macos_ssl_path` SCons argument. - For Linux users, `sudo apt-get install libssl-dev`, or local package manager equivalent. ### Build diff --git a/SConstruct b/SConstruct index f93c554..ceba3ea 100644 --- a/SConstruct +++ b/SConstruct @@ -27,6 +27,8 @@ opts.Add(PathVariable("target_name", "The library name.", opts.Add(EnumVariable("bits", "The bit architecture.", "64", ["64"])) opts.Add(EnumVariable("macos_arch", "Target macOS architecture", "universal", ["universal", "x86_64", "arm64"])) +opts.Add(PathVariable("macos_ssl_path", "Path to OpenSSL libraries - only used in macOS builds.", + "/usr/local/opt/openssl/", PathVariable.PathAccept)) # Updates the environment with the option variables. opts.Update(env) diff --git a/godot-git-plugin/SCsub b/godot-git-plugin/SCsub index 376246e..097b2d7 100644 --- a/godot-git-plugin/SCsub +++ b/godot-git-plugin/SCsub @@ -32,9 +32,6 @@ if env["platform"] == "osx": env["target_path"] += "osx/" cpp_library += ".osx" - env.Prepend(LIBPATH=["/usr/local/opt/openssl@1.1/lib/"]) - env.Append(LIBS=["ssl", "crypto"]) - if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-g", "-O2", "-std=c++17"]) else: diff --git a/thirdparty/git2/SCsub b/thirdparty/git2/SCsub index 3ec90e7..c95eff5 100644 --- a/thirdparty/git2/SCsub +++ b/thirdparty/git2/SCsub @@ -131,6 +131,13 @@ if env_git["platform"] in ["linux", "osx"]: ) if env_git["platform"] == "osx": - env_git.Prepend(CPPPATH=["/usr/local/opt/openssl@1.1/include/"]) + # We link to OpenSSL dynamically only on macOS to allow universal builds + env_git.Prepend( + CPPDEFINES=[ + "CRYPT_OPENSSL_DYNAMIC", + ("GIT_OPENSSL_DYNAMIC", "1"), + ] + ) + env_git.Prepend(CPPPATH=[env_git["macos_ssl_path"] + "include/"]) env_git.StaticLibrary(target="../bin/" + "git2", source=libgit2_sources) diff --git a/thirdparty/ssh2/SCsub b/thirdparty/ssh2/SCsub index 52786f1..18d8d83 100644 --- a/thirdparty/ssh2/SCsub +++ b/thirdparty/ssh2/SCsub @@ -105,12 +105,17 @@ if env_ssh2["platform"] in ["linux", "osx"]: ) if env_ssh2["platform"] == "osx": + env_ssh2.Append(CPPPATH=[env_ssh2["macos_ssl_path"] + "include/"]) + + # We only link to OpenSSL dynamic libraries on macOS when we are + # doing a universal build, otherwise we do a static link if env_ssh2["macos_arch"] == "universal": env_ssh2.Append(CPPDEFINES=[ ("WORDS_BIGENDIAN", "1"), ("AC_APPLE_UNIVERSAL_BUILD", 1) ]) - env_ssh2.Append(CPPPATH=["/usr/local/opt/openssl@1.1/include/"]) - env_ssh2.Append(LIBPATH=["/usr/local/opt/openssl@1.1/lib/"]) + else: + env_ssh2.Append(LIBPATH=[env_ssh2["macos_ssl_path"] + "lib/"]) + env_ssh2.Append(LIBS=["ssl", "crypto"]) env_ssh2.StaticLibrary(target="../bin/" + "ssh2", source=libssh2_sources)