Fix incremental compilation
The macOS specific `package()` code changes the directory. This didn't cause any problems before 9135387cfa141e9ec27271bc41d5b6c43da90197 since `compile_commands.json` was written to the filesystem before `package()` was called. This is not the case anymore, which results in `compile_commands.json` being written into the `kitty.app` bundle. I fixed the problem by using a context manager to change the direcctory back after `kitty.app` was created.
This commit is contained in:
parent
bc90ce569a
commit
aaaf7f9d8b
120
setup.py
120
setup.py
@ -669,6 +669,18 @@ def compile_python(base_path):
|
|||||||
compileall.compile_dir(base_path, **kwargs)
|
compileall.compile_dir(base_path, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class ChDir(object):
|
||||||
|
def __init__(self, path):
|
||||||
|
self.old_dir = os.getcwd()
|
||||||
|
self.new_dir = path
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
os.chdir(self.new_dir)
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
os.chdir(self.old_dir)
|
||||||
|
|
||||||
|
|
||||||
def package(args, bundle_type):
|
def package(args, bundle_type):
|
||||||
ddir = args.prefix
|
ddir = args.prefix
|
||||||
if bundle_type == 'linux-freeze':
|
if bundle_type == 'linux-freeze':
|
||||||
@ -741,61 +753,61 @@ Categories=System;TerminalEmulator;
|
|||||||
if bundle_type.startswith('macos-'): # macOS bundle gunk {{{
|
if bundle_type.startswith('macos-'): # macOS bundle gunk {{{
|
||||||
import plistlib
|
import plistlib
|
||||||
logo_dir = os.path.abspath(os.path.join('logo', appname + '.iconset'))
|
logo_dir = os.path.abspath(os.path.join('logo', appname + '.iconset'))
|
||||||
os.chdir(ddir)
|
with ChDir(ddir):
|
||||||
os.mkdir('Contents')
|
os.mkdir('Contents')
|
||||||
os.chdir('Contents')
|
os.chdir('Contents')
|
||||||
VERSION = '.'.join(map(str, version))
|
VERSION = '.'.join(map(str, version))
|
||||||
pl = dict(
|
pl = dict(
|
||||||
CFBundleDevelopmentRegion='English',
|
CFBundleDevelopmentRegion='English',
|
||||||
CFBundleDisplayName=appname,
|
CFBundleDisplayName=appname,
|
||||||
CFBundleName=appname,
|
CFBundleName=appname,
|
||||||
CFBundleIdentifier='net.kovidgoyal.' + appname,
|
CFBundleIdentifier='net.kovidgoyal.' + appname,
|
||||||
CFBundleVersion=VERSION,
|
CFBundleVersion=VERSION,
|
||||||
CFBundleShortVersionString=VERSION,
|
CFBundleShortVersionString=VERSION,
|
||||||
CFBundlePackageType='APPL',
|
CFBundlePackageType='APPL',
|
||||||
CFBundleSignature='????',
|
CFBundleSignature='????',
|
||||||
CFBundleExecutable=appname,
|
CFBundleExecutable=appname,
|
||||||
LSMinimumSystemVersion='10.12.0',
|
LSMinimumSystemVersion='10.12.0',
|
||||||
LSRequiresNativeExecution=True,
|
LSRequiresNativeExecution=True,
|
||||||
NSAppleScriptEnabled=False,
|
NSAppleScriptEnabled=False,
|
||||||
# Needed for dark mode in Mojave when linking against older SDKs
|
# Needed for dark mode in Mojave when linking against older SDKs
|
||||||
NSRequiresAquaSystemAppearance='NO',
|
NSRequiresAquaSystemAppearance='NO',
|
||||||
NSHumanReadableCopyright=time.strftime(
|
NSHumanReadableCopyright=time.strftime(
|
||||||
'Copyright %Y, Kovid Goyal'),
|
'Copyright %Y, Kovid Goyal'),
|
||||||
CFBundleGetInfoString='kitty, an OpenGL based terminal emulator https://sw.kovidgoyal.net/kitty',
|
CFBundleGetInfoString='kitty, an OpenGL based terminal emulator https://sw.kovidgoyal.net/kitty',
|
||||||
CFBundleIconFile=appname + '.icns',
|
CFBundleIconFile=appname + '.icns',
|
||||||
NSHighResolutionCapable=True,
|
NSHighResolutionCapable=True,
|
||||||
NSSupportsAutomaticGraphicsSwitching=True,
|
NSSupportsAutomaticGraphicsSwitching=True,
|
||||||
LSApplicationCategoryType='public.app-category.utilities',
|
LSApplicationCategoryType='public.app-category.utilities',
|
||||||
LSEnvironment={'KITTY_LAUNCHED_BY_LAUNCH_SERVICES': '1'},
|
LSEnvironment={'KITTY_LAUNCHED_BY_LAUNCH_SERVICES': '1'},
|
||||||
NSServices=[
|
NSServices=[
|
||||||
{
|
{
|
||||||
'NSMenuItem': {'default': 'New ' + appname + ' Tab Here'},
|
'NSMenuItem': {'default': 'New ' + appname + ' Tab Here'},
|
||||||
'NSMessage': 'openTab',
|
'NSMessage': 'openTab',
|
||||||
'NSRequiredContext': {'NSTextContent': 'FilePath'},
|
'NSRequiredContext': {'NSTextContent': 'FilePath'},
|
||||||
'NSSendTypes': ['NSFilenamesPboardType', 'public.plain-text'],
|
'NSSendTypes': ['NSFilenamesPboardType', 'public.plain-text'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'NSMenuItem': {'default': 'New ' + appname + ' Window Here'},
|
'NSMenuItem': {'default': 'New ' + appname + ' Window Here'},
|
||||||
'NSMessage': 'openOSWindow',
|
'NSMessage': 'openOSWindow',
|
||||||
'NSRequiredContext': {'NSTextContent': 'FilePath'},
|
'NSRequiredContext': {'NSTextContent': 'FilePath'},
|
||||||
'NSSendTypes': ['NSFilenamesPboardType', 'public.plain-text'],
|
'NSSendTypes': ['NSFilenamesPboardType', 'public.plain-text'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
with open('Info.plist', 'wb') as fp:
|
with open('Info.plist', 'wb') as fp:
|
||||||
plistlib.dump(pl, fp)
|
plistlib.dump(pl, fp)
|
||||||
os.rename('../share', 'Resources')
|
os.rename('../share', 'Resources')
|
||||||
os.rename('../bin', 'MacOS')
|
os.rename('../bin', 'MacOS')
|
||||||
os.rename('../lib', 'Frameworks')
|
os.rename('../lib', 'Frameworks')
|
||||||
if not os.path.exists(logo_dir):
|
if not os.path.exists(logo_dir):
|
||||||
raise SystemExit('The kitty logo has not been generated, you need to run logo/make.py')
|
raise SystemExit('The kitty logo has not been generated, you need to run logo/make.py')
|
||||||
os.symlink(os.path.join('MacOS', 'kitty'), os.path.join('MacOS', 'kitty-deref-symlink'))
|
os.symlink(os.path.join('MacOS', 'kitty'), os.path.join('MacOS', 'kitty-deref-symlink'))
|
||||||
|
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
'iconutil', '-c', 'icns', logo_dir, '-o',
|
'iconutil', '-c', 'icns', logo_dir, '-o',
|
||||||
os.path.join('Resources', os.path.basename(logo_dir).partition('.')[0] + '.icns')
|
os.path.join('Resources', os.path.basename(logo_dir).partition('.')[0] + '.icns')
|
||||||
])
|
])
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user