|
24 | 24 |
|
25 | 25 | namespace swift {
|
26 | 26 |
|
27 |
| - class SerializationOptions { |
28 |
| - SerializationOptions(const SerializationOptions &) = delete; |
29 |
| - void operator=(const SerializationOptions &) = delete; |
| 27 | +class SerializationOptions { |
| 28 | +public: |
| 29 | + SerializationOptions() = default; |
| 30 | + SerializationOptions(SerializationOptions &&) = default; |
| 31 | + SerializationOptions &operator=(SerializationOptions &&) = default; |
| 32 | + SerializationOptions(const SerializationOptions &) = default; |
| 33 | + SerializationOptions &operator=(const SerializationOptions &) = default; |
| 34 | + ~SerializationOptions() = default; |
| 35 | + |
| 36 | + StringRef OutputPath; |
| 37 | + StringRef DocOutputPath; |
| 38 | + StringRef SourceInfoOutputPath; |
| 39 | + std::string ABIDescriptorPath; |
| 40 | + bool emptyABIDescriptor = false; |
| 41 | + llvm::VersionTuple UserModuleVersion; |
| 42 | + std::set<std::string> AllowableClients; |
| 43 | + std::string SDKName; |
| 44 | + std::string SDKVersion; |
| 45 | + |
| 46 | + StringRef GroupInfoPath; |
| 47 | + StringRef ImportedHeader; |
| 48 | + StringRef ModuleLinkName; |
| 49 | + StringRef ModuleInterface; |
| 50 | + std::vector<std::string> ExtraClangOptions; |
| 51 | + std::vector<swift::PluginSearchOption> PluginSearchOptions; |
| 52 | + |
| 53 | + /// Path prefixes that should be rewritten in debug info. |
| 54 | + PathRemapper DebuggingOptionsPrefixMap; |
| 55 | + |
| 56 | + /// Obfuscate the serialized paths so we don't have the actual paths encoded |
| 57 | + /// in the .swiftmodule file. |
| 58 | + PathObfuscator PathObfuscator; |
| 59 | + |
| 60 | + /// Describes a single-file dependency for this module, along with the |
| 61 | + /// appropriate strategy for how to verify if it's up-to-date. |
| 62 | + class FileDependency { |
| 63 | + /// The size of the file on disk, in bytes. |
| 64 | + uint64_t Size : 62; |
| 65 | + |
| 66 | + /// A dependency can be either hash-based or modification-time-based. |
| 67 | + bool IsHashBased : 1; |
| 68 | + |
| 69 | + /// The dependency path can be absolute or relative to the SDK |
| 70 | + bool IsSDKRelative : 1; |
| 71 | + |
| 72 | + union { |
| 73 | + /// The last modification time of the file. |
| 74 | + uint64_t ModificationTime; |
| 75 | + |
| 76 | + /// The xxHash of the full contents of the file. |
| 77 | + uint64_t ContentHash; |
| 78 | + }; |
| 79 | + |
| 80 | + /// The path to the dependency. |
| 81 | + std::string Path; |
| 82 | + |
| 83 | + FileDependency(uint64_t size, bool isHash, uint64_t hashOrModTime, |
| 84 | + StringRef path, bool isSDKRelative) |
| 85 | + : Size(size), IsHashBased(isHash), IsSDKRelative(isSDKRelative), |
| 86 | + ModificationTime(hashOrModTime), Path(path) {} |
30 | 87 |
|
31 | 88 | public:
|
32 |
| - SerializationOptions() = default; |
33 |
| - SerializationOptions(SerializationOptions &&) = default; |
34 |
| - SerializationOptions &operator=(SerializationOptions &&) = default; |
35 |
| - ~SerializationOptions() = default; |
36 |
| - |
37 |
| - StringRef OutputPath; |
38 |
| - StringRef DocOutputPath; |
39 |
| - StringRef SourceInfoOutputPath; |
40 |
| - std::string ABIDescriptorPath; |
41 |
| - bool emptyABIDescriptor = false; |
42 |
| - llvm::VersionTuple UserModuleVersion; |
43 |
| - std::set<std::string> AllowableClients; |
44 |
| - std::string SDKName; |
45 |
| - std::string SDKVersion; |
46 |
| - |
47 |
| - StringRef GroupInfoPath; |
48 |
| - StringRef ImportedHeader; |
49 |
| - StringRef ModuleLinkName; |
50 |
| - StringRef ModuleInterface; |
51 |
| - std::vector<std::string> ExtraClangOptions; |
52 |
| - std::vector<swift::PluginSearchOption> PluginSearchOptions; |
53 |
| - |
54 |
| - /// Path prefixes that should be rewritten in debug info. |
55 |
| - PathRemapper DebuggingOptionsPrefixMap; |
56 |
| - |
57 |
| - /// Obfuscate the serialized paths so we don't have the actual paths encoded |
58 |
| - /// in the .swiftmodule file. |
59 |
| - PathObfuscator PathObfuscator; |
60 |
| - |
61 |
| - /// Describes a single-file dependency for this module, along with the |
62 |
| - /// appropriate strategy for how to verify if it's up-to-date. |
63 |
| - class FileDependency { |
64 |
| - /// The size of the file on disk, in bytes. |
65 |
| - uint64_t Size : 62; |
66 |
| - |
67 |
| - /// A dependency can be either hash-based or modification-time-based. |
68 |
| - bool IsHashBased : 1; |
69 |
| - |
70 |
| - /// The dependency path can be absolute or relative to the SDK |
71 |
| - bool IsSDKRelative : 1; |
72 |
| - |
73 |
| - union { |
74 |
| - /// The last modification time of the file. |
75 |
| - uint64_t ModificationTime; |
76 |
| - |
77 |
| - /// The xxHash of the full contents of the file. |
78 |
| - uint64_t ContentHash; |
79 |
| - }; |
80 |
| - |
81 |
| - /// The path to the dependency. |
82 |
| - std::string Path; |
83 |
| - |
84 |
| - FileDependency(uint64_t size, bool isHash, uint64_t hashOrModTime, |
85 |
| - StringRef path, bool isSDKRelative): |
86 |
| - Size(size), IsHashBased(isHash), IsSDKRelative(isSDKRelative), |
87 |
| - ModificationTime(hashOrModTime), Path(path) {} |
88 |
| - public: |
89 |
| - FileDependency() = delete; |
90 |
| - |
91 |
| - /// Creates a new hash-based file dependency. |
92 |
| - static FileDependency |
93 |
| - hashBased(StringRef path, bool isSDKRelative, uint64_t size, uint64_t hash) { |
94 |
| - return FileDependency(size, /*isHash*/true, hash, path, isSDKRelative); |
95 |
| - } |
96 |
| - |
97 |
| - /// Creates a new modification time-based file dependency. |
98 |
| - static FileDependency |
99 |
| - modTimeBased(StringRef path, bool isSDKRelative, uint64_t size, uint64_t mtime) { |
100 |
| - return FileDependency(size, /*isHash*/false, mtime, path, isSDKRelative); |
101 |
| - } |
102 |
| - |
103 |
| - /// Updates the last-modified time of this dependency. |
104 |
| - /// If the dependency is a hash-based dependency, it becomes |
105 |
| - /// modification time-based. |
106 |
| - void setLastModificationTime(uint64_t mtime) { |
107 |
| - IsHashBased = false; |
108 |
| - ModificationTime = mtime; |
109 |
| - } |
110 |
| - |
111 |
| - /// Updates the content hash of this dependency. |
112 |
| - /// If the dependency is a modification time-based dependency, it becomes |
113 |
| - /// hash-based. |
114 |
| - void setContentHash(uint64_t hash) { |
115 |
| - IsHashBased = true; |
116 |
| - ContentHash = hash; |
117 |
| - } |
118 |
| - |
119 |
| - /// Determines if this dependency is hash-based and should be validated |
120 |
| - /// based on content hash. |
121 |
| - bool isHashBased() const { return IsHashBased; } |
122 |
| - |
123 |
| - /// Determines if this dependency is absolute or relative to the SDK. |
124 |
| - bool isSDKRelative() const { return IsSDKRelative; } |
125 |
| - |
126 |
| - /// Determines if this dependency is hash-based and should be validated |
127 |
| - /// based on modification time. |
128 |
| - bool isModificationTimeBased() const { return !IsHashBased; } |
129 |
| - |
130 |
| - /// Gets the modification time, if this is a modification time-based |
131 |
| - /// dependency. |
132 |
| - uint64_t getModificationTime() const { |
133 |
| - assert(isModificationTimeBased() && |
134 |
| - "cannot get modification time for hash-based dependency"); |
135 |
| - return ModificationTime; |
136 |
| - } |
137 |
| - |
138 |
| - /// Gets the content hash, if this is a hash-based |
139 |
| - /// dependency. |
140 |
| - uint64_t getContentHash() const { |
141 |
| - assert(isHashBased() && |
142 |
| - "cannot get content hash for mtime-based dependency"); |
143 |
| - return ContentHash; |
144 |
| - } |
145 |
| - |
146 |
| - StringRef getPath() const { return Path; } |
147 |
| - uint64_t getSize() const { return Size; } |
148 |
| - }; |
149 |
| - ArrayRef<FileDependency> Dependencies; |
150 |
| - ArrayRef<std::string> PublicDependentLibraries; |
151 |
| - |
152 |
| - bool AutolinkForceLoad = false; |
153 |
| - bool SerializeAllSIL = false; |
154 |
| - bool SerializeOptionsForDebugging = false; |
155 |
| - bool IsSIB = false; |
156 |
| - bool DisableCrossModuleIncrementalInfo = false; |
157 |
| - bool StaticLibrary = false; |
158 |
| - bool HermeticSealAtLink = false; |
159 |
| - bool EmbeddedSwiftModule = false; |
160 |
| - bool IsOSSA = false; |
161 |
| - bool SkipNonExportableDecls = false; |
162 |
| - bool ExplicitModuleBuild = false; |
163 |
| - bool EnableSerializationRemarks = false; |
| 89 | + FileDependency() = delete; |
| 90 | + |
| 91 | + /// Creates a new hash-based file dependency. |
| 92 | + static FileDependency hashBased(StringRef path, bool isSDKRelative, |
| 93 | + uint64_t size, uint64_t hash) { |
| 94 | + return FileDependency(size, /*isHash*/ true, hash, path, isSDKRelative); |
| 95 | + } |
| 96 | + |
| 97 | + /// Creates a new modification time-based file dependency. |
| 98 | + static FileDependency modTimeBased(StringRef path, bool isSDKRelative, |
| 99 | + uint64_t size, uint64_t mtime) { |
| 100 | + return FileDependency(size, /*isHash*/ false, mtime, path, isSDKRelative); |
| 101 | + } |
| 102 | + |
| 103 | + /// Updates the last-modified time of this dependency. |
| 104 | + /// If the dependency is a hash-based dependency, it becomes |
| 105 | + /// modification time-based. |
| 106 | + void setLastModificationTime(uint64_t mtime) { |
| 107 | + IsHashBased = false; |
| 108 | + ModificationTime = mtime; |
| 109 | + } |
| 110 | + |
| 111 | + /// Updates the content hash of this dependency. |
| 112 | + /// If the dependency is a modification time-based dependency, it becomes |
| 113 | + /// hash-based. |
| 114 | + void setContentHash(uint64_t hash) { |
| 115 | + IsHashBased = true; |
| 116 | + ContentHash = hash; |
| 117 | + } |
| 118 | + |
| 119 | + /// Determines if this dependency is hash-based and should be validated |
| 120 | + /// based on content hash. |
| 121 | + bool isHashBased() const { return IsHashBased; } |
| 122 | + |
| 123 | + /// Determines if this dependency is absolute or relative to the SDK. |
| 124 | + bool isSDKRelative() const { return IsSDKRelative; } |
| 125 | + |
| 126 | + /// Determines if this dependency is hash-based and should be validated |
| 127 | + /// based on modification time. |
| 128 | + bool isModificationTimeBased() const { return !IsHashBased; } |
| 129 | + |
| 130 | + /// Gets the modification time, if this is a modification time-based |
| 131 | + /// dependency. |
| 132 | + uint64_t getModificationTime() const { |
| 133 | + assert(isModificationTimeBased() && |
| 134 | + "cannot get modification time for hash-based dependency"); |
| 135 | + return ModificationTime; |
| 136 | + } |
| 137 | + |
| 138 | + /// Gets the content hash, if this is a hash-based |
| 139 | + /// dependency. |
| 140 | + uint64_t getContentHash() const { |
| 141 | + assert(isHashBased() && |
| 142 | + "cannot get content hash for mtime-based dependency"); |
| 143 | + return ContentHash; |
| 144 | + } |
| 145 | + |
| 146 | + StringRef getPath() const { return Path; } |
| 147 | + uint64_t getSize() const { return Size; } |
164 | 148 | };
|
| 149 | + ArrayRef<FileDependency> Dependencies; |
| 150 | + ArrayRef<std::string> PublicDependentLibraries; |
| 151 | + |
| 152 | + bool AutolinkForceLoad = false; |
| 153 | + bool SerializeAllSIL = false; |
| 154 | + bool SerializeOptionsForDebugging = false; |
| 155 | + bool IsSIB = false; |
| 156 | + bool DisableCrossModuleIncrementalInfo = false; |
| 157 | + bool StaticLibrary = false; |
| 158 | + bool HermeticSealAtLink = false; |
| 159 | + bool EmbeddedSwiftModule = false; |
| 160 | + bool IsOSSA = false; |
| 161 | + bool SkipNonExportableDecls = false; |
| 162 | + bool ExplicitModuleBuild = false; |
| 163 | + bool EnableSerializationRemarks = false; |
| 164 | +}; |
165 | 165 |
|
166 | 166 | } // end namespace swift
|
167 | 167 | #endif
|
0 commit comments