Skip to content

Commit

Permalink
Merge pull request #162 from nosamad/topic/fix_assertion_with_zig_too…
Browse files Browse the repository at this point in the history
…lchain

Fix: assertion when using zig toolchain
  • Loading branch information
cpsauer authored Jan 30, 2024
2 parents 09fee2f + 097b179 commit c4918fa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ def _parse_headers_from_makefile_deps(d_file_content: str, source_path_for_sanit
# We assume that this Makefile-like dependency file (`*.d`) contains exactly one `target: dependencies` rule.
# There can be an optional space after the target, and long lists of dependencies (often) carry over with a backslash and newline.
# For example, `d_file_content` might be: `"foo.o : foo.cc bar.h \\\n baz.hpp"`.
target, dependencies = d_file_content.split(':', 1)
target, dependencies = d_file_content.split(': ', 1) # Needs to handle absolute Windows paths, like C:\
target = target.strip() # Remove the optional trailing space.
assert target.endswith('.o'), "Something went wrong in makefile parsing to get headers. The target should be an object file. Output:\n" + d_file_content
assert target.endswith(('.o', '.obj')), "Something went wrong in makefile parsing to get headers. The target should be an object file. Output:\n" + d_file_content
# Undo shell-like line wrapping because the newlines aren't eaten by shlex.join. Note also that it's the line wrapping is inconsistently generated across compilers and depends on the lengths of the filenames, so you can't just split on the escaped newlines.
dependencies = dependencies.replace('\\\n', '')
# On Windows, swap out (single) backslash path directory separators for forward slash. Shlex otherwise eats the separators...and Windows gcc intermixes backslash separators with backslash escaped spaces. For a real example of gcc run from Windows, see https://github.com/hedronvision/bazel-compile-commands-extractor/issues/81
Expand Down

0 comments on commit c4918fa

Please sign in to comment.