No longer use a shell script for the wrapper .app

This commit is contained in:
Kovid Goyal 2018-01-11 08:40:35 +05:30
parent 66a46279f4
commit 236c92b2b4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 17 additions and 20 deletions

View File

@ -437,6 +437,10 @@ logo/make.py
./setup.py kitty.app
```
This `kitty.app` unlike the released one does not include its own copy of
python and the other dependencies. So if you ever un-install/upgrade those dependencies
you might have to rebuild the app.
Note that the released kitty.dmg includes all dependencies, unlike the
`kitty.app` built above and is built automatically by using the `kitty` branch of
link:https://github.com/kovidgoyal/build-calibre[build-calibre] however, that

View File

@ -90,8 +90,12 @@ int main(int argc, char *argv[]) {
wchar_t *argvw[MAX_ARGC + 1] = {0};
#ifdef WITH_PROFILER
num = snprintf(lib, PATH_MAX, "%s%s", exe_dir, "/");
#else
#ifdef FOR_LAUNCHER
num = snprintf(lib, PATH_MAX, "%s%s", exe_dir, "/../Frameworks/kitty");
#else
num = snprintf(lib, PATH_MAX, "%s%s", exe_dir, "/../lib/kitty");
#endif
#endif
if (num < 0 || num >= PATH_MAX) { fprintf(stderr, "Failed to create path to kitty lib\n"); return 1; }

View File

@ -456,7 +456,7 @@ def build_asan_launcher(args):
run_tool(cmd, desc='Creating {} ...'.format(emphasis('asan-launcher')))
def build_linux_launcher(args, launcher_dir='.', for_bundle=False):
def build_linux_launcher(args, launcher_dir='.', for_bundle=False, sh_launcher=False):
cflags = '-Wall -Werror -fpie'.split()
libs = []
if args.profile:
@ -467,6 +467,8 @@ def build_linux_launcher(args, launcher_dir='.', for_bundle=False):
if for_bundle:
cflags.append('-DFOR_BUNDLE')
cflags.append('-DPYVER="{}"'.format(sysconfig.get_python_version()))
elif sh_launcher:
cflags.append('-DFOR_LAUNCHER')
pylib = get_python_flags(cflags)
exe = 'kitty-profile' if args.profile else 'kitty'
cmd = [env.cc] + cflags + [
@ -505,7 +507,7 @@ def package(args, for_bundle=False, sh_launcher=False): # {{{
os.chmod(path, 0o755 if f.endswith('.so') else 0o644)
launcher_dir = os.path.join(ddir, 'bin')
safe_makedirs(launcher_dir)
build_linux_launcher(args, launcher_dir, for_bundle)
build_linux_launcher(args, launcher_dir, for_bundle, sh_launcher)
if not is_macos: # {{{ linux desktop gunk
icdir = os.path.join(ddir, 'share', 'icons', 'hicolor', '256x256', 'apps')
safe_makedirs(icdir)
@ -529,10 +531,9 @@ Categories=System;
)
# }}}
if for_bundle: # OS X bundle gunk {{{
if for_bundle or sh_launcher: # OS X bundle gunk {{{
import plistlib
logo_dir = os.path.abspath(os.path.join('logo', appname + '.iconset'))
exe_path = os.path.abspath(sys.executable)
os.chdir(ddir)
os.mkdir('Contents')
os.chdir('Contents')
@ -569,22 +570,8 @@ Categories=System;
'iconutil', '-c', 'icns', logo_dir, '-o',
os.path.join('Resources', os.path.basename(logo_dir).partition('.')[0] + '.icns')
])
if sh_launcher:
with open('MacOS/kitty', 'r+') as f:
f.seek(0), f.truncate()
f.write('''\
#!EXE_PATH
import os, sys
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
kitty = os.path.join(base, 'Frameworks', 'kitty')
sys.path.insert(0, kitty)
with open(os.path.join(kitty, '__main__.py')) as f:
code = f.read()
code = compile(code, f.name, 'exec')
exec(code, {'__name__': '__main__'})
'''.replace('EXE_PATH', exe_path, 1))
# }}}
# }}}
# }}}
def clean():
@ -675,8 +662,10 @@ def main():
package(args, for_bundle=True)
elif args.action == 'kitty.app':
args.prefix = 'kitty.app'
if os.path.exists(args.prefix):
shutil.rmtree(args.prefix)
build(args)
package(args, for_bundle=True, sh_launcher=True)
package(args, for_bundle=False, sh_launcher=True)
print('kitty.app successfully built!')
elif args.action == 'clean':
clean()