Support macOS universal thirdparty library builds

This commit is contained in:
Twarit Waikar
2021-10-12 02:56:19 +05:30
parent b0b3eba3ee
commit 84fa17720c
5 changed files with 32 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ jobs:
git submodule update --init --recursive
pip3 install --user scons
scons platform=linux target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json -j $(nproc)
ldd demo/addons/godot-git-plugin/linux/libgitapi.so
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-linux-release-${{ github.sha }}
@@ -33,6 +34,7 @@ jobs:
git submodule update --init --recursive
pip3 install --user scons
scons platform=windows target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json -j $env:NUMBER_OF_PROCESSORS
dumpbin /dependents .\demo\addons\godot-git-plugin\win64\libgitapi.dll
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-windows-release-${{ github.sha }}
@@ -47,8 +49,9 @@ jobs:
- name: build-macos-release
run: |
git submodule update --init --recursive
brew install scons
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=universal use_llvm=yes -j $(sysctl -n hw.logicalcpu)
otool -L demo/addons/godot-git-plugin/osx/libgitapi.so
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-macos-release-${{ github.sha }}

View File

@@ -19,6 +19,8 @@ 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 Linux users, `sudo apt-get install libssl-dev`, or local package manager equivalent.
### Build

View File

@@ -18,7 +18,7 @@ opts.Add(BoolVariable("use_llvm", "Use the LLVM / Clang compiler", "no"))
opts.Add(PathVariable("target_path", "The path where the lib is installed.", "demo/addons/godot-git-plugin/"))
opts.Add(PathVariable("target_name", "The library name.", "libgitapi", PathVariable.PathAccept))
opts.Add(EnumVariable("bits", "The bit architecture.", "64", ["64"]))
opts.Add(EnumVariable("macos_arch", "Target macOS architecture", "universal", ["universal", "x86_64", "arm64"]))
# Updates the environment with the option variables.
opts.Update(env)

19
thirdparty/git2/SCsub vendored
View File

@@ -130,4 +130,23 @@ if env_git["platform"] in ["linux", "osx"]:
]
)
if env_git["platform"] == "osx":
env_git.Prepend(
CPPPATH=[
"/usr/local/opt/openssl@1.1/include/"
]
)
env_git.Prepend(
LIBPATH=[
"/usr/local/opt/openssl@1.1/lib/"
]
)
if env_git["macos_arch"] == "universal":
env_git.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
env_git.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
else:
env_git.Append(LINKFLAGS=["-arch", env_git["macos_arch"]])
env_git.Append(CCFLAGS=["-arch", env_git["macos_arch"]])
env_git.StaticLibrary(target = "../bin/" + "git2", source = libgit2_sources)

View File

@@ -77,6 +77,12 @@ if env_ssh2["platform"] == "osx":
"HAVE_SYS_UIO_H"
]
)
if env_ssh2["macos_arch"] == "universal":
env_ssh2.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
env_ssh2.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
else:
env_ssh2.Append(LINKFLAGS=["-arch", env_ssh2["macos_arch"]])
env_ssh2.Append(CCFLAGS=["-arch", env_ssh2["macos_arch"]])
if env_ssh2["platform"] == "linux":
env_ssh2.Append(CCFLAGS = "-fPIC")