Browse Source

Fix deps parsing from striping whitespace on non-deps output

default_compile_flags
vector-of-bool 5 years ago
parent
commit
7cea3a34f7
2 changed files with 8 additions and 7 deletions
  1. +5
    -5
      src/dds/build/deps.cpp
  2. +3
    -2
      src/dds/build/deps.test.cpp

+ 5
- 5
src/dds/build/deps.cpp View File

@@ -48,14 +48,14 @@ msvc_deps_info dds::parse_msvc_output_for_deps(std::string_view output, std::str
auto lines = split_view(output, "\n");
std::string cleaned_output;
deps_info deps;
for (auto line : lines) {
line = trim_view(line);
if (!starts_with(line, leader)) {
cleaned_output += std::string(line);
for (const auto full_line : lines) {
auto trimmed = trim_view(full_line);
if (!starts_with(trimmed, leader)) {
cleaned_output += std::string(full_line);
cleaned_output.push_back('\n');
continue;
}
auto remaining = trim_view(line.substr(leader.size()));
auto remaining = trim_view(trimmed.substr(leader.size()));
deps.inputs.emplace_back(fs::weakly_canonical(remaining));
}
if (!cleaned_output.empty()) {

+ 3
- 2
src/dds/build/deps.test.cpp View File

@@ -30,15 +30,16 @@ TEST_CASE("Parse MSVC deps") {
Note: including file: C:\foo\bar\filepath/thing.hpp
Note: including file: C:\foo\bar\filepath/baz.h
Note: including file: C:\foo\bar\filepath/quux.h
Note: including file: C:\foo\bar\filepath/cats/quux.h
Note: including file: C:\foo\bar\filepath/cats/quux.h
Other line
indented line
Something else
)";

auto res = dds::parse_msvc_output_for_deps(mscv_output, "Note: including file:");
auto& deps = res.deps_info;
auto new_output = res.cleaned_output;
CHECK(new_output == "\nOther line\nSomething else\n");
CHECK(new_output == "\nOther line\n indented line\nSomething else\n");
CHECK(deps.inputs
== std::vector<dds::fs::path>({
"C:\\foo\\bar\\filepath/thing.hpp",

Loading…
Cancel
Save