Add universal builds back to CI + link to OpenSSL dylib, not .a

This commit is contained in:
Twarit Waikar
2021-10-12 23:31:51 +05:30
parent 76dfd5a143
commit 4119ad2c74
7 changed files with 39 additions and 11 deletions

View File

@@ -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/

View File

@@ -1,6 +1,6 @@
name: clang-format
on: [push]
on: [push, pull_request]
jobs:
clang-format:

View File

@@ -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

View File

@@ -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)

View File

@@ -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:

View File

@@ -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)

View File

@@ -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)