diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fb7db5..bf2209f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/.gitignore b/.gitignore index 3189d81..f4f46c8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ win64/ *.obj *.ilk *.pdb +!thirdparty/openssl/* diff --git a/README.md b/README.md index ffd078c..6c11fb5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/SConstruct b/SConstruct index fa952a7..e660b81 100644 --- a/SConstruct +++ b/SConstruct @@ -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) diff --git a/godot-git-plugin/SCsub b/godot-git-plugin/SCsub index f2a4834..18f06b0 100644 --- a/godot-git-plugin/SCsub +++ b/godot-git-plugin/SCsub @@ -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"): diff --git a/thirdparty/git2/SCsub b/thirdparty/git2/SCsub index 75f4bce..9d7359c 100644 --- a/thirdparty/git2/SCsub +++ b/thirdparty/git2/SCsub @@ -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) diff --git a/thirdparty/openssl/libcrypto.a b/thirdparty/openssl/libcrypto.a new file mode 100644 index 0000000..bb98f3d Binary files /dev/null and b/thirdparty/openssl/libcrypto.a differ diff --git a/thirdparty/openssl/libssl.a b/thirdparty/openssl/libssl.a new file mode 100644 index 0000000..fb2c40c Binary files /dev/null and b/thirdparty/openssl/libssl.a differ diff --git a/thirdparty/ssh2/SCsub b/thirdparty/ssh2/SCsub index 2b32268..7be2774 100644 --- a/thirdparty/ssh2/SCsub +++ b/thirdparty/ssh2/SCsub @@ -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)