73 lines
1.8 KiB
Python
73 lines
1.8 KiB
Python
|
import argparse
|
||
|
import glob
|
||
|
import os
|
||
|
import shutil
|
||
|
from os.path import isdir, isfile, join
|
||
|
|
||
|
parser = argparse.ArgumentParser(description="Patch imports")
|
||
|
parser.add_argument("bundle", type=str)
|
||
|
parser.add_argument("--executable", help="executable name", required=False)
|
||
|
|
||
|
args = parser.parse_args()
|
||
|
bundle_path = args.bundle
|
||
|
|
||
|
if not isdir(bundle_path):
|
||
|
print(bundle_path + " is not a directory")
|
||
|
exit()
|
||
|
|
||
|
if not isfile(join(bundle_path, "Contents/Info.plist")):
|
||
|
print("Contents/Info.plist not found")
|
||
|
exit()
|
||
|
|
||
|
|
||
|
executable_dir = join(bundle_path, "Contents/MacOS")
|
||
|
executable = ""
|
||
|
|
||
|
if args.executable is not None:
|
||
|
executable = join(executable_dir, args.executable)
|
||
|
else:
|
||
|
executable = glob.glob(join(executable_dir, "**"), recursive=False)[0]
|
||
|
|
||
|
if not os.path.exists(executable):
|
||
|
print("error with executable path " + executable)
|
||
|
exit()
|
||
|
|
||
|
frameworks_dir = join(bundle_path, "Contents/Frameworks")
|
||
|
|
||
|
if not os.path.exists(frameworks_dir):
|
||
|
os.makedirs(frameworks_dir)
|
||
|
|
||
|
SHADERC_DYLIB_NAME = "libshaderc_shared.1.dylib"
|
||
|
VULKAN_DYLIB_NAME = "libvulkan.1.dylib"
|
||
|
DYLIB_PATH = join(os.environ["VULKAN_SDK"], "lib")
|
||
|
|
||
|
shutil.copyfile(
|
||
|
join(DYLIB_PATH, SHADERC_DYLIB_NAME),
|
||
|
join(frameworks_dir, SHADERC_DYLIB_NAME),
|
||
|
follow_symlinks=True,
|
||
|
)
|
||
|
shutil.copyfile(
|
||
|
join(DYLIB_PATH, VULKAN_DYLIB_NAME),
|
||
|
join(frameworks_dir, VULKAN_DYLIB_NAME),
|
||
|
follow_symlinks=True,
|
||
|
)
|
||
|
|
||
|
os.system(
|
||
|
'install_name_tool -change "@rpath/'
|
||
|
+ SHADERC_DYLIB_NAME
|
||
|
+ '" "@executable_path/../Frameworks/'
|
||
|
+ SHADERC_DYLIB_NAME
|
||
|
+ '" '
|
||
|
+ executable
|
||
|
)
|
||
|
os.system(
|
||
|
'install_name_tool -change "@rpath/'
|
||
|
+ VULKAN_DYLIB_NAME
|
||
|
+ '" "@executable_path/../Frameworks/'
|
||
|
+ VULKAN_DYLIB_NAME
|
||
|
+ '" '
|
||
|
+ executable
|
||
|
)
|
||
|
|
||
|
os.system("codesign -f -s - " + bundle_path)
|