Skip to content

Commit

Permalink
Fix compile_commands.json
Browse files Browse the repository at this point in the history
Removes newlines in JSON strings and
normalize path to avoid backslash in JSON strings.
  • Loading branch information
lieser committed May 2, 2023
1 parent 1881cd8 commit 2088a0b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,13 @@ def insert_join(match):
output += lines[idx] + "\n"
idx += 1

return self.join_pattern.sub(insert_join, self.value_pattern.sub(insert_value, output)) + '\n'
subsituded_template = self.join_pattern.sub(insert_join, self.value_pattern.sub(insert_value, output))

# Prevent newlines being added if the template was not a multiline string
if len(lines) == 1 and not template.endswith('\n'):
return subsituded_template.rstrip('\n')

return subsituded_template + '\n'

try:
return SimpleTemplate(variables).substitute(template_text)
Expand Down Expand Up @@ -2064,7 +2070,7 @@ def choose_cxx_exe():
if options.compiler_cache is None:
return cxx
else:
return '%s %s' % (options.compiler_cache, cxx)
return '%s %s' % (normalize_source_path(options.compiler_cache), cxx)

def extra_libs(libs, cc):
if libs is None:
Expand Down Expand Up @@ -2102,7 +2108,7 @@ def test_exe_extra_ldflags():
'internal_headers': sorted([os.path.basename(h) for h in build_paths.internal_headers]),
'external_headers': sorted([os.path.basename(h) for h in build_paths.external_headers]),

'abs_root_dir': os.path.dirname(os.path.realpath(__file__)),
'abs_root_dir': normalize_source_path(os.path.dirname(os.path.realpath(__file__))),

'base_dir': source_paths.base_dir,
'src_dir': source_paths.src_dir,
Expand Down

0 comments on commit 2088a0b

Please sign in to comment.