From fe5b0aeba5f68cb36ea88481adc297f171b3c5dc Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 6 Feb 2018 08:03:50 -0500 Subject: [PATCH] [xbd] emit proguard configs to FileWrites always There was an issue with the proguard task where config files extracted and cached into the intermediate output dir were not being emitted to the FileWrites item group on subsequent incremental builds because the .stamp file was checked and then the task skipped if it existed. This PR now makes the cached proguard config file paths saved to the .stamp file so subsequent incremental builds can read them from the .stamp file and emit them to the FileWrites item group. --- .../XamarinBuildAndroidAarProguardConfigs.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Util/Xamarin.Build.Download/source/Xamarin.Build.Download/XamarinBuildAndroidAarProguardConfigs.cs b/Util/Xamarin.Build.Download/source/Xamarin.Build.Download/XamarinBuildAndroidAarProguardConfigs.cs index 64e7def3fe..3cb845d3b0 100644 --- a/Util/Xamarin.Build.Download/source/Xamarin.Build.Download/XamarinBuildAndroidAarProguardConfigs.cs +++ b/Util/Xamarin.Build.Download/source/Xamarin.Build.Download/XamarinBuildAndroidAarProguardConfigs.cs @@ -32,7 +32,7 @@ public override bool Execute () if (!Directory.Exists (proguardIntermediateOutputPath)) Directory.CreateDirectory (proguardIntermediateOutputPath); - var additionalFileWrites = new List (); + var additionalFileWrites = new List (); // Make sure our XbdMerge directory exists var outputDir = MergeOutputDir; @@ -62,8 +62,21 @@ public override bool Execute () // We keep a stamp file around to avoid reprocessing, so skip if it exists var stampPath = Path.Combine (outputDir, saveNameHash + ".proguard.stamp"); - if (File.Exists (stampPath)) + // If we have a stamp file, it should contain any proguard config files that + // were previously processed. These need to be emitted still as FileWrites + if (File.Exists (stampPath)) { + // Each line should be a filename + var stampLines = File.ReadAllLines (stampPath); + if (stampLines != null && stampLines.Any ()) { + foreach (var line in stampLines) { + if (File.Exists (line)) // make sure we only add files that exist + additionalFileWrites.Add (line); + } + } + // the stamp file itself is a filewrites file + additionalFileWrites.Add (stampPath); continue; + } // Get all the mapped .aar files var resourceItems = asm.Value; @@ -93,7 +106,7 @@ public override bool Execute () var proguardSaveFilename = Path.Combine (proguardIntermediateOutputPath, saveNameHash + entryCount + ".txt"); // Add this to our file writes - additionalFileWrites.Add (new TaskItem (proguardSaveFilename)); + additionalFileWrites.Add (proguardSaveFilename); // Save out the proguard file using (var entryStream = entry.Open ()) @@ -109,12 +122,11 @@ public override bool Execute () } // *.proguard.stamp files are additional file writes - File.WriteAllText (stampPath, string.Empty); - additionalFileWrites.Add (new TaskItem (stampPath)); - + File.WriteAllText (stampPath, string.Join (Environment.NewLine, additionalFileWrites)); + additionalFileWrites.Add (stampPath); } - AdditionalFileWrites = additionalFileWrites.ToArray (); + AdditionalFileWrites = additionalFileWrites.Select (a => new TaskItem (a)).ToArray (); return true; }