From 13eedbfcf97e402ade06f2be29f98723ef7ff286 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 18 Oct 2018 13:42:54 -0700 Subject: Extract interfaces for Preprocess/Compile/Link/Bind/etc --- src/WixToolset.Core/CommandLine/CompileCommand.cs | 31 +++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/WixToolset.Core/CommandLine/CompileCommand.cs') diff --git a/src/WixToolset.Core/CommandLine/CompileCommand.cs b/src/WixToolset.Core/CommandLine/CompileCommand.cs index 621571b1..4007c263 100644 --- a/src/WixToolset.Core/CommandLine/CompileCommand.cs +++ b/src/WixToolset.Core/CommandLine/CompileCommand.cs @@ -6,6 +6,7 @@ namespace WixToolset.Core.CommandLine using System.Collections.Generic; using System.Xml.Linq; using WixToolset.Data; + using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; @@ -15,6 +16,7 @@ namespace WixToolset.Core.CommandLine { this.ServiceProvider = serviceProvider; this.Messaging = serviceProvider.GetService(); + this.ExtensionManager = serviceProvider.GetService(); this.SourceFiles = sources; this.PreprocessorVariables = preprocessorVariables; this.Platform = platform; @@ -24,6 +26,8 @@ namespace WixToolset.Core.CommandLine public IMessaging Messaging { get; } + public IExtensionManager ExtensionManager { get; } + private IEnumerable SourceFiles { get; } private IDictionary PreprocessorVariables { get; } @@ -36,16 +40,18 @@ namespace WixToolset.Core.CommandLine { foreach (var sourceFile in this.SourceFiles) { - var preprocessor = new Preprocessor(this.ServiceProvider); - preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; - preprocessor.Platform = Platform.X86; // TODO: set this correctly - preprocessor.SourcePath = sourceFile.SourcePath; - preprocessor.Variables = new Dictionary(this.PreprocessorVariables); + var context = this.ServiceProvider.GetService(); + context.Extensions = this.ExtensionManager.Create(); + context.Platform = this.Platform; + context.IncludeSearchPaths = this.IncludeSearchPaths; + context.SourcePath = sourceFile.SourcePath; + context.Variables = this.PreprocessorVariables; XDocument document = null; try { - document = preprocessor.Execute(); + var preprocessor = this.ServiceProvider.GetService(); + document = preprocessor.Preprocess(context); } catch (WixException e) { @@ -57,11 +63,14 @@ namespace WixToolset.Core.CommandLine continue; } - var compiler = new Compiler(this.ServiceProvider); - compiler.OutputPath = sourceFile.OutputPath; - compiler.Platform = this.Platform; - compiler.SourceDocument = document; - var intermediate = compiler.Execute(); + var compileContext = this.ServiceProvider.GetService(); + compileContext.Extensions = this.ExtensionManager.Create(); + compileContext.OutputPath = sourceFile.OutputPath; + compileContext.Platform = this.Platform; + compileContext.Source = document; + + var compiler = this.ServiceProvider.GetService(); + var intermediate = compiler.Compile(compileContext); intermediate.Save(sourceFile.OutputPath); } -- cgit v1.2.3-55-g6feb