UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SourceProject.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
9
10namespace uLang
11{
12
13class CArchive;
14class CSourcePackage;
15class CSourceProject;
16
21{
22public:
23
24 virtual ~ISourceSnippet() {}
25
29 virtual CUTF8String GetPath() const = 0;
30 virtual void SetPath(const CUTF8String& Path) = 0;
31
37 virtual TOptional<CUTF8String> GetText() const = 0;
38
46
51 virtual bool IsSnippetValid(Verse::Vst::Snippet& Snippet) const { return false; }
52 virtual uint64_t GetSourceVersion() const { return 0; }
53};
54
59{
60public:
61
64
67
70 virtual ~CSourceModule() = default;
71
72 const CUTF8String& GetName() const { return _Name; }
73 virtual const CUTF8String& GetFilePath() const { return CUTF8String::GetEmpty(); }
76
78
81
85 template<typename FunctionType>
86 bool VisitAll(FunctionType&& Lambda) const;
87 template<typename FunctionType>
88 bool VisitAll(FunctionType&& Lambda); // non-const version
89
91 ULANG_FORCEINLINE bool operator==(const CUTF8StringView& Name) const { return _Name == Name; }
92
93protected:
94
97};
98
103{
104public:
108 {
109 CUTF8String _VersePath; // Verse path of the root module of this package
110 EVerseScope _VerseScope = EVerseScope::PublicUser; // Origin/visibility of Verse code in this package
111 EPackageRole _Role = EPackageRole::Source; // The role this package plays in the project.
112 TOptional<uint32_t> _VerseVersion; // The language version the package targets. Note that this value is ignored for digests, which are assumed to target the latest unstable version.
113 TOptional<uint32_t> _UploadedAtFNVersion; // Only set for constraint `_Role`.
114 bool _bTreatModulesAsImplicit = false; // If true, module macros in this package's source and digest will be treated as implicit
115 TArray<CUTF8String> _DependencyPackages; // Names of packages this package is dependent on
116 TOptional<CUTF8String> _VniDestDir; // Destination directory for VNI generated C++ code (fully qualified)
117 bool _bAllowExperimental = false; // If true, this package can use experimental definitions (but cannot publish in UEFN).
118 bool _bEnableSceneGraph = false; // If true, Scene Graph is enabled. This impacts the asset digest that is generated.
119 bool _bDefsInClassesInAssetManifests = true; // See FVersePackageSettings::_bDefsInClassesInAssetManifests
120
125
127 {
128 Generator->Update(_VersePath.AsCString(), _VersePath.ByteLen(), "SSettings::_VersePath");
129 Generator->Update(&_VerseScope, sizeof(_VerseScope), "SSettings::_VerseScope");
130
131 // Do not hash the Role as this changes before/after we compile when we mark packages as External
132 //Generator->Update(&_Role, sizeof(_Role), "SSettings::_Role");
133
134 if (_VerseVersion.IsSet())
135 {
136 uint32_t VerseVersion = *_VerseVersion;
137 Generator->Update(&VerseVersion, sizeof(VerseVersion), "SSettings::_VerseVersion");
138 }
139
141 {
143 Generator->Update(&UploadVersion, sizeof(UploadVersion), "SSettings::_UploadedAtFNVersion");
144 }
145
146 Generator->Update(&_bTreatModulesAsImplicit, sizeof(_bTreatModulesAsImplicit), "SSettings::_bTreatModulesAsImplicit");
147
150 {
151 Dependencies.Add(&Dependency);
152 }
153 Algo::Sort(Dependencies, [](const uLang::CUTF8String* LHS, const uLang::CUTF8String* RHS) -> bool
154 {
155 return strcmp(LHS->AsCString(), RHS->AsCString()) < 0;
156 });
157
158 for (const uLang::CUTF8String* Dependency : Dependencies)
159 {
160 Generator->Update(Dependency->AsCString(), Dependency->ByteLen(), "SSettings::_DependencyPackages[]");
161 }
162
163 if (_VniDestDir.IsSet())
164 {
166 Generator->Update(VniDestDir.AsCString(), VniDestDir.ByteLen(), "SSettings::_VniDestDir");
167 }
168 Generator->Update(&_bAllowExperimental, sizeof(_bAllowExperimental), "SSettings::_bAllowExperimental");
169 Generator->Update(&_bEnableSceneGraph, sizeof(_bEnableSceneGraph), "SSettings::_bEnableSceneGraph");
170 Generator->Update(&_bDefsInClassesInAssetManifests, sizeof(_bDefsInClassesInAssetManifests), "SSettings::_bDefsInClassesInAssetManifests");
171 }
172 };
173
175 {
179
181 {
182 if (_Snippet.IsValid())
183 {
185 if (Text.IsSet())
186 {
187 Generator->Update(Text->AsCString(), Text->ByteLen(), uLang::CUTF8String("SVersionedDigest::_Snippet - %s", _Snippet->GetPath().AsCString()).AsCString());
188 }
189 }
190
191 Generator->Update(&_EffectiveVerseVersion, sizeof(_EffectiveVerseVersion), "SVersionedDigest::_EffectiveVerseVersion");
192
195 {
196 Dependencies.Add(&Dependency);
197 }
198 Algo::Sort(Dependencies, [](const uLang::CUTF8String* LHS, const uLang::CUTF8String* RHS) -> bool
199 {
200 return strcmp(LHS->AsCString(), RHS->AsCString()) < 0;
201 });
202
203 for (const uLang::CUTF8String* Dependency : Dependencies)
204 {
205 Generator->Update(Dependency->AsCString(), Dependency->ByteLen(), "SVersionedDigest::_DependencyPackages[]");
206 }
207 }
208 };
209
217
218
221
224
227
230 virtual ~CSourcePackage() = default;
231
232 const CUTF8String& GetName() const { return _Name; }
233 const SSettings& GetSettings() const { return _Settings; }
234 virtual EOrigin GetOrigin() const { return EOrigin::Unknown; }
235 virtual const CUTF8String& GetDirPath() const { return CUTF8String::GetEmpty(); }
236 virtual const CUTF8String& GetFilePath() const { return CUTF8String::GetEmpty(); }
238 const FSolFingerprint& GetFingerprint() const { return _Fingerprint; }
239
241
242 void SetName(const CUTF8StringView& NewName) { _Name = NewName; }
243 void SetVersePath(const CUTF8StringView& VersePath) { _Settings._VersePath = VersePath; }
244 void SetVerseScope(const EVerseScope VerseScope) { _Settings._VerseScope = VerseScope; }
245 void SetVerseVersion(const TOptional<uint32_t> VerseVersion) { _Settings._VerseVersion = VerseVersion; }
247 void SetRole(const EPackageRole Role) { _Settings._Role = Role; }
249 void SetFingerprint(FSolFingerprint Fingerprint) { _Fingerprint = Fingerprint; }
252 VERSECOMPILER_API void TruncateVniDestDir(); // Strip parent path from VniDestDir
253
255
256private:
257
259 CUTF8String _Name;
260
262 FSolFingerprint _Fingerprint;
263
264protected:
265
268
269};
270
275{
276public:
277
279 struct SPackage
280 {
282 bool _bReadonly = false;
283 bool _bValkyrieSource = false;
284 };
285
288
293 virtual ~CSourceProject() = default;
294
295 const CUTF8String& GetName() const { return _Name; }
296 virtual const CUTF8String& GetFilePath() const { return CUTF8String::GetEmpty(); }
298
299 VERSECOMPILER_API const SPackage* FindPackage(const CUTF8StringView& PackageName, const CUTF8StringView& PackageVersePath) const;
300 VERSECOMPILER_API const SPackage& FindOrAddPackage(const CUTF8StringView& PackageName, const CUTF8StringView& PackageVersePath);
303
304 VERSECOMPILER_API void TruncateVniDestDirs(); // Strip parent path from all VniDestDirs
305
308
309private:
310
312 CUTF8String _Name;
313};
314
315/* Implementations
316 *****************************************************************************/
317
318template<typename FunctionType>
319bool CSourceModule::VisitAll(FunctionType&& Lambda) const
320{
321 if (!Lambda(*this))
322 {
323 return false;
324 }
325
327 {
328 if (!Submodule->VisitAll(Lambda))
329 {
330 return false;
331 }
332 }
333
334 return true;
335}
336template<typename FunctionType>
337bool CSourceModule::VisitAll(FunctionType&& Lambda) // non-const version
338{
339 if (!Lambda(*this))
340 {
341 return false;
342 }
343
345 {
346 if (!Submodule->VisitAll(Lambda))
347 {
348 return false;
349 }
350 }
351
352 return true;
353}
354
355}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ULANG_FORCEINLINE
Definition Common.h:188
Definition SharedPointer.h:28
Definition SourceProject.h:59
VERSECOMPILER_API void AddSnippet(const uLang::TSRef< ISourceSnippet > &Snippet)
Definition SourceProject.cpp:40
virtual const CUTF8String & GetFilePath() const
Definition SourceProject.h:73
VERSECOMPILER_API TOptional< TSRef< CSourceModule > > FindSubmodule(const CUTF8StringView &ModuleName) const
Definition SourceProject.cpp:35
CSourceModule(const CUTF8StringView &Name)
Construct from name.
Definition SourceProject.h:69
CUTF8String _Name
Name of this module.
Definition SourceProject.h:96
VERSECOMPILER_API bool RemoveSnippet(const uLang::TSRef< ISourceSnippet > &Snippet, bool bRecursive)
Definition SourceProject.cpp:47
ULANG_FORCEINLINE bool operator==(const CUTF8StringView &Name) const
For lookup by name.
Definition SourceProject.h:91
TSRefArray< CSourceModule > _Submodules
Submodules of this module.
Definition SourceProject.h:66
virtual ~CSourceModule()=default
TSRefArray< ISourceSnippet > _SourceSnippets
The source files contained in the module.
Definition SourceProject.h:63
VERSECOMPILER_API CUTF8StringView GetNameFromFile() const
Definition SourceProject.cpp:16
const CUTF8String & GetName() const
Definition SourceProject.h:72
bool VisitAll(FunctionType &&Lambda) const
Definition SourceProject.h:319
Definition SourceProject.h:103
virtual const CUTF8String & GetDirPath() const
Definition SourceProject.h:235
EOrigin
Where the source code of this package originates.
Definition SourceProject.h:212
@ FileSystem
Definition SourceProject.h:215
@ Unknown
Definition SourceProject.h:213
@ Memory
Definition SourceProject.h:214
VERSECOMPILER_API void TruncateVniDestDir()
Definition SourceProject.cpp:80
const SSettings & GetSettings() const
Definition SourceProject.h:233
TOptional< SVersionedDigest > _Digest
Optional digest to be used instead of source if desired.
Definition SourceProject.h:223
VERSECOMPILER_API void GenerateFingerprint(TSRef< ISolFingerprintGenerator > &Generator) const
Definition SourceProject.cpp:94
void SetName(const CUTF8StringView &NewName)
Definition SourceProject.h:242
void SetVerseScope(const EVerseScope VerseScope)
Definition SourceProject.h:244
virtual const CUTF8String & GetFilePath() const
Definition SourceProject.h:236
VERSECOMPILER_API void AddDependencyPackage(const CUTF8StringView &PackageName)
Definition SourceProject.cpp:75
void SetVerseVersion(const TOptional< uint32_t > VerseVersion)
Definition SourceProject.h:245
VERSECOMPILER_API bool RemoveSnippet(const uLang::TSRef< ISourceSnippet > &Snippet)
Definition SourceProject.cpp:89
VERSECOMPILER_API void SetDependencyPackages(TArray< CUTF8String > &&PackageNames)
Definition SourceProject.cpp:70
virtual ~CSourcePackage()=default
const FSolFingerprint & GetFingerprint() const
Definition SourceProject.h:238
void SetFingerprint(FSolFingerprint Fingerprint)
Definition SourceProject.h:249
const CUTF8String & GetName() const
Definition SourceProject.h:232
void SetTreatDefinitionsAsImplicit(bool bTreatAsImplicit)
Definition SourceProject.h:248
void SetVersePath(const CUTF8StringView &VersePath)
Definition SourceProject.h:243
void SetAllowExperimental(const bool bAllowExperimental)
Definition SourceProject.h:246
TOptional< SVersionedDigest > _PublicDigest
The public-only digest, if it exists.
Definition SourceProject.h:226
CSourcePackage(const CUTF8StringView &Name, const TSRef< CSourceModule > &RootModule)
Construct from name.
Definition SourceProject.h:229
VERSECOMPILER_API int32_t GetNumSnippets() const
Definition SourceProject.cpp:59
TSRef< CSourceModule > _RootModule
The root module of this package, equivalent to the _VersePath specified in _Settings.
Definition SourceProject.h:220
virtual EOrigin GetOrigin() const
Definition SourceProject.h:234
SSettings _Settings
Settings, e.g. parsed from .vpackage file.
Definition SourceProject.h:267
void SetRole(const EPackageRole Role)
Definition SourceProject.h:247
Definition SourceProject.h:275
VERSECOMPILER_API const SPackage * FindPackage(const CUTF8StringView &PackageName, const CUTF8StringView &PackageVersePath) const
Definition SourceProject.cpp:150
TArray< SPackage > _Packages
The packages contained in this project.
Definition SourceProject.h:287
VERSECOMPILER_API void AddSnippet(const uLang::TSRef< ISourceSnippet > &Snippet, const CUTF8StringView &PackageName, const CUTF8StringView &PackageVersePath)
Definition SourceProject.cpp:173
VERSECOMPILER_API int32_t GetNumSnippets() const
Definition SourceProject.cpp:140
CSourceProject(const CUTF8StringView &Name)
Construct from name.
Definition SourceProject.h:290
virtual const CUTF8String & GetFilePath() const
Definition SourceProject.h:296
VERSECOMPILER_API const SPackage & FindOrAddPackage(const CUTF8StringView &PackageName, const CUTF8StringView &PackageVersePath)
Definition SourceProject.cpp:160
virtual ~CSourceProject()=default
VERSECOMPILER_API void TruncateVniDestDirs()
Definition SourceProject.cpp:191
VERSECOMPILER_API bool RemoveSnippet(const uLang::TSRef< ISourceSnippet > &Snippet)
Definition SourceProject.cpp:178
const CUTF8String & GetName() const
Definition SourceProject.h:295
void PopulateTransitiveDependencyMap(uLang::TMap< const CSourcePackage *, uLang::TArray< const CSourcePackage * > > &OutMap)
Definition SourceProject.cpp:199
VERSECOMPILER_API void GeneratePackageFingerprints(TSRef< ISolFingerprintGenerator > &Generator)
Definition SourceProject.cpp:273
Definition UTF8StringView.h:15
Definition SourceProject.h:21
virtual CUTF8String GetPath() const =0
virtual TOptional< CUTF8String > GetText() const =0
virtual void SetPath(const CUTF8String &Path)=0
virtual uint64_t GetSourceVersion() const
Definition SourceProject.h:52
virtual void SetVst(TSRef< Verse::Vst::Snippet > Snippet)=0
virtual TOptional< TSRef< Verse::Vst::Snippet > > GetVst() const =0
virtual bool IsSnippetValid(Verse::Vst::Snippet &Snippet) const
Definition SourceProject.h:51
virtual ~ISourceSnippet()
Definition SourceProject.h:24
Definition Array.h:51
ULANG_FORCEINLINE int32_t Add(ElementType &&Item)
Definition Array.h:1587
Definition Map.h:13
Definition SharedPointerArray.h:21
Definition SharedPointer.h:77
static const TUTF8String & GetEmpty()
Definition UTF8String.h:262
ULANG_FORCEINLINE const char * AsCString() const
Definition UTF8String.h:50
ULANG_FORCEINLINE int32_t ByteLen() const
Definition UTF8String.h:46
Definition VerseScope.h:13
ULANG_FORCEINLINE void Sort(RangeType &&Range)
Definition Sort.h:18
Definition VVMEngineEnvironment.h:23
EPackageRole
Definition PackageRole.h:15
Definition VstNode.h:1828
Definition VstNode.h:885
Definition SourceProject.h:108
TOptional< uint32_t > _UploadedAtFNVersion
Definition SourceProject.h:113
TArray< CUTF8String > _DependencyPackages
Definition SourceProject.h:115
uint32_t GetUploadedAtFNVersion(uint32_t Default) const
Definition SourceProject.h:121
TOptional< CUTF8String > _VniDestDir
Definition SourceProject.h:116
void GenerateFingerprint(TSRef< ISolFingerprintGenerator > &Generator) const
Definition SourceProject.h:126
CUTF8String _VersePath
Definition SourceProject.h:109
bool _bDefsInClassesInAssetManifests
Definition SourceProject.h:119
bool _bAllowExperimental
Definition SourceProject.h:117
EVerseScope _VerseScope
Definition SourceProject.h:110
TOptional< uint32_t > _VerseVersion
Definition SourceProject.h:112
bool _bEnableSceneGraph
Definition SourceProject.h:118
bool _bTreatModulesAsImplicit
Definition SourceProject.h:114
EPackageRole _Role
Definition SourceProject.h:111
Definition SourceProject.h:175
TArray< CUTF8String > _DependencyPackages
Definition SourceProject.h:178
void GenerateFingerprint(TSRef< ISolFingerprintGenerator > &Generator) const
Definition SourceProject.h:180
uint32_t _EffectiveVerseVersion
Definition SourceProject.h:177
TSRef< ISourceSnippet > _Snippet
Definition SourceProject.h:176
Entry for a package contained in this project.
Definition SourceProject.h:280
bool _bValkyrieSource
Definition SourceProject.h:283
bool _bReadonly
Definition SourceProject.h:282
TSPtr< CSourcePackage > _Package
Definition SourceProject.h:281
Definition CompilerTypes.h:30
Definition Optional.h:23
const OptionalType & Get(const OptionalType &DefaultValue) const
Definition Optional.h:180
ULANG_FORCEINLINE bool IsSet() const
Definition Optional.h:161