File: cmCxxModuleMapper.h

package info (click to toggle)
cmake 4.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 152,348 kB
  • sloc: ansic: 403,894; cpp: 303,807; sh: 4,097; python: 3,582; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 108; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (114 lines) | stat: -rw-r--r-- 3,067 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file LICENSE.rst or https://cmake.org/licensing for details.  */
#pragma once

#include "cmConfigure.h" // IWYU pragma: keep

#include <functional>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cm/optional>
#include <cmext/string_view>

enum class LookupMethod;
struct cmScanDepInfo;

enum class CxxModuleMapFormat
{
  Clang,
  Gcc,
  Msvc,
};

struct CxxBmiLocation
{
  static CxxBmiLocation Unknown();
  static CxxBmiLocation Private();
  static CxxBmiLocation Known(std::string path);

  bool IsKnown() const;
  bool IsPrivate() const;
  std::string const& Location() const;

private:
  CxxBmiLocation();
  CxxBmiLocation(std::string path);

  cm::optional<std::string> BmiLocation;
};

struct CxxModuleLocations
{
  // The path from which all relative paths should be computed. If
  // this is relative, it is relative to the compiler's working
  // directory.
  std::string RootDirectory;

  // A function to convert a full path to a path for the generator.
  std::function<std::string(std::string)> PathForGenerator;

  // Lookup the BMI location of a logical module name.
  std::function<CxxBmiLocation(std::string const&)> BmiLocationForModule;

  // Returns the generator path (if known) for the BMI given a
  // logical module name.
  CxxBmiLocation BmiGeneratorPathForModule(
    std::string const& logical_name) const;
};

struct CxxModuleReference
{
  // The path to the module file used.
  std::string Path;
  // How the module was looked up.
  LookupMethod Method;
};

struct CxxModuleUsage
{
  // The usage requirements for this object.
  std::map<std::string, std::set<std::string>> Usage;

  // The references for this object.
  std::map<std::string, CxxModuleReference> Reference;

  // Add a reference to a module.
  //
  // Returns `true` if it matches how it was found previously, `false` if it
  // conflicts.
  bool AddReference(std::string const& logical, std::string const& loc,
                    LookupMethod method);
};

enum class CxxModuleMapMode
{
  Text,
  Binary,

  Default = Text,
};

// Return the extension to use for a given modulemap format.
cm::static_string_view CxxModuleMapExtension(
  cm::optional<CxxModuleMapFormat> format);

// Fill in module usage information for internal usages.
//
// Returns the set of unresolved module usage requirements (these form an
// import cycle).
std::set<std::string> CxxModuleUsageSeed(
  CxxModuleLocations const& loc, std::vector<cmScanDepInfo> const& objects,
  CxxModuleUsage& usages, bool& private_usage_found);

// Return the contents of the module map in the given format for the
// object file.
std::string CxxModuleMapContent(CxxModuleMapFormat format,
                                CxxModuleLocations const& loc,
                                cmScanDepInfo const& obj,
                                CxxModuleUsage const& usages);

// Return the open mode required for the modmap file format.
CxxModuleMapMode CxxModuleMapOpenMode(CxxModuleMapFormat format);