Coverage Report

Created: 2026-06-15 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmBuildSbomGenerator.h
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
#pragma once
4
5
#include <iosfwd>
6
#include <string>
7
#include <utility>
8
#include <vector>
9
10
#include <cm/memory>
11
12
#include "cmBuildSbomBuilder.h"
13
#include "cmSbomArguments.h"
14
class cmExportSet;
15
class cmGeneratorTarget;
16
class cmLocalGenerator;
17
18
/** \class cmBuildSbomGenerator
19
 * \brief Thin wrapper around cmBuildSbomBuilder for the build-tree SBOM case.
20
 *
21
 * Stored on cmMakefile at configure time.  At generate time,
22
 * ComputeBuildFileGenerators() calls Compute(lg) to resolve export set
23
 * targets and supply the local generator — mirroring
24
 * cmExportBuildFileGenerator.
25
 */
26
class cmBuildSbomGenerator
27
{
28
public:
29
  cmBuildSbomGenerator(cmSbomArguments args,
30
                       std::vector<cmExportSet*> exportSets,
31
                       std::string outputFile)
32
0
    : OutputFile(std::move(outputFile))
33
0
    , Builder(cm::make_unique<cmBuildSbomBuilder>(std::move(args),
34
0
                                                  std::move(exportSets)))
35
0
  {
36
0
  }
37
38
  void Compute(cmLocalGenerator* lg);
39
40
0
  std::string const& GetOutputFile() const { return this->OutputFile; }
41
42
  /** True if this SBOM directly describes `target`.  Used by peer SBOMs to
43
   *  attribute cross-references when install(export) provenance is absent. */
44
  bool CoversTarget(cmGeneratorTarget const* target) const
45
0
  {
46
0
    return this->Builder->CoversTarget(target);
47
0
  }
48
49
  bool GenerateForBuild(std::ostream& os, std::string const& config)
50
0
  {
51
0
    return this->Builder->Generate(os, config);
52
0
  }
53
54
  std::string const& GetPackageName() const
55
0
  {
56
0
    return this->Builder->GetPackageName();
57
0
  }
58
59
  /** Open the output file and write the SBOM document to it. */
60
  bool GenerateForBuild(std::string const& config);
61
62
private:
63
  std::string OutputFile;
64
  std::unique_ptr<cmBuildSbomBuilder> Builder;
65
};