Fix minimal macos bundle build

This commit is contained in:
Kovid Goyal 2022-08-14 13:48:45 +05:30
parent deb8c3dacd
commit 848a795d26
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 11 additions and 9 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@
/link_commands.json /link_commands.json
/glad/out/ /glad/out/
/kitty/launcher/kitty /kitty/launcher/kitty
/kitty/launcher/kitty.app
/*.dSYM/ /*.dSYM/
__pycache__/ __pycache__/
/glfw/wayland-*-client-protocol.[ch] /glfw/wayland-*-client-protocol.[ch]

View File

@ -904,7 +904,7 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
os.makedirs(launcher_dir, exist_ok=True) os.makedirs(launcher_dir, exist_ok=True)
os.makedirs(build_dir, exist_ok=True) os.makedirs(build_dir, exist_ok=True)
objects = [] objects = []
for src in ('kitty/launcher/launcher.c', 'kitty/launcher/prewarm-launcher.c'): for src in ('kitty/launcher/main.c', 'kitty/launcher/prewarm.c'):
obj = os.path.join(build_dir, src.replace('/', '-').replace('.c', '.o')) obj = os.path.join(build_dir, src.replace('/', '-').replace('.c', '.o'))
objects.append(obj) objects.append(obj)
cmd = env.cc + cppflags + cflags + ['-c', src, '-o', obj] cmd = env.cc + cppflags + cflags + ['-c', src, '-o', obj]
@ -1241,19 +1241,20 @@ def create_macos_app_icon(where: str = 'Resources') -> None:
]]) ]])
def create_minimal_macos_bundle(args: Options, where: str) -> None: def create_minimal_macos_bundle(args: Options, launcher_dir: str) -> None:
if os.path.exists(where): kapp = os.path.join(launcher_dir, 'kitty.app')
shutil.rmtree(where) if os.path.exists(kapp):
bin_dir = os.path.join(where, 'kitty.app/Contents/MacOS') shutil.rmtree(kapp)
resources_dir = os.path.join(where, 'kitty.app/Contents/Resources') bin_dir = os.path.join(kapp, 'Contents/MacOS')
resources_dir = os.path.join(kapp, 'Contents/Resources')
os.makedirs(resources_dir) os.makedirs(resources_dir)
os.makedirs(bin_dir) os.makedirs(bin_dir)
with open(os.path.join(where, 'kitty.app/Contents/Info.plist'), 'wb') as f: with open(os.path.join(kapp, 'Contents/Info.plist'), 'wb') as f:
f.write(macos_info_plist()) f.write(macos_info_plist())
build_launcher(args, bin_dir) build_launcher(args, bin_dir)
os.symlink( os.symlink(
os.path.join(os.path.relpath(bin_dir, where), appname), os.path.join(os.path.relpath(bin_dir, launcher_dir), appname),
os.path.join(where, appname)) os.path.join(launcher_dir, appname))
create_macos_app_icon(resources_dir) create_macos_app_icon(resources_dir)