@@ -1366,10 +1366,35 @@ List<string> skipFiles
1366
1366
}
1367
1367
1368
1368
// Write all unity sections together at the beginning of the .bff just after the header.
1369
- foreach ( var unityFile in _unities . Keys . OrderBy ( u => u . UnityName ) )
1369
+ if ( _unities . Any ( ) )
1370
1370
{
1371
- using ( bffWholeFileGenerator . Declare ( "unityFile" , unityFile ) )
1372
- bffWholeFileGenerator . Write ( Template . ConfigurationFile . UnitySection ) ;
1371
+ foreach ( var unityFile in _unities . Keys . OrderBy ( u => u . UnityName ) )
1372
+ {
1373
+ using ( bffWholeFileGenerator . Declare ( "unityFile" , unityFile ) )
1374
+ bffWholeFileGenerator . Write ( Template . ConfigurationFile . UnitySection ) ;
1375
+
1376
+ // Record the unities in the autocleanupdb to allow auto removal when they become stale.
1377
+ // Note that can't record them as 'generated', since they are created by FastBuild and not by us.
1378
+ int nbUnities = 1 ;
1379
+ if ( unityFile . UnityNumFiles != FileGeneratorUtilities . RemoveLineTag )
1380
+ {
1381
+ if ( ! int . TryParse ( unityFile . UnityNumFiles , out nbUnities ) )
1382
+ throw new Error ( "'{0}' cannot be converted to int!" , unityFile . UnityNumFiles ) ;
1383
+ }
1384
+
1385
+ string outputPattern = unityFile . UnityOutputPattern == FileGeneratorUtilities . RemoveLineTag ? Sharpmake . Generators . FastBuild . Bff . Unity . DefaultUnityOutputPatternExtension : unityFile . UnityOutputPattern ;
1386
+ int wildcardIndex = outputPattern . IndexOf ( '*' ) ;
1387
+ if ( wildcardIndex == - 1 )
1388
+ throw new Error ( "UnityOutputPattern must include a '*', but none was found in '{0}'!" , unityFile . UnityNumFiles ) ;
1389
+
1390
+ string firstStringChunk = outputPattern . Substring ( 0 , wildcardIndex ) ;
1391
+ string lastStringChunk = outputPattern . Substring ( wildcardIndex + 1 ) ;
1392
+ for ( int i = 1 ; i <= nbUnities ; ++ i )
1393
+ {
1394
+ string fullPath = Path . Combine ( unityFile . UnityFullOutputPath , $ "{ firstStringChunk } { i } { lastStringChunk } ") ;
1395
+ Util . RecordInAutoCleanupDatabase ( fullPath ) ;
1396
+ }
1397
+ }
1373
1398
}
1374
1399
1375
1400
// Now combine all the streams.
@@ -1878,6 +1903,7 @@ private void ConfigureUnities(IGenerationContext context, Dictionary<Project.Con
1878
1903
{
1879
1904
// Note that the UnityName and UnityOutputPattern are intentionally left empty: they will be set in the Resolve
1880
1905
UnityOutputPath = CurrentBffPathKeyCombine ( Util . PathGetRelative ( context . ProjectDirectoryCapitalized , conf . FastBuildUnityPath , true ) ) ,
1906
+ UnityFullOutputPath = Path . Combine ( context . ProjectDirectoryCapitalized , conf . FastBuildUnityPath ) ,
1881
1907
UnityInputIsolateWritableFiles = conf . FastBuildUnityInputIsolateWritableFiles . ToString ( ) . ToLower ( ) ,
1882
1908
UnityInputIsolateWritableFilesLimit = conf . FastBuildUnityInputIsolateWritableFiles ? conf . FastBuildUnityInputIsolateWritableFilesLimit . ToString ( ) : FileGeneratorUtilities . RemoveLineTag ,
1883
1909
UnityPCH = conf . PrecompHeader ?? FileGeneratorUtilities . RemoveLineTag ,
0 commit comments