Merge branch 'support-cppflags' of https://github.com/jamessan/kitty
This commit is contained in:
commit
796ead5d75
53
setup.py
53
setup.py
@ -142,11 +142,11 @@ def get_sanitize_args(cc, ccver):
|
|||||||
|
|
||||||
class Env:
|
class Env:
|
||||||
|
|
||||||
def __init__(self, cc, cflags, ldflags, ldpaths=[]):
|
def __init__(self, cc, cppflags, cflags, ldflags, ldpaths=[]):
|
||||||
self.cc, self.cflags, self.ldflags, self.ldpaths = cc, cflags, ldflags, ldpaths
|
self.cc, self.cppflags, self.cflags, self.ldflags, self.ldpaths = cc, cppflags, cflags, ldflags, ldpaths
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
return Env(self.cc, list(self.cflags), list(self.ldflags), list(self.ldflags))
|
return Env(self.cc, list(self.cppflags), list(self.cflags), list(self.ldflags), list(self.ldflags))
|
||||||
|
|
||||||
|
|
||||||
def init_env(
|
def init_env(
|
||||||
@ -166,14 +166,23 @@ def init_env(
|
|||||||
df += ' -Og'
|
df += ' -Og'
|
||||||
optimize = df if debug or sanitize else '-O3'
|
optimize = df if debug or sanitize else '-O3'
|
||||||
sanitize_args = get_sanitize_args(cc, ccver) if sanitize else set()
|
sanitize_args = get_sanitize_args(cc, ccver) if sanitize else set()
|
||||||
|
cppflags = os.environ.get(
|
||||||
|
'OVERRIDE_CPPFLAGS', (
|
||||||
|
'-D_XOPEN_SOURCE=700 -D{}DEBUG'
|
||||||
|
).format(
|
||||||
|
('' if debug else 'N'),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
cppflags = shlex.split(cppflags) + shlex.split(
|
||||||
|
sysconfig.get_config_var('CPPFLAGS')
|
||||||
|
)
|
||||||
cflags = os.environ.get(
|
cflags = os.environ.get(
|
||||||
'OVERRIDE_CFLAGS', (
|
'OVERRIDE_CFLAGS', (
|
||||||
'-Wextra -Wno-missing-field-initializers -Wall -std=c99 -D_XOPEN_SOURCE=700'
|
'-Wextra -Wno-missing-field-initializers -Wall -std=c99'
|
||||||
' -pedantic-errors -Werror {} {} -D{}DEBUG -fwrapv {} {} -pipe {} -fvisibility=hidden'
|
' -pedantic-errors -Werror {} {} -fwrapv {} {} -pipe {} -fvisibility=hidden'
|
||||||
).format(
|
).format(
|
||||||
optimize,
|
optimize,
|
||||||
' '.join(sanitize_args),
|
' '.join(sanitize_args),
|
||||||
('' if debug else 'N'),
|
|
||||||
stack_protector,
|
stack_protector,
|
||||||
missing_braces,
|
missing_braces,
|
||||||
'-march=native' if native_optimizations else '',
|
'-march=native' if native_optimizations else '',
|
||||||
@ -184,13 +193,14 @@ def init_env(
|
|||||||
)
|
)
|
||||||
if os.path.exists('.git'):
|
if os.path.exists('.git'):
|
||||||
rev = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
|
rev = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
|
||||||
cflags.append('-DKITTY_VCS_REV="{}"'.format(rev))
|
cppflags.append('-DKITTY_VCS_REV="{}"'.format(rev))
|
||||||
ldflags = os.environ.get(
|
ldflags = os.environ.get(
|
||||||
'OVERRIDE_LDFLAGS',
|
'OVERRIDE_LDFLAGS',
|
||||||
'-Wall ' + ' '.join(sanitize_args) + ('' if debug else ' -O3')
|
'-Wall ' + ' '.join(sanitize_args) + ('' if debug else ' -O3')
|
||||||
)
|
)
|
||||||
ldflags = shlex.split(ldflags)
|
ldflags = shlex.split(ldflags)
|
||||||
ldflags.append('-shared')
|
ldflags.append('-shared')
|
||||||
|
cppflags += shlex.split(os.environ.get('CPPFLAGS', ''))
|
||||||
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
||||||
ldflags += shlex.split(os.environ.get('LDFLAGS', ''))
|
ldflags += shlex.split(os.environ.get('LDFLAGS', ''))
|
||||||
if not debug and not sanitize:
|
if not debug and not sanitize:
|
||||||
@ -198,10 +208,10 @@ def init_env(
|
|||||||
cflags.append('-flto'), ldflags.append('-flto')
|
cflags.append('-flto'), ldflags.append('-flto')
|
||||||
|
|
||||||
if profile:
|
if profile:
|
||||||
cflags.append('-DWITH_PROFILER')
|
cppflags.append('-DWITH_PROFILER')
|
||||||
cflags.append('-g3')
|
cflags.append('-g3')
|
||||||
ldflags.append('-lprofiler')
|
ldflags.append('-lprofiler')
|
||||||
return Env(cc, cflags, ldflags)
|
return Env(cc, cppflags, cflags, ldflags)
|
||||||
|
|
||||||
|
|
||||||
def kitty_env():
|
def kitty_env():
|
||||||
@ -210,8 +220,9 @@ def kitty_env():
|
|||||||
cflags.append('-pthread')
|
cflags.append('-pthread')
|
||||||
# We add 4000 to the primary version because vim turns on SGR mouse mode
|
# We add 4000 to the primary version because vim turns on SGR mouse mode
|
||||||
# automatically if this version is high enough
|
# automatically if this version is high enough
|
||||||
cflags.append('-DPRIMARY_VERSION={}'.format(version[0] + 4000))
|
cppflags = ans.cppflags
|
||||||
cflags.append('-DSECONDARY_VERSION={}'.format(version[1]))
|
cppflags.append('-DPRIMARY_VERSION={}'.format(version[0] + 4000))
|
||||||
|
cppflags.append('-DSECONDARY_VERSION={}'.format(version[1]))
|
||||||
at_least_version('harfbuzz', 1, 5)
|
at_least_version('harfbuzz', 1, 5)
|
||||||
cflags.extend(pkg_config('libpng', '--cflags-only-I'))
|
cflags.extend(pkg_config('libpng', '--cflags-only-I'))
|
||||||
if is_macos:
|
if is_macos:
|
||||||
@ -348,13 +359,13 @@ def compile_c_extension(kenv, module, incremental, compilation_database, all_key
|
|||||||
|
|
||||||
for original_src, dest in zip(sources, objects):
|
for original_src, dest in zip(sources, objects):
|
||||||
src = original_src
|
src = original_src
|
||||||
cflgs = kenv.cflags[:]
|
cppflgs = kenv.cppflags[:]
|
||||||
is_special = src in SPECIAL_SOURCES
|
is_special = src in SPECIAL_SOURCES
|
||||||
if is_special:
|
if is_special:
|
||||||
src, defines = SPECIAL_SOURCES[src]
|
src, defines = SPECIAL_SOURCES[src]
|
||||||
cflgs.extend(map(define, defines))
|
cppflgs.extend(map(define, defines))
|
||||||
|
|
||||||
cmd = [kenv.cc, '-MMD'] + cflgs
|
cmd = [kenv.cc, '-MMD'] + kenv.cflags + cppflgs
|
||||||
key = original_src, os.path.basename(dest)
|
key = original_src, os.path.basename(dest)
|
||||||
all_keys.add(key)
|
all_keys.add(key)
|
||||||
cmd_changed = compilation_database.get(key, [])[:-4] != cmd
|
cmd_changed = compilation_database.get(key, [])[:-4] != cmd
|
||||||
@ -482,23 +493,25 @@ def build_asan_launcher(args):
|
|||||||
|
|
||||||
def build_linux_launcher(args, launcher_dir='.', for_bundle=False, sh_launcher=False):
|
def build_linux_launcher(args, launcher_dir='.', for_bundle=False, sh_launcher=False):
|
||||||
cflags = '-Wall -Werror -fpie'.split()
|
cflags = '-Wall -Werror -fpie'.split()
|
||||||
|
cppflags = []
|
||||||
libs = []
|
libs = []
|
||||||
if args.profile:
|
if args.profile:
|
||||||
cflags.append('-DWITH_PROFILER'), cflags.append('-g')
|
cppflags.append('-DWITH_PROFILER'), cflags.append('-g')
|
||||||
libs.append('-lprofiler')
|
libs.append('-lprofiler')
|
||||||
else:
|
else:
|
||||||
cflags.append('-O3')
|
cflags.append('-O3')
|
||||||
if for_bundle:
|
if for_bundle:
|
||||||
cflags.append('-DFOR_BUNDLE')
|
cppflags.append('-DFOR_BUNDLE')
|
||||||
cflags.append('-DPYVER="{}"'.format(sysconfig.get_python_version()))
|
cppflags.append('-DPYVER="{}"'.format(sysconfig.get_python_version()))
|
||||||
elif sh_launcher:
|
elif sh_launcher:
|
||||||
cflags.append('-DFOR_LAUNCHER')
|
cppflags.append('-DFOR_LAUNCHER')
|
||||||
cflags.append('-DLIB_DIR_NAME="{}"'.format(args.libdir_name.strip('/')))
|
cppflags.append('-DLIB_DIR_NAME="{}"'.format(args.libdir_name.strip('/')))
|
||||||
pylib = get_python_flags(cflags)
|
pylib = get_python_flags(cflags)
|
||||||
exe = 'kitty-profile' if args.profile else 'kitty'
|
exe = 'kitty-profile' if args.profile else 'kitty'
|
||||||
|
cppflags += shlex.split(os.environ.get('CPPFLAGS', ''))
|
||||||
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
||||||
ldflags = shlex.split(os.environ.get('LDFLAGS', ''))
|
ldflags = shlex.split(os.environ.get('LDFLAGS', ''))
|
||||||
cmd = [env.cc] + cflags + [
|
cmd = [env.cc] + cppflags + cflags + [
|
||||||
'linux-launcher.c', '-o',
|
'linux-launcher.c', '-o',
|
||||||
os.path.join(launcher_dir, exe)
|
os.path.join(launcher_dir, exe)
|
||||||
] + ldflags + libs + pylib
|
] + ldflags + libs + pylib
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user