From 2bb37beda887d120a0ddabf874ad25357101faa1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Nov 2017 10:59:45 -0700 Subject: Update to WiX Intermediate Representation --- src/WixToolset.Core/Bind/DelayedField.cs | 6 +- src/WixToolset.Core/Bind/FileFacade.cs | 17 +++--- .../Bind/ResolveDelayedFieldsCommand.cs | 15 ++--- src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | 67 +++++++++++++++------- 4 files changed, 65 insertions(+), 40 deletions(-) (limited to 'src/WixToolset.Core/Bind') diff --git a/src/WixToolset.Core/Bind/DelayedField.cs b/src/WixToolset.Core/Bind/DelayedField.cs index 6c56f27c..8b761b94 100644 --- a/src/WixToolset.Core/Bind/DelayedField.cs +++ b/src/WixToolset.Core/Bind/DelayedField.cs @@ -16,7 +16,7 @@ namespace WixToolset.Core.Bind /// /// Row for the field. /// Field needing further resolution. - public DelayedField(Row row, Field field) + public DelayedField(IntermediateTuple row, IntermediateField field) { this.Row = row; this.Field = field; @@ -25,11 +25,11 @@ namespace WixToolset.Core.Bind /// /// The row containing the field. /// - public Row Row { get; } + public IntermediateTuple Row { get; } /// /// The field needing further resolving. /// - public Field Field { get; } + public IntermediateField Field { get; } } } diff --git a/src/WixToolset.Core/Bind/FileFacade.cs b/src/WixToolset.Core/Bind/FileFacade.cs index aaa6b7d3..ebca9cff 100644 --- a/src/WixToolset.Core/Bind/FileFacade.cs +++ b/src/WixToolset.Core/Bind/FileFacade.cs @@ -3,19 +3,18 @@ namespace WixToolset.Core.Bind { using System.Collections.Generic; - using WixToolset.Data; - using WixToolset.Data.Rows; + using WixToolset.Data.Tuples; public class FileFacade { - public FileFacade(FileRow file, WixFileRow wixFile, WixDeltaPatchFileRow deltaPatchFile) + public FileFacade(FileTuple file, WixFileTuple wixFile, WixDeltaPatchFileTuple deltaPatchFile) { this.File = file; this.WixFile = wixFile; this.DeltaPatchFile = deltaPatchFile; } - public FileFacade(bool fromModule, FileRow file, WixFileRow wixFile) + public FileFacade(bool fromModule, FileTuple file, WixFileTuple wixFile) { this.FromModule = fromModule; this.File = file; @@ -24,21 +23,21 @@ namespace WixToolset.Core.Bind public bool FromModule { get; private set; } - public FileRow File { get; private set; } + public FileTuple File { get; private set; } - public WixFileRow WixFile { get; private set; } + public WixFileTuple WixFile { get; private set; } - public WixDeltaPatchFileRow DeltaPatchFile { get; private set; } + public WixDeltaPatchFileTuple DeltaPatchFile { get; private set; } /// /// Gets the set of MsiAssemblyName rows created for this file. /// /// RowCollection of MsiAssemblyName table. - public List AssemblyNames { get; set; } + public List AssemblyNames { get; set; } /// /// Gets or sets the MsiFileHash row for this file. /// - public Row Hash { get; set; } + public MsiFileHashTuple Hash { get; set; } } } diff --git a/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs index 15365c2a..d05135cf 100644 --- a/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs +++ b/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs @@ -34,19 +34,19 @@ namespace WixToolset.Core.Bind { try { - Row propertyRow = delayedField.Row; + var propertyRow = delayedField.Row; // process properties first in case they refer to other binder variables - if ("Property" == propertyRow.Table.Name) + if (delayedField.Row.Definition.Type == TupleDefinitionType.Property) { - string value = WixVariableResolver.ResolveDelayedVariables(propertyRow.SourceLineNumbers, (string)delayedField.Field.Data, this.VariableCache); + var value = WixVariableResolver.ResolveDelayedVariables(propertyRow.SourceLineNumbers, delayedField.Field.AsString(), this.VariableCache); // update the variable cache with the new value - string key = String.Concat("property.", Common.Demodularize(this.OutputType, this.ModularizationGuid, (string)propertyRow[0])); + var key = String.Concat("property.", Common.Demodularize(this.OutputType, this.ModularizationGuid, (string)propertyRow[0])); this.VariableCache[key] = value; // update the field data - delayedField.Field.Data = value; + delayedField.Field.Set(value); } else { @@ -103,11 +103,12 @@ namespace WixToolset.Core.Bind } // process the remaining fields in case they refer to property binder variables - foreach (DelayedField delayedField in deferredFields) + foreach (var delayedField in deferredFields) { try { - delayedField.Field.Data = WixVariableResolver.ResolveDelayedVariables(delayedField.Row.SourceLineNumbers, (string)delayedField.Field.Data, this.VariableCache); + var value = WixVariableResolver.ResolveDelayedVariables(delayedField.Row.SourceLineNumbers, delayedField.Field.AsString(), this.VariableCache); + delayedField.Field.Set(value); } catch (WixException we) { diff --git a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs index f4f4f9e8..9253f352 100644 --- a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs +++ b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs @@ -2,6 +2,7 @@ namespace WixToolset.Core.Bind { + using System; using System.Collections.Generic; using WixToolset.Data; using WixToolset.Data.Bind; @@ -24,7 +25,7 @@ namespace WixToolset.Core.Bind public string IntermediateFolder { private get; set; } - public TableIndexedCollection Tables { private get; set; } + public Intermediate Intermediate { private get; set; } public bool SupportDelayedResolution { private get; set; } @@ -36,25 +37,39 @@ namespace WixToolset.Core.Bind var fileResolver = new FileResolver(this.BindPaths, this.Extensions); - foreach (Table table in this.Tables) + foreach (var sections in this.Intermediate.Sections) { - foreach (Row row in table.Rows) + foreach (var row in sections.Tuples) { - foreach (Field field in row.Fields) + foreach (var field in row.Fields) { - bool isDefault = true; - bool delayedResolve = false; + if (field == null) + { + continue; + } + + var isDefault = true; + var delayedResolve = false; // Check to make sure we're in a scenario where we can handle variable resolution. if (null != delayedFields) { // resolve localization and wix variables - if (field.Data is string) + if (field.Type == IntermediateFieldType.String) { - field.Data = this.BindVariableResolver.ResolveVariables(row.SourceLineNumbers, field.AsString(), false, out isDefault, out delayedResolve); - if (delayedResolve) + var original = field.AsString(); + if (!String.IsNullOrEmpty(original)) { - delayedFields.Add(new DelayedField(row, field)); + var value = this.BindVariableResolver.ResolveVariables(row.SourceLineNumbers, original, false, out isDefault, out delayedResolve); + if (original != value) + { + field.Set(value); + } + + if (delayedResolve) + { + delayedFields.Add(new DelayedField(row, field)); + } } } } @@ -66,44 +81,51 @@ namespace WixToolset.Core.Bind } // Resolve file paths - if (ColumnType.Object == field.Column.Type) + if (field.Type == IntermediateFieldType.Path) { - ObjectField objectField = (ObjectField)field; + var objectField = field.AsPath(); +#if REVISIT_FOR_PATCHING // Skip file resolution if the file is to be deleted. if (RowOperation.Delete == row.Operation) { continue; } +#endif // File is embedded and path to it was not modified above. if (objectField.EmbeddedFileIndex.HasValue && isDefault) { - string extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileIndex(objectField.BaseUri, objectField.EmbeddedFileIndex.Value, this.IntermediateFolder); + var extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileIndex(objectField.BaseUri, objectField.EmbeddedFileIndex.Value, this.IntermediateFolder); // Set the path to the embedded file once where it will be extracted. - objectField.Data = extractPath; + field.Set(extractPath); } - else if (null != objectField.Data) // non-compressed file (or localized value) + else if (null != objectField.Path) // non-compressed file (or localized value) { try { if (!this.BuildingPatch) // Normal binding for non-Patch scenario such as link (light.exe) { +#if REVISIT_FOR_PATCHING // keep a copy of the un-resolved data for future replay. This will be saved into wixpdb file if (null == objectField.UnresolvedData) { objectField.UnresolvedData = (string)objectField.Data; } +#endif // resolve the path to the file - objectField.Data = fileResolver.ResolveFile((string)objectField.Data, table.Name, row.SourceLineNumbers, BindStage.Normal); + var value = fileResolver.ResolveFile(objectField.Path, row.Definition.Name, row.SourceLineNumbers, BindStage.Normal); + field.Set(value); } else if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) // Normal binding for Patch Scenario (normal patch, no re-basing logic) { // resolve the path to the file - objectField.Data = fileResolver.ResolveFile((string)objectField.Data, table.Name, row.SourceLineNumbers, BindStage.Normal); + var value = fileResolver.ResolveFile(objectField.Path, row.Definition.Name, row.SourceLineNumbers, BindStage.Normal); + field.Set(value); } +#if REVISIT_FOR_PATCHING else // Re-base binding path scenario caused by pyro.exe -bt -bu { // by default, use the resolved Data for file lookup @@ -122,16 +144,18 @@ namespace WixToolset.Core.Bind } } - objectField.Data = fileResolver.ResolveFile(filePathToResolve, table.Name, row.SourceLineNumbers, BindStage.Updated); + objectField.Data = fileResolver.ResolveFile(filePathToResolve, row.Definition.Name, row.SourceLineNumbers, BindStage.Updated); } +#endif } catch (WixFileNotFoundException) { // display the error with source line information - Messaging.Instance.OnMessage(WixErrors.FileNotFound(row.SourceLineNumbers, (string)objectField.Data)); + Messaging.Instance.OnMessage(WixErrors.FileNotFound(row.SourceLineNumbers, objectField.Path)); } } +#if REVISIT_FOR_PATCHING if (null != objectField.PreviousData) { objectField.PreviousData = this.BindVariableResolver.ResolveVariables(row.SourceLineNumbers, objectField.PreviousData, false, out isDefault); @@ -159,7 +183,7 @@ namespace WixToolset.Core.Bind if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) { // resolve the path to the file - objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, table.Name, row.SourceLineNumbers, BindStage.Normal); + objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, row.Definition.Name, row.SourceLineNumbers, BindStage.Normal); } else { @@ -177,7 +201,7 @@ namespace WixToolset.Core.Bind } // resolve the path to the file - objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, table.Name, row.SourceLineNumbers, BindStage.Target); + objectField.PreviousData = fileResolver.ResolveFile((string)objectField.PreviousData, row.Definition.Name, row.SourceLineNumbers, BindStage.Target); } } @@ -189,6 +213,7 @@ namespace WixToolset.Core.Bind } } } +#endif } } } -- cgit v1.2.3-55-g6feb