aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2020-03-26 13:31:04 -0400
committerRob Mensching <rob@firegiant.com>2020-03-26 10:50:21 -0700
commit271601dfe0990917ef6331fbddcfd1b400882eb2 (patch)
treec246d6c3a04d4b5c95e4f15bea71a65c5084beba
parentc1ebab9485256e5fbf4f47d20be8627fd03c68a1 (diff)
downloadwix-271601dfe0990917ef6331fbddcfd1b400882eb2.tar.gz
wix-271601dfe0990917ef6331fbddcfd1b400882eb2.tar.bz2
wix-271601dfe0990917ef6331fbddcfd1b400882eb2.zip
Add intermediate levels to track how IR has been lowered.
-rw-r--r--src/WixToolset.Data/ErrorMessages.cs18
-rw-r--r--src/WixToolset.Data/Intermediate.cs35
-rw-r--r--src/WixToolset.Data/IntermediateLevels.cs9
-rw-r--r--src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs9
-rw-r--r--src/test/WixToolsetTest.Data/SerializeFixture.cs10
5 files changed, 78 insertions, 3 deletions
diff --git a/src/WixToolset.Data/ErrorMessages.cs b/src/WixToolset.Data/ErrorMessages.cs
index 43398ad2..1740f6c9 100644
--- a/src/WixToolset.Data/ErrorMessages.cs
+++ b/src/WixToolset.Data/ErrorMessages.cs
@@ -2249,6 +2249,21 @@ namespace WixToolset.Data
2249 return Message(null, Ids.WixiplSourceFileIsExclusive, "When an intermediate post link source file is specified, it must be the only source file provided."); 2249 return Message(null, Ids.WixiplSourceFileIsExclusive, "When an intermediate post link source file is specified, it must be the only source file provided.");
2250 } 2250 }
2251 2251
2252 public static Message IntermediatesMustBeCompiled(string invalidIntermediates)
2253 {
2254 return Message(null, Ids.IntermediatesMustBeCompiled, "Intermediates being linked must have been compiled. Intermediates with these ids were not compiled: {0}", invalidIntermediates);
2255 }
2256
2257 public static Message IntermediatesMustBeLinked(string invalidIntermediate)
2258 {
2259 return Message(null, Ids.IntermediatesMustBeLinked, "Intermediates being resolved must have been linked. This intermediate was not linked: {0}", invalidIntermediate);
2260 }
2261
2262 public static Message IntermediatesMustBeResolved(string invalidIntermediate)
2263 {
2264 return Message(null, Ids.IntermediatesMustBeResolved, "Intermediates being bound must have been resolved. This intermediate was not resolved: {0}", invalidIntermediate);
2265 }
2266
2252 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) 2267 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
2253 { 2268 {
2254 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); 2269 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
@@ -2646,6 +2661,9 @@ namespace WixToolset.Data
2646 WixiplSourceFileIsExclusive = 392, 2661 WixiplSourceFileIsExclusive = 392,
2647 UnableToConvertFieldToNumber = 393, 2662 UnableToConvertFieldToNumber = 393,
2648 CouldNotDetermineProductCodeFromTransformSummaryInfo = 394, 2663 CouldNotDetermineProductCodeFromTransformSummaryInfo = 394,
2664 IntermediatesMustBeCompiled = 395,
2665 IntermediatesMustBeLinked = 396,
2666 IntermediatesMustBeResolved = 397,
2649 } 2667 }
2650 } 2668 }
2651} 2669}
diff --git a/src/WixToolset.Data/Intermediate.cs b/src/WixToolset.Data/Intermediate.cs
index 7fc7d6c3..d1c38cf0 100644
--- a/src/WixToolset.Data/Intermediate.cs
+++ b/src/WixToolset.Data/Intermediate.cs
@@ -29,9 +29,14 @@ namespace WixToolset.Data
29 this.Sections = new List<IntermediateSection>(); 29 this.Sections = new List<IntermediateSection>();
30 } 30 }
31 31
32 public Intermediate(string id, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture) 32 public Intermediate(string id, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture) : this(id, level: null, sections, localizationsByCulture)
33 {
34 }
35
36 public Intermediate(string id, string level, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture)
33 { 37 {
34 this.Id = id; 38 this.Id = id;
39 this.Level = level;
35 this.localizationsByCulture = (localizationsByCulture != null) ? new Dictionary<string, Localization>(localizationsByCulture, StringComparer.OrdinalIgnoreCase) : new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase); 40 this.localizationsByCulture = (localizationsByCulture != null) ? new Dictionary<string, Localization>(localizationsByCulture, StringComparer.OrdinalIgnoreCase) : new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase);
36 this.Sections = (sections != null) ? new List<IntermediateSection>(sections) : new List<IntermediateSection>(); 41 this.Sections = (sections != null) ? new List<IntermediateSection>(sections) : new List<IntermediateSection>();
37 } 42 }
@@ -42,6 +47,11 @@ namespace WixToolset.Data
42 public string Id { get; } 47 public string Id { get; }
43 48
44 /// <summary> 49 /// <summary>
50 /// Get the id for the intermediate.
51 /// </summary>
52 public string Level { get; private set; }
53
54 /// <summary>
45 /// Get the localizations contained in this intermediate. 55 /// Get the localizations contained in this intermediate.
46 /// </summary> 56 /// </summary>
47 public IEnumerable<Localization> Localizations => this.localizationsByCulture.Values; 57 public IEnumerable<Localization> Localizations => this.localizationsByCulture.Values;
@@ -182,6 +192,25 @@ namespace WixToolset.Data
182 } 192 }
183 193
184 /// <summary> 194 /// <summary>
195 /// Updates the intermediate level to the specified level.
196 /// </summary>
197 /// <param name="level">Intermediate level.</param>
198 public void UpdateLevel(string level)
199 {
200 this.Level = String.IsNullOrEmpty(this.Level) ? level : String.Concat(this.Level, ";", level);
201 }
202
203 /// <summary>
204 /// Returns whether a specifed intermediate level has been set for this intermediate.
205 /// </summary>
206 /// <param name="level">Intermediate level.</param>
207 /// <returns>True if the specifed intermediate level has been set for this intermediate.</returns>
208 public bool HasLevel(string level)
209 {
210 return this.Level?.Contains(level) == true;
211 }
212
213 /// <summary>
185 /// Saves an intermediate to a path on disk. 214 /// Saves an intermediate to a path on disk.
186 /// </summary> 215 /// </summary>
187 /// <param name="path">Path to save intermediate file to disk.</param> 216 /// <param name="path">Path to save intermediate file to disk.</param>
@@ -277,6 +306,7 @@ namespace WixToolset.Data
277 private static Intermediate FinalizeLoad(JsonObject json, Uri baseUri, ITupleDefinitionCreator creator) 306 private static Intermediate FinalizeLoad(JsonObject json, Uri baseUri, ITupleDefinitionCreator creator)
278 { 307 {
279 var id = json.GetValueOrDefault<string>("id"); 308 var id = json.GetValueOrDefault<string>("id");
309 var level = json.GetValueOrDefault<string>("level");
280 310
281 var sections = new List<IntermediateSection>(); 311 var sections = new List<IntermediateSection>();
282 312
@@ -296,7 +326,7 @@ namespace WixToolset.Data
296 localizations.Add(localization.Culture, localization); 326 localizations.Add(localization.Culture, localization);
297 } 327 }
298 328
299 return new Intermediate(id, sections, localizations); 329 return new Intermediate(id, level, sections, localizations);
300 } 330 }
301 331
302 private void SaveEmbedFiles(WixOutput wixout) 332 private void SaveEmbedFiles(WixOutput wixout)
@@ -351,6 +381,7 @@ namespace WixToolset.Data
351 var jsonObject = new JsonObject 381 var jsonObject = new JsonObject
352 { 382 {
353 { "id", this.Id }, 383 { "id", this.Id },
384 { "level", this.Level },
354 { "version", Intermediate.CurrentVersion.ToString() } 385 { "version", Intermediate.CurrentVersion.ToString() }
355 }; 386 };
356 387
diff --git a/src/WixToolset.Data/IntermediateLevels.cs b/src/WixToolset.Data/IntermediateLevels.cs
new file mode 100644
index 00000000..738cabaa
--- /dev/null
+++ b/src/WixToolset.Data/IntermediateLevels.cs
@@ -0,0 +1,9 @@
1namespace WixToolset.Data
2{
3 public static class IntermediateLevels
4 {
5 public const string Compiled = "compiled";
6 public const string Linked = "linked";
7 public const string Resolved = "resolved";
8 }
9}
diff --git a/src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs b/src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs
new file mode 100644
index 00000000..1eb0ef2d
--- /dev/null
+++ b/src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs
@@ -0,0 +1,9 @@
1namespace WixToolset.Data.WindowsInstaller
2{
3 public static class IntermediateLevels
4 {
5 // TODO: These are placeholder names until we (hopefully) come up with better ones.
6 public const string PartiallyBound = "msiPartiallyBound";
7 public const string FullyBound = "msiFullyBound";
8 }
9}
diff --git a/src/test/WixToolsetTest.Data/SerializeFixture.cs b/src/test/WixToolsetTest.Data/SerializeFixture.cs
index 34e50f36..55460d54 100644
--- a/src/test/WixToolsetTest.Data/SerializeFixture.cs
+++ b/src/test/WixToolsetTest.Data/SerializeFixture.cs
@@ -26,13 +26,21 @@ namespace WixToolsetTest.Data
26 Location = ComponentLocation.Either, 26 Location = ComponentLocation.Either,
27 }); 27 });
28 28
29 var intermediate = new Intermediate("TestIntermediate", new[] { section }, null); 29 var intermediate = new Intermediate("TestIntermediate", IntermediateLevels.Compiled, new[] { section }, null);
30
31 intermediate.UpdateLevel(IntermediateLevels.Linked);
32 intermediate.UpdateLevel(IntermediateLevels.Resolved);
30 33
31 var path = Path.GetTempFileName(); 34 var path = Path.GetTempFileName();
32 intermediate.Save(path); 35 intermediate.Save(path);
33 36
34 var loaded = Intermediate.Load(path); 37 var loaded = Intermediate.Load(path);
35 38
39 Assert.True(loaded.HasLevel(IntermediateLevels.Compiled));
40 Assert.True(loaded.HasLevel(IntermediateLevels.Linked));
41 Assert.True(loaded.HasLevel(IntermediateLevels.Resolved));
42 Assert.False(loaded.HasLevel(WixToolset.Data.WindowsInstaller.IntermediateLevels.PartiallyBound));
43
36 var tuple = (ComponentTuple)loaded.Sections.Single().Tuples.Single(); 44 var tuple = (ComponentTuple)loaded.Sections.Single().Tuples.Single();
37 45
38 Assert.Equal("TestComponent", tuple.Id.Id); 46 Assert.Equal("TestComponent", tuple.Id.Id);