Only define VCS_REV where it is needed

This commit is contained in:
Kovid Goyal 2018-04-29 18:47:14 +05:30
parent 053835afbe
commit bb1374f64e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -203,9 +203,6 @@ def init_env(
cflags = shlex.split(cflags) + shlex.split(
sysconfig.get_config_var('CCSHARED')
)
if os.path.exists('.git'):
rev = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
cppflags.append('-DKITTY_VCS_REV="{}"'.format(rev))
ldflags = os.environ.get(
'OVERRIDE_LDFLAGS',
'-Wall ' + ' '.join(sanitize_args) + ('' if debug else ' -O3')
@ -377,6 +374,10 @@ def compile_c_extension(kenv, module, incremental, compilation_database, all_key
src, defines = SPECIAL_SOURCES[src]
cppflags.extend(map(define, defines))
if src == 'kitty/data-types.c':
if os.path.exists('.git'):
rev = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
cppflags.append(define('KITTY_VCS_REV="{}"'.format(rev)))
cmd = [kenv.cc, '-MMD'] + cppflags + kenv.cflags
key = original_src, os.path.basename(dest)
all_keys.add(key)