Coverage Report

Created: 2026-04-29 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmGccDepfileReader.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmGccDepfileReader.h"
4
5
#include <utility>
6
#include <vector>
7
8
#include <cm/optional>
9
10
#include "cmGccDepfileLexerHelper.h"
11
#include "cmStringAlgorithms.h"
12
#include "cmSystemTools.h"
13
14
cm::optional<cmGccDepfileContent> cmReadGccDepfile(
15
  char const* filePath, std::string const& prefix,
16
  GccDepfilePrependPaths prependPaths)
17
5.81k
{
18
5.81k
  cmGccDepfileLexerHelper helper;
19
5.81k
  if (!helper.readFile(filePath)) {
20
65
    return cm::nullopt;
21
65
  }
22
5.75k
  auto deps = cm::make_optional(std::move(helper).extractContent());
23
24
57.1k
  for (auto& dep : *deps) {
25
81.6k
    for (auto& rule : dep.rules) {
26
81.6k
      if (prependPaths == GccDepfilePrependPaths::All && !prefix.empty() &&
27
0
          !cmSystemTools::FileIsFullPath(rule)) {
28
0
        rule = cmStrCat(prefix, '/', rule);
29
0
      }
30
81.6k
      if (cmSystemTools::FileIsFullPath(rule)) {
31
57.2k
        rule = cmSystemTools::CollapseFullPath(rule);
32
57.2k
      }
33
81.6k
      cmSystemTools::ConvertToLongPath(rule);
34
81.6k
    }
35
57.1k
    for (auto& path : dep.paths) {
36
50.8k
      if (!prefix.empty() && !cmSystemTools::FileIsFullPath(path)) {
37
0
        path = cmStrCat(prefix, '/', path);
38
0
      }
39
50.8k
      if (cmSystemTools::FileIsFullPath(path)) {
40
3.51k
        path = cmSystemTools::CollapseFullPath(path);
41
3.51k
      }
42
50.8k
      cmSystemTools::ConvertToLongPath(path);
43
50.8k
    }
44
57.1k
  }
45
46
5.75k
  return deps;
47
5.81k
}