Skip to content

Commit

Permalink
Add universal OpenSSL library builds
Browse files Browse the repository at this point in the history
  • Loading branch information
twaritwaikar committed Oct 13, 2021
1 parent 3e955b9 commit cc9632e
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ jobs:
- name: build-macos-release-x64
run: |
git submodule update --init --recursive
chmod +x build_openssl_arm64_osx.sh
./build_openssl_arm64_osx.sh
./build_openssl_universal_osx.sh
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=universal macos_openssl_static_ssl="libssl.a" macos_openssl_static_crypto="libcrypto.a" 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=universal use_llvm=yes -j $(sysctl -n hw.logicalcpu)
otool -L demo/addons/godot-git-plugin/osx/libgitapi.dylib
- uses: actions/upload-artifact@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ win64/
*.obj
*.ilk
*.pdb
!thirdparty/openssl/*
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ 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@1.1`.
- For Linux users, `sudo apt-get install libssl-dev`, or local package manager equivalent.
- Platforms Specific Setup
- Windows
- No extra steps required other than setting up the compilers.
- MacOS
- For making universal builds targeting both Apple Silicon and x86_64, you can optionally run `build_openssl_universal_osx.sh` to build OpenSSL yourself and replace the already prebuilt libraries provided inside `thirdparty/openssl/`, otherwise, just run `brew install openssl@1.1`.
- Linux
- Run `sudo apt-get install libssl-dev`, or local package manager equivalent.

### Build

Expand Down
8 changes: 4 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ 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_openssl", "Path to OpenSSL libraries - only used in macOS builds.",
"/usr/local/opt/openssl@1.1/", PathVariable.PathAccept))
opts.Add(PathVariable("macos_openssl", "Path to OpenSSL library root - only used in macOS builds.",
"/usr/local/opt/openssl@1.1/", PathVariable.PathAccept)) # TODO: Find a way to configure this to use the cloned OpenSSL source code, based on `macos_arch`.
opts.Add(PathVariable("macos_openssl_static_ssl", "Path to OpenSSL libssl.a library - only used in macOS builds.",
"/usr/local/opt/openssl@1.1/lib/libssl.a", PathVariable.PathAccept))
os.path.join(os.path.abspath(os.getcwd()), "thirdparty/openssl/libssl.a"), PathVariable.PathAccept))
opts.Add(PathVariable("macos_openssl_static_crypto", "Path to OpenSSL libcrypto.a library - only used in macOS builds.",
"/usr/local/opt/openssl@1.1/lib/libcrypto.a", PathVariable.PathAccept))
os.path.join(os.path.abspath(os.getcwd()), "thirdparty/openssl/libcrypto.a"), PathVariable.PathAccept))

# Updates the environment with the option variables.
opts.Update(env)
Expand Down
4 changes: 2 additions & 2 deletions godot-git-plugin/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ if env["platform"] == "osx":
cpp_library += ".osx"

# Force static linkage (https://stackoverflow.com/a/2995999/7370948)
static_ssl = File("../" + env["macos_openssl_static_ssl"])
static_crypto = File("../" + env["macos_openssl_static_crypto"])
static_ssl = File(env["macos_openssl_static_ssl"])
static_crypto = File(env["macos_openssl_static_crypto"])
env.Append(LIBS=[static_ssl, static_crypto])

if env["target"] in ("debug", "d"):
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/git2/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ if env_git["platform"] in ["linux", "osx"]:

if env_git["platform"] == "osx":
env_git.Prepend(CPPPATH=[env_git["macos_openssl"] + "include/"])
static_ssl = File("../../" + env_git["macos_openssl_static_ssl"])
static_crypto = File("../../" + env_git["macos_openssl_static_crypto"])
static_ssl = File(env_git["macos_openssl_static_ssl"])
static_crypto = File(env_git["macos_openssl_static_crypto"])
env_git.Append(LIBS=[static_ssl, static_crypto])

env_git.StaticLibrary(target="../bin/" + "git2", source=libgit2_sources)
Binary file added thirdparty/openssl/libcrypto.a
Binary file not shown.
Binary file added thirdparty/openssl/libssl.a
Binary file not shown.
4 changes: 2 additions & 2 deletions thirdparty/ssh2/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ if env_ssh2["platform"] in ["linux", "osx"]:

if env_ssh2["platform"] == "osx":
env_ssh2.Append(CPPPATH=[env_ssh2["macos_openssl"] + "include/"])
static_ssl = File("../../" + env_ssh2["macos_openssl_static_ssl"])
static_crypto = File("../../" + env_ssh2["macos_openssl_static_crypto"])
static_ssl = File(env_ssh2["macos_openssl_static_ssl"])
static_crypto = File(env_ssh2["macos_openssl_static_crypto"])
env_ssh2.Append(LIBS=[static_ssl, static_crypto])

env_ssh2.StaticLibrary(target="../bin/" + "ssh2", source=libssh2_sources)

0 comments on commit cc9632e

Please sign in to comment.