Skip to content

Fix: assertion when using zig toolchain #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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