Make macos version work (testes on m1 at least)
1. Change name of discord's library to libdiscord_game_sdk, so it links properly 2. Change it's install name with install_name_tool to use @loader_path instead of @rpath, that one's a blunder on discord's side, it should really have been loader_path from the beginning (rpath means look at where the binary is started from, loader_path means look at where the library is) 3. Combine the aarch and x86 library into one, again no idea why discord does not do this themselves
This commit is contained in:
11
setup.py
11
setup.py
@@ -2,6 +2,7 @@ import zipfile
|
||||
from distutils.dir_util import copy_tree
|
||||
import shutil
|
||||
import os
|
||||
import sys
|
||||
|
||||
with zipfile.ZipFile("src/lib/discord_game_sdk.zip", "r") as zip_ref:
|
||||
zip_ref.extractall("src/lib/discord_game_sdk/")
|
||||
@@ -43,4 +44,14 @@ shutil.rmtree("src/lib/discord_game_sdk/bin/x86/", ignore_errors=True)
|
||||
shutil.rmtree("src/lib/discord_game_sdk/bin/x86_64/", ignore_errors=True)
|
||||
os.remove("src/lib/discord_game_sdk/README.md")
|
||||
|
||||
if sys.platform == "darwin":
|
||||
# Combine the two libraries into one
|
||||
os.system("lipo src/lib/discord_game_sdk/bin/{discord_game_sdk.dylib,discord_game_sdk_aarch64.dylib} -output src/lib/discord_game_sdk/bin/libdiscord_game_sdk.dylib -create")
|
||||
# Change the install name to (library's location)/(its new name)
|
||||
os.system("install_name_tool -id '@loader_path/libdiscord_game_sdk.dylib'\
|
||||
src/lib/discord_game_sdk/bin/libdiscord_game_sdk.dylib")
|
||||
# Remove the ones it's made of
|
||||
os.remove("src/lib/discord_game_sdk/bin/discord_game_sdk.dylib")
|
||||
os.remove("src/lib/discord_game_sdk/bin/discord_game_sdk_aarch64.dylib")
|
||||
|
||||
os.system("git submodule update --init --remote")
|
||||
|
Reference in New Issue
Block a user