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:
|
||||
|
||||
def __init__(self, cc, cflags, ldflags, ldpaths=[]):
|
||||
self.cc, self.cflags, self.ldflags, self.ldpaths = cc, cflags, ldflags, ldpaths
|
||||
def __init__(self, cc, cppflags, cflags, ldflags, ldpaths=[]):
|
||||
self.cc, self.cppflags, self.cflags, self.ldflags, self.ldpaths = cc, cppflags, cflags, ldflags, ldpaths
|
||||
|
||||
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(
|
||||
@ -166,14 +166,23 @@ def init_env(
|
||||
df += ' -Og'
|
||||
optimize = df if debug or sanitize else '-O3'
|
||||
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(
|
||||
'OVERRIDE_CFLAGS', (
|
||||
'-Wextra -Wno-missing-field-initializers -Wall -std=c99 -D_XOPEN_SOURCE=700'
|
||||
' -pedantic-errors -Werror {} {} -D{}DEBUG -fwrapv {} {} -pipe {} -fvisibility=hidden'
|
||||
'-Wextra -Wno-missing-field-initializers -Wall -std=c99'
|
||||
' -pedantic-errors -Werror {} {} -fwrapv {} {} -pipe {} -fvisibility=hidden'
|
||||
).format(
|
||||
optimize,
|
||||
' '.join(sanitize_args),
|
||||
('' if debug else 'N'),
|
||||
stack_protector,
|
||||
missing_braces,
|
||||
'-march=native' if native_optimizations else '',
|
||||
@ -184,13 +193,14 @@ def init_env(
|
||||
)
|
||||
if os.path.exists('.git'):
|
||||
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(
|
||||
'OVERRIDE_LDFLAGS',
|
||||
'-Wall ' + ' '.join(sanitize_args) + ('' if debug else ' -O3')
|
||||
)
|
||||
ldflags = shlex.split(ldflags)
|
||||
ldflags.append('-shared')
|
||||
cppflags += shlex.split(os.environ.get('CPPFLAGS', ''))
|
||||
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
||||
ldflags += shlex.split(os.environ.get('LDFLAGS', ''))
|
||||
if not debug and not sanitize:
|
||||
@ -198,10 +208,10 @@ def init_env(
|
||||
cflags.append('-flto'), ldflags.append('-flto')
|
||||
|
||||
if profile:
|
||||
cflags.append('-DWITH_PROFILER')
|
||||
cppflags.append('-DWITH_PROFILER')
|
||||
cflags.append('-g3')
|
||||
ldflags.append('-lprofiler')
|
||||
return Env(cc, cflags, ldflags)
|
||||
return Env(cc, cppflags, cflags, ldflags)
|
||||
|
||||
|
||||
def kitty_env():
|
||||
@ -210,8 +220,9 @@ def kitty_env():
|
||||
cflags.append('-pthread')
|
||||
# We add 4000 to the primary version because vim turns on SGR mouse mode
|
||||
# automatically if this version is high enough
|
||||
cflags.append('-DPRIMARY_VERSION={}'.format(version[0] + 4000))
|
||||
cflags.append('-DSECONDARY_VERSION={}'.format(version[1]))
|
||||
cppflags = ans.cppflags
|
||||
cppflags.append('-DPRIMARY_VERSION={}'.format(version[0] + 4000))
|
||||
cppflags.append('-DSECONDARY_VERSION={}'.format(version[1]))
|
||||
at_least_version('harfbuzz', 1, 5)
|
||||
cflags.extend(pkg_config('libpng', '--cflags-only-I'))
|
||||
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):
|
||||
src = original_src
|
||||
cflgs = kenv.cflags[:]
|
||||
cppflgs = kenv.cppflags[:]
|
||||
is_special = src in SPECIAL_SOURCES
|
||||
if is_special:
|
||||
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)
|
||||
all_keys.add(key)
|
||||
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):
|
||||
cflags = '-Wall -Werror -fpie'.split()
|
||||
cppflags = []
|
||||
libs = []
|
||||
if args.profile:
|
||||
cflags.append('-DWITH_PROFILER'), cflags.append('-g')
|
||||
cppflags.append('-DWITH_PROFILER'), cflags.append('-g')
|
||||
libs.append('-lprofiler')
|
||||
else:
|
||||
cflags.append('-O3')
|
||||
if for_bundle:
|
||||
cflags.append('-DFOR_BUNDLE')
|
||||
cflags.append('-DPYVER="{}"'.format(sysconfig.get_python_version()))
|
||||
cppflags.append('-DFOR_BUNDLE')
|
||||
cppflags.append('-DPYVER="{}"'.format(sysconfig.get_python_version()))
|
||||
elif sh_launcher:
|
||||
cflags.append('-DFOR_LAUNCHER')
|
||||
cflags.append('-DLIB_DIR_NAME="{}"'.format(args.libdir_name.strip('/')))
|
||||
cppflags.append('-DFOR_LAUNCHER')
|
||||
cppflags.append('-DLIB_DIR_NAME="{}"'.format(args.libdir_name.strip('/')))
|
||||
pylib = get_python_flags(cflags)
|
||||
exe = 'kitty-profile' if args.profile else 'kitty'
|
||||
cppflags += shlex.split(os.environ.get('CPPFLAGS', ''))
|
||||
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
||||
ldflags = shlex.split(os.environ.get('LDFLAGS', ''))
|
||||
cmd = [env.cc] + cflags + [
|
||||
cmd = [env.cc] + cppflags + cflags + [
|
||||
'linux-launcher.c', '-o',
|
||||
os.path.join(launcher_dir, exe)
|
||||
] + ldflags + libs + pylib
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user