Change macOS builds to use OpenSSL purely as a static lib

This commit is contained in:
Twarit Waikar
2021-10-13 00:39:23 +05:30
parent 4119ad2c74
commit a6772e0d3f
6 changed files with 26 additions and 51 deletions

View File

@@ -3,11 +3,11 @@ name: C/C++ CI
on: [push, pull_request]
jobs:
linux:
linux-x64:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: build-linux-release
- name: build-linux-release-x64
run: |
git submodule update --init --recursive
pip3 install --user scons
@@ -15,12 +15,12 @@ jobs:
ldd demo/addons/godot-git-plugin/linux/libgitapi.so
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-linux-release-${{ github.sha }}
name: godot-git-plugin-linux-release-x64-${{ github.sha }}
if-no-files-found: error
path: |
demo/
windows:
windows-x64:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
@@ -29,7 +29,7 @@ jobs:
python-version: "3.x"
architecture: "x64"
- uses: ilammy/msvc-dev-cmd@v1
- name: build-windows-release
- name: build-windows-release-x64
run: |
git submodule update --init --recursive
pip3 install --user scons
@@ -37,7 +37,7 @@ jobs:
dumpbin /dependents .\demo\addons\godot-git-plugin\win64\libgitapi.dll
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-windows-release-${{ github.sha }}
name: godot-git-plugin-windows-release-x64-${{ github.sha }}
if-no-files-found: error
path: |
demo/
@@ -46,10 +46,10 @@ jobs:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- name: build-macos-release
- name: build-macos-release-x64
run: |
git submodule update --init --recursive
brew install scons openssl@1.1
brew install scons
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
@@ -58,20 +58,3 @@ jobs:
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

@@ -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, run `brew install openssl` and use the `macos_ssl_path` SCons argument.
- For Mac users, run `brew install openssl@1.1` and use the `macos_ssl_path` SCons argument which should contain the path to where Homebrew installed the OpenSSL library.
- For Linux users, `sudo apt-get install libssl-dev`, or local package manager equivalent.
### Build

View File

@@ -28,7 +28,7 @@ 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))
"/usr/local/opt/openssl@1.1/", PathVariable.PathAccept))
# Updates the environment with the option variables.
opts.Update(env)

View File

@@ -31,6 +31,8 @@ if not os.path.isdir(env["target_path"]):
if env["platform"] == "osx":
env["target_path"] += "osx/"
cpp_library += ".osx"
env.Append(LIBPATH=[env["macos_ssl_path"] + "lib/"])
env.Append(LIBS=["ssl", "crypto"])
if env["target"] in ("debug", "d"):
env.Append(CCFLAGS=["-g", "-O2", "-std=c++17"])

19
thirdparty/git2/SCsub vendored
View File

@@ -28,13 +28,6 @@ if env_git["bits"] == 64:
elif env_git["bits"] == 32:
env_git.Prepend(CPPDEFINES=["GIT_ARCH_32"])
if env_git["platform"] == "windows":
env_git.Prepend(CPPDEFINES=["GIT_WINHTTP"])
libgit2_sources += Glob("libgit2/src/win32/" + "*.c")
if env_git["platform"] in ["linux", "osx"]:
libgit2_sources += Glob("libgit2/src/unix/" + "*.c")
env_git.Prepend(
CPPPATH=[
"libgit2/include/",
@@ -61,8 +54,10 @@ env_git.Prepend(
)
if env_git["platform"] == "windows":
libgit2_sources += Glob("libgit2/src/win32/" + "*.c")
env_git.Prepend(
CPPDEFINES=[
"GIT_WINHTTP",
"HAVE_SYS_STAT_H",
"HAVE_SYS_TYPES_H",
"HAVE_WINDOWS_H",
@@ -92,6 +87,7 @@ if env_git["platform"] == "windows":
if env_git["platform"] in ["linux", "osx"]:
env_git.Append(CCFLAGS="-fPIC")
libgit2_sources += Glob("libgit2/src/unix/" + "*.c")
libgit2_sources += [
"libgit2/deps/ntlmclient/crypt_openssl.c",
"libgit2/deps/ntlmclient/unicode_builtin.c"
@@ -131,13 +127,8 @@ if env_git["platform"] in ["linux", "osx"]:
)
if env_git["platform"] == "osx":
# 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.Append(LIBPATH=[env_git["macos_ssl_path"] + "lib/"])
env_git.Append(LIBS=["ssl"])
env_git.StaticLibrary(target="../bin/" + "git2", source=libgit2_sources)

19
thirdparty/ssh2/SCsub vendored
View File

@@ -106,16 +106,15 @@ if env_ssh2["platform"] in ["linux", "osx"]:
if env_ssh2["platform"] == "osx":
env_ssh2.Append(CPPPATH=[env_ssh2["macos_ssl_path"] + "include/"])
env_ssh2.Append(LIBPATH=[env_ssh2["macos_ssl_path"] + "lib/"])
env_ssh2.Append(LIBS=["ssl", "crypto"])
# 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)
])
else:
env_ssh2.Append(LIBPATH=[env_ssh2["macos_ssl_path"] + "lib/"])
env_ssh2.Append(LIBS=["ssl", "crypto"])
# TODO: Verify if this works on actual M1 hardware
if env_ssh2["macos_arch"] == "arm64":
env_ssh2.Append(
CPPDEFINES=[
("WORDS_BIGENDIAN", "1"),
# ("AC_APPLE_UNIVERSAL_BUILD", "1")
])
env_ssh2.StaticLibrary(target="../bin/" + "ssh2", source=libssh2_sources)