From 5ba862bfa618c89a563d555e8ce7b44a904df406 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 6 Dec 2017 11:39:26 -0800 Subject: Add support for loading Intermediates from extensions --- src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs | 7 +--- src/WixToolset.Core/CommandLine/BuildCommand.cs | 4 +- src/WixToolset.Core/LinkContext.cs | 4 ++ src/WixToolset.Core/Linker.cs | 52 +++++------------------- 4 files changed, 20 insertions(+), 47 deletions(-) (limited to 'src/WixToolset.Core') diff --git a/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs b/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs index 28fc4817..c6e21973 100644 --- a/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs +++ b/src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs @@ -28,19 +28,16 @@ namespace WixToolset.Core.Bind /// The extract path for the embedded file. public string AddEmbeddedFileIndex(Uri uri, int embeddedFileIndex, string tempPath) { - string extractPath; - SortedList extracts; - // If the uri to the file that contains the embedded file does not already have embedded files // being extracted, create the dictionary to track that. - if (!filesWithEmbeddedFiles.TryGetValue(uri, out extracts)) + if (!filesWithEmbeddedFiles.TryGetValue(uri, out var extracts)) { extracts = new SortedList(); filesWithEmbeddedFiles.Add(uri, extracts); } // If the embedded file is not already tracked in the dictionary of extracts, add it. - if (!extracts.TryGetValue(embeddedFileIndex, out extractPath)) + if (!extracts.TryGetValue(embeddedFileIndex, out var extractPath)) { string localFileNameWithoutExtension = Path.GetFileNameWithoutExtension(uri.LocalPath); string unique = this.HashUri(uri.AbsoluteUri); diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 79bacd22..7a63b869 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs @@ -168,8 +168,10 @@ namespace WixToolset.Core var context = this.ServiceProvider.GetService(); context.Messaging = Messaging.Instance; context.Extensions = this.ExtensionManager.Create(); - context.Intermediates = intermediates.Union(libraries).ToList(); + context.ExtensionData = this.ExtensionManager.Create(); context.ExpectedOutputType = this.OutputType; + context.Intermediates = intermediates.Union(libraries).ToList(); + context.TupleDefinitionCreator = creator; var linker = new Linker(); var output = linker.Link(context); diff --git a/src/WixToolset.Core/LinkContext.cs b/src/WixToolset.Core/LinkContext.cs index c3631f72..1384cf98 100644 --- a/src/WixToolset.Core/LinkContext.cs +++ b/src/WixToolset.Core/LinkContext.cs @@ -21,8 +21,12 @@ namespace WixToolset.Core public IEnumerable Extensions { get; set; } + public IEnumerable ExtensionData { get; set; } + public OutputType ExpectedOutputType { get; set; } public IEnumerable Intermediates { get; set; } + + public ITupleDefinitionCreator TupleDefinitionCreator { get; set; } } } diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs index 7faf69ba..c893a01d 100644 --- a/src/WixToolset.Core/Linker.cs +++ b/src/WixToolset.Core/Linker.cs @@ -55,32 +55,6 @@ namespace WixToolset.Core /// The Wix variable resolver. //internal IBindVariableResolver WixVariableResolver { get; set; } - /// - /// Adds an extension. - /// - /// The extension to add. - //public void AddExtensionData(IExtensionData extension) - //{ - // if (null != extension.TableDefinitions) - // { - // foreach (TableDefinition tableDefinition in extension.TableDefinitions) - // { - // if (!this.tableDefinitions.Contains(tableDefinition.Name)) - // { - // this.tableDefinitions.Add(tableDefinition); - // } - // else - // { - // throw new WixException(WixErrors.DuplicateExtensionTable(extension.GetType().ToString(), tableDefinition.Name)); - // } - // } - // } - - // // keep track of extension data so the libraries can be loaded from these later once all the table definitions - // // are loaded; this will allow extensions to have cross table definition dependencies - // this.extensionData.Add(extension); - //} - /// /// Links a collection of sections into an output. /// @@ -91,10 +65,19 @@ namespace WixToolset.Core { this.Context = context ?? throw new ArgumentNullException(nameof(context)); - //IEnumerable
inputs, OutputType expectedOutputType - var sections = this.Context.Intermediates.SelectMany(i => i.Sections).ToList(); + // Add sections from the extensions with data. + foreach (var data in context.ExtensionData) + { + var library = data.GetLibrary(context.TupleDefinitionCreator); + + if (library != null) + { + sections.AddRange(library.Sections); + } + } + #if MOVE_TO_BACKEND bool containsModuleSubstitution = false; bool containsModuleConfiguration = false; @@ -144,19 +127,6 @@ namespace WixToolset.Core } #endif -#if TODO - // Add sections from the extensions with data. - foreach (IExtensionData data in this.extensionData) - { - Library library = data.GetLibrary(this.tableDefinitions); - - if (null != library) - { - sections.AddRange(library.Sections); - } - } -#endif - // First find the entry section and while processing all sections load all the symbols from all of the sections. // sections.FindEntrySectionAndLoadSymbols(false, this, expectedOutputType, out entrySection, out allSymbols); var find = new FindEntrySectionAndLoadSymbolsCommand(sections); -- cgit v1.2.3-55-g6feb