not-uasset 文件过滤规则

可以控制 not-uasset 文件进 Pak 的规则。AutomationTool/Scripts/CopyBuildToStagingDirectory.Automation.cs#L1887

Scripts/CopyBuildToStagingDirectory.Automation.cs
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/// <summary>
/// Reads Default/BasePakFileRules.ini and returns all PakFileRules objects that apply for this deployment
/// </summary>
/// <param name="Params"></param>
/// <param name="SC"></param>
private static List<PakFileRules> GetPakFileRules(ProjectParams Params, DeploymentContext SC)
{
bool bWarnedAboutMultipleTargets = false;
bool bFoundConfig = false;

List<ConfigFile> ConfigFiles = new List<ConfigFile>();
FileReference BaseConfigFileReference = FileReference.Combine(SC.EngineRoot, "Config", "BasePakFileRules.ini");
if (FileReference.Exists(BaseConfigFileReference))
{
ConfigFiles.Add(new ConfigFile(BaseConfigFileReference));
bFoundConfig = true;
}

FileReference ProjectConfigFileReference = FileReference.Combine(SC.ProjectRoot, "Config", "DefaultPakFileRules.ini");
if (FileReference.Exists(ProjectConfigFileReference))
{
ConfigFiles.Add(new ConfigFile(ProjectConfigFileReference));
bFoundConfig = true;
}

if (!bFoundConfig)
{
return null;
}

bool bChunkedBuild = SC.PlatformUsesChunkManifests && DoesChunkPakManifestExist(Params, SC);

ConfigHierarchy PakRulesConfig = new ConfigHierarchy(ConfigFiles);

List<PakFileRules> RulesList = new List<PakFileRules>();
foreach (string SectionName in PakRulesConfig.SectionNames)
{
//LogInformation("Building PakFileRules for Section {0}", SectionName);

bool bOnlyChunkedBuilds = false;
if (!PakRulesConfig.TryGetValue(SectionName, "bOnlyChunkedBuilds", out bOnlyChunkedBuilds))
{
bOnlyChunkedBuilds = false;
}

bool bOnlyNonChunkedBuilds = false;
if (!PakRulesConfig.TryGetValue(SectionName, "bOnlyNonChunkedBuilds", out bOnlyNonChunkedBuilds))
{
bOnlyNonChunkedBuilds = false;
}

if (bChunkedBuild && bOnlyNonChunkedBuilds)
{
continue;
}

if(!bChunkedBuild && bOnlyChunkedBuilds)
{
continue;
}

string PlatformString;
if (PakRulesConfig.TryGetValue(SectionName, "Platforms", out PlatformString))
{
string[] PlatformStrings = PlatformString.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool bMatches = false;

// Check platform string
foreach (string Platform in PlatformStrings)
{
if (SC.StageTargetPlatform.PlatformType.ToString().Equals(Platform, StringComparison.OrdinalIgnoreCase))
{
bMatches = true;
break;
}
else if (SC.StageTargetPlatform.IniPlatformType.ToString().Equals(Platform, StringComparison.OrdinalIgnoreCase))
{
bMatches = true;
break;
}
}

if (!bMatches)
{
//LogInformation("No matching platform for PakFileRules for Section {0} : {1}, {2}", SectionName, SC.StageTargetPlatform.PlatformType.ToString(), SC.StageTargetPlatform.IniPlatformType.ToString());
continue;
}
}

string TargetString;
if (PakRulesConfig.TryGetValue(SectionName, "Targets", out TargetString))
{
string[] TargetStrings = TargetString.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool bMatches = false;

// Check target string
foreach (string Target in TargetStrings)
{
foreach (UnrealTargetConfiguration C in SC.StageTargetConfigurations)
{
if (C.ToString() == Target)
{
bMatches = true;
break;
}
}
}

if (!bMatches)
{
continue;
}
else if (SC.StageTargetConfigurations.Count > 0 && !bWarnedAboutMultipleTargets)
{
bWarnedAboutMultipleTargets = true;
LogInformation("Staging with more than one target, PakFileRules may apply too many rules!");
}
}

PakFileRules PakRules = new PakFileRules();
PakRules.Name = SectionName;
PakRulesConfig.TryGetValue(SectionName, "bExcludeFromPaks", out PakRules.bExcludeFromPaks);
PakRulesConfig.TryGetValue(SectionName, "bOverrideChunkManifest", out PakRules.bOverrideChunkManifest);
PakRulesConfig.TryGetValue(SectionName, "bDisabled", out PakRules.bDisabled);
string PakString;
PakRulesConfig.TryGetValue(SectionName, "OverridePaks", out PakString);

if (PakString != null && PakString.Length > 0)
{
PakRules.OverridePaks = PakString.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
else
{
PakRules.OverridePaks = null;
}

if (PakRules.bExcludeFromPaks && PakRules.OverridePaks != null)
{
LogWarning("Error in PakFileRules {0}, set to exclude but also sets override!", PakRules.Name);
continue;
}
else if (!PakRules.bExcludeFromPaks && PakRules.OverridePaks == null)
{
LogWarning("Error in PakFileRules {0}, set to include but did not specify paks!", PakRules.Name);
continue;
}

IReadOnlyList<string> FilesEnumberable;
if (PakRulesConfig.TryGetValues(SectionName, "Files", out FilesEnumberable))
{
// Only add if we have actual files, we can end up with none due to config overriding
PakRules.Filter = new FileFilter();
foreach (string FileFilter in FilesEnumberable)
{
//LogInformation("Adding to PakFileRules for Section {0} : {1}", SectionName, FileFilter);
PakRules.Filter.AddRule(FileFilter);
}

RulesList.Add(PakRules);
}
}

return RulesList;
}

配置规则,在项目 Config 下创建一个 DefaultPakFileRules.ini:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
; These rules are applied in order, the first rule that applies per file is taken and no others are evaluated
; [SectionName]
; bOverrideChunkManifest=false ; If true this allows overriding assignments from the cooker
; bExcludeFromPaks=false ; If true this removes entirely, cannot coexist with overridepaks
; OverridePaks="pakchunk1" ; If set this will override pak list, comma separated
; Platforms="iOS,Android" ; If set this rule will only apply to these platforms
; Targets="Shipping,Test" ; If set this rule will only apply to these configurations
; bOnlyChunkedBuilds=true ; If set this rule will only apply to chunked builds
; bOnlyNonChunkedBuilds=true ; If set this rule will only apply to non-chunked builds
; +Files=".../*FileMask*.*" ; List of file masks to apply to, using the C# FileFilter class


[ExcludeContentForMobile]
; Exclude specific large textures on mobile platforms, this was moved from CopyBuildToStagingDirectory.cs
; This can be added to in a game's DefaultPakFileRules.ini by using the same sections, and new sections can be added
; To remove this rule, use !Files to clear the list of file paths
Platforms="Android,iOS,tvOS"
bExcludeFromPaks=true
bOverrideChunkManifest=true
+Files=".../Engine/Content/EngineMaterials/DefaultBloomKernel.*"