@@ -192,7 +192,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
192
192
}
193
193
194
194
UpdateMaxPatchForSprint ( taskVersionInfo [ t . Value . Name ] , currentSprint , ref maxPatchForCurrentSprint ) ;
195
- CheckForDuplicates ( t . Value . Name , taskVersionInfo [ t . Value . Name ] . configTaskVersionMapping ) ;
195
+ CheckForDuplicates ( t . Value . Name , taskVersionInfo [ t . Value . Name ] . configTaskVersionMapping , checkGlobalVersion : false ) ;
196
196
}
197
197
198
198
if ( tasksNeedingUpdates . Count > 0 )
@@ -201,11 +201,14 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
201
201
}
202
202
203
203
// bump patch number for global if any tasks invalidated or if there is no existing global version
204
- if ( taskVersionInfo . Values . Any ( x => x . versionsUpdated . Any ( ) ) || globalVersion is null )
204
+ bool anyTaskVersionUpdated = taskVersionInfo . Values . Any ( x => x . versionsUpdated . Any ( ) ) ;
205
+ bool noCurrentGlobalVersion = globalVersion is null ;
206
+ bool maxPatchForCurrentSprintGreaterOrEqualToGlobalPatch = globalVersion is not null && maxPatchForCurrentSprint >= globalVersion . Patch ;
207
+ if ( anyTaskVersionUpdated || noCurrentGlobalVersion || maxPatchForCurrentSprintGreaterOrEqualToGlobalPatch )
205
208
{
206
209
maxPatchForCurrentSprint = maxPatchForCurrentSprint + 1 ;
207
210
208
- Console . WriteLine ( $ "Global version: maxPatchForCurrentSprint = maxPatchForCurrentSprint + 1") ;
211
+ Console . WriteLine ( $ "Global version: maxPatchForCurrentSprint = maxPatchForCurrentSprint + 1 anyTaskVersionUpdated= { anyTaskVersionUpdated } noCurrentGlobalVersion= { noCurrentGlobalVersion } maxPatchForCurrentSprintGreaterOrEqualToGlobalPatch= { maxPatchForCurrentSprintGreaterOrEqualToGlobalPatch } ") ;
209
212
}
210
213
211
214
Console . WriteLine ( $ "Global version update: globalVersion = { globalVersion } maxPatchForCurrentSprint={ maxPatchForCurrentSprint } ") ;
@@ -218,7 +221,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
218
221
IEnumerable < string > configsList = FilterConfigsForTask ( configs , t ) ;
219
222
HashSet < Config . ConfigRecord > targetConfigs = GetConfigRecords ( configsList , writeUpdates ) ;
220
223
UpdateVersionsForTask ( t . Value . Name , taskVersionInfo [ t . Value . Name ] , targetConfigs , currentSprint , globalVersionPath , globalVersion , generatedFolder ) ;
221
- CheckForDuplicates ( t . Value . Name , taskVersionInfo [ t . Value . Name ] . configTaskVersionMapping ) ;
224
+ CheckForDuplicates ( t . Value . Name , taskVersionInfo [ t . Value . Name ] . configTaskVersionMapping , checkGlobalVersion : true ) ;
222
225
}
223
226
}
224
227
@@ -264,7 +267,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
264
267
HashSet < Config . ConfigRecord > targetConfigs = GetConfigRecords ( configsList , writeUpdates ) ;
265
268
266
269
UpdateVersionsGlobal ( t . Value . Name , taskVersionInfo [ t . Value . Name ] , targetConfigs , globalVersion ) ;
267
- CheckForDuplicates ( t . Value . Name , taskVersionInfo [ t . Value . Name ] . configTaskVersionMapping ) ;
270
+ CheckForDuplicates ( t . Value . Name , taskVersionInfo [ t . Value . Name ] . configTaskVersionMapping , checkGlobalVersion : true ) ;
268
271
}
269
272
}
270
273
@@ -335,15 +338,25 @@ private static IEnumerable<string> FilterConfigsForTask(string? configs, KeyValu
335
338
return configsList ;
336
339
}
337
340
338
- private static void CheckForDuplicates ( string task , Dictionary < Config . ConfigRecord , TaskVersion > configTaskVersionMapping )
341
+ private static void CheckForDuplicates ( string task , Dictionary < Config . ConfigRecord , TaskVersion > configTaskVersionMapping , bool checkGlobalVersion )
339
342
{
340
- var duplicateVersions = configTaskVersionMapping . GroupBy ( x => x . Value ) . Select ( x => new { version = x . Key , configName = String . Join ( "," , x . Select ( x => x . Key . name ) ) , count = x . Count ( ) } ) . Where ( x => x . count > 1 ) ;
343
+ var duplicateVersions = configTaskVersionMapping
344
+ . Where ( x => checkGlobalVersion || ! x . Key . useGlobalVersion )
345
+ . GroupBy ( x => x . Value )
346
+ . Select ( x => new { version = x . Key , hasGlobal = x . Where ( x => x . Key . useGlobalVersion ) . Any ( ) , configName = String . Join ( "," , x . Select ( x => x . Key . name ) ) , count = x . Count ( ) } ) . Where ( x => x . count > 1 ) ;
341
347
if ( duplicateVersions . Any ( ) )
342
348
{
343
349
StringBuilder dupConfigsStr = new StringBuilder ( ) ;
344
350
foreach ( var x in duplicateVersions )
345
351
{
346
- dupConfigsStr . AppendLine ( $ "task={ task } version={ x . version } specified in multiple configName={ x . configName } config count={ x . count } ") ;
352
+ if ( x . hasGlobal )
353
+ {
354
+ dupConfigsStr . AppendLine ( $ "task={ task } version={ x . version } specified in multiple configName={ x . configName } config count={ x . count } . To fix, check-in globalversion.txt change generated by running 'node make.js build --task { task } --includeLocalPackagesBuildConfig'") ;
355
+ }
356
+ else
357
+ {
358
+ dupConfigsStr . AppendLine ( $ "task={ task } version={ x . version } specified in multiple configName={ x . configName } config count={ x . count } ") ;
359
+ }
347
360
}
348
361
349
362
throw new Exception ( dupConfigsStr . ToString ( ) ) ;
@@ -549,7 +562,7 @@ private static void MainUpdateTask(
549
562
550
563
if ( config . enableBuildConfigOverrides )
551
564
{
552
- EnsureBuildConfigFileOverrides ( config , taskTargetPath ) ;
565
+ EnsureBuildConfigFileOverrides ( config , taskTargetPath , generatedFolder , task ) ;
553
566
}
554
567
555
568
try
@@ -600,7 +613,7 @@ private static void MainUpdateTask(
600
613
601
614
if ( config . enableBuildConfigOverrides )
602
615
{
603
- CopyConfigOverrides ( gitRootPath , taskTargetPath , taskOutput , config ) ;
616
+ CopyConfigOverrides ( gitRootPath , taskTargetPath , taskOutput , config , generatedFolder , task ) ;
604
617
}
605
618
606
619
// if some files aren't present in destination, stop as following code assumes they're present and we'll just get a FileNotFoundException
@@ -620,7 +633,7 @@ private static void MainUpdateTask(
620
633
621
634
if ( config . isNode )
622
635
{
623
- GetBuildConfigFileOverridePaths ( config , taskTargetPath , out string configTaskPath , out string readmePath ) ;
636
+ GetBuildConfigFileOverridePaths ( config , taskTargetPath , out string configTaskPath , out string readmePath , generatedFolder , task ) ;
624
637
625
638
string buildConfigPackageJsonPath = Path . Combine ( taskTargetPath , buildConfigs , configTaskPath , "package.json" ) ;
626
639
@@ -781,15 +794,15 @@ private static bool HasTaskInputContainsPreprocessorInstructions(string gitRootP
781
794
return hasPreprocessorDirectives ;
782
795
}
783
796
784
- private static void EnsureBuildConfigFileOverrides ( Config . ConfigRecord config , string taskTargetPath )
797
+ private static void EnsureBuildConfigFileOverrides ( Config . ConfigRecord config , string taskTargetPath , string generatedFolder , string taskName )
785
798
{
786
799
if ( ! config . enableBuildConfigOverrides )
787
800
{
788
801
throw new Exception ( "BUG: should not get here: !config.enableBuildConfigOverrides" ) ;
789
802
}
790
803
791
804
string path , readmeFile ;
792
- GetBuildConfigFileOverridePaths ( config , taskTargetPath , out path , out readmeFile ) ;
805
+ GetBuildConfigFileOverridePaths ( config , taskTargetPath , out path , out readmeFile , generatedFolder , taskName ) ;
793
806
794
807
if ( ! Directory . Exists ( path ) )
795
808
{
@@ -799,7 +812,7 @@ private static void EnsureBuildConfigFileOverrides(Config.ConfigRecord config, s
799
812
ensureUpdateModeVerifier ! . WriteAllText ( readmeFile , "Place files overridden for this config in this directory" , suppressValidationErrorIfTargetPathDoesntExist : ! Knob . Default . SourceDirectoriesMustContainPlaceHolders ) ;
800
813
}
801
814
802
- private static void GetBuildConfigFileOverridePaths ( Config . ConfigRecord config , string taskTargetPath , out string path , out string readmeFile )
815
+ private static void GetBuildConfigFileOverridePaths ( Config . ConfigRecord config , string taskTargetPath , out string path , out string readmeFile , string generatedFolder , string taskName )
803
816
{
804
817
string directoryName = config . name ;
805
818
@@ -813,19 +826,28 @@ private static void GetBuildConfigFileOverridePaths(Config.ConfigRecord config,
813
826
directoryName = config . overriddenDirectoryName ;
814
827
}
815
828
816
- path = Path . Combine ( taskTargetPath , buildConfigs , directoryName ) ;
817
- readmeFile = Path . Combine ( taskTargetPath , buildConfigs , directoryName , filesOverriddenForConfigGoHereReadmeTxt ) ;
829
+ if ( config . useGlobalVersion )
830
+ {
831
+ // for global version, place artifacts in _generated (such as package-lock)
832
+ path = Path . Combine ( generatedFolder , buildConfigs , taskName , directoryName ) ;
833
+ readmeFile = Path . Combine ( generatedFolder , buildConfigs , taskName , directoryName , filesOverriddenForConfigGoHereReadmeTxt ) ;
834
+ }
835
+ else
836
+ {
837
+ path = Path . Combine ( taskTargetPath , buildConfigs , directoryName ) ;
838
+ readmeFile = Path . Combine ( taskTargetPath , buildConfigs , directoryName , filesOverriddenForConfigGoHereReadmeTxt ) ;
839
+ }
818
840
}
819
841
820
- private static void CopyConfigOverrides ( string gitRootPath , string taskTargetPath , string taskOutput , Config . ConfigRecord config )
842
+ private static void CopyConfigOverrides ( string gitRootPath , string taskTargetPath , string taskOutput , Config . ConfigRecord config , string generatedFolder , string taskName )
821
843
{
822
844
if ( ! config . enableBuildConfigOverrides )
823
845
{
824
846
throw new Exception ( "BUG: should not get here: !config.enableBuildConfigOverrides" ) ;
825
847
}
826
848
827
849
string overridePathForBuildConfig ;
828
- GetBuildConfigFileOverridePaths ( config , taskTargetPath , out overridePathForBuildConfig , out _ ) ;
850
+ GetBuildConfigFileOverridePaths ( config , taskTargetPath , out overridePathForBuildConfig , out _ , generatedFolder , taskName ) ;
829
851
830
852
bool doCopy ;
831
853
if ( Knob . Default . SourceDirectoriesMustContainPlaceHolders )
0 commit comments