aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/CommandLine/CompileCommand.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-12-26 15:11:40 -0800
committerRob Mensching <rob@firegiant.com>2017-12-26 15:11:40 -0800
commit1d6ff8af3c423ee4622185edc986ae5caad6b122 (patch)
tree0fd320bb2e249da3a2fbebcd3e0aa49879aa27b0 /src/WixToolset.Core/CommandLine/CompileCommand.cs
parentecf3a0cca5a424a91ab98557d963d2535963d582 (diff)
downloadwix-1d6ff8af3c423ee4622185edc986ae5caad6b122.tar.gz
wix-1d6ff8af3c423ee4622185edc986ae5caad6b122.tar.bz2
wix-1d6ff8af3c423ee4622185edc986ae5caad6b122.zip
Standardize creation of public objects in move towards interfaces
Diffstat (limited to '')
-rw-r--r--src/WixToolset.Core/CommandLine/CompileCommand.cs42
1 files changed, 13 insertions, 29 deletions
diff --git a/src/WixToolset.Core/CommandLine/CompileCommand.cs b/src/WixToolset.Core/CommandLine/CompileCommand.cs
index f0ff5b1a..123318f5 100644
--- a/src/WixToolset.Core/CommandLine/CompileCommand.cs
+++ b/src/WixToolset.Core/CommandLine/CompileCommand.cs
@@ -4,28 +4,21 @@ namespace WixToolset.Core.CommandLine
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Linq;
8 using WixToolset.Data; 7 using WixToolset.Data;
9 using WixToolset.Extensibility; 8 using WixToolset.Extensibility;
10 using WixToolset.Extensibility.Services; 9 using WixToolset.Extensibility.Services;
11 10
12 internal class CompileCommand : ICommandLineCommand 11 internal class CompileCommand : ICommandLineCommand
13 { 12 {
14 public CompileCommand(IServiceProvider serviceProvider, IMessaging messaging, IExtensionManager extensions, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables) 13 public CompileCommand(IServiceProvider serviceProvider, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables)
15 { 14 {
16 this.PreprocessorVariables = preprocessorVariables; 15 this.PreprocessorVariables = preprocessorVariables;
17 this.ServiceProvider = serviceProvider; 16 this.ServiceProvider = serviceProvider;
18 this.Messaging = messaging;
19 this.ExtensionManager = extensions;
20 this.SourceFiles = sources; 17 this.SourceFiles = sources;
21 } 18 }
22 19
23 private IServiceProvider ServiceProvider { get; } 20 private IServiceProvider ServiceProvider { get; }
24 21
25 private IMessaging Messaging { get; }
26
27 private IExtensionManager ExtensionManager { get; }
28
29 public IEnumerable<string> IncludeSearchPaths { get; } 22 public IEnumerable<string> IncludeSearchPaths { get; }
30 23
31 private IEnumerable<SourceFile> SourceFiles { get; } 24 private IEnumerable<SourceFile> SourceFiles { get; }
@@ -36,27 +29,18 @@ namespace WixToolset.Core.CommandLine
36 { 29 {
37 foreach (var sourceFile in this.SourceFiles) 30 foreach (var sourceFile in this.SourceFiles)
38 { 31 {
39 var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); 32 var preprocessor = new Preprocessor(this.ServiceProvider);
40 preprocessContext.Messaging = this.Messaging; 33 preprocessor.IncludeSearchPaths = this.IncludeSearchPaths;
41 preprocessContext.Extensions = this.ExtensionManager.Create<IPreprocessorExtension>(); 34 preprocessor.Platform = Platform.X86; // TODO: set this correctly
42 preprocessContext.Platform = Platform.X86; // TODO: set this correctly 35 preprocessor.SourcePath = sourceFile.SourcePath;
43 preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List<string>(); 36 preprocessor.Variables = new Dictionary<string, string>(this.PreprocessorVariables);
44 preprocessContext.SourceFile = sourceFile.SourcePath; 37 var document = preprocessor.Execute();
45 preprocessContext.Variables = new Dictionary<string, string>(this.PreprocessorVariables); 38
46 39 var compiler = new Compiler(this.ServiceProvider);
47 var preprocessor = new Preprocessor(); 40 compiler.OutputPath = sourceFile.OutputPath;
48 var document = preprocessor.Process(preprocessContext); 41 compiler.Platform = Platform.X86; // TODO: set this correctly
49 42 compiler.SourceDocument = document;
50 var compileContext = this.ServiceProvider.GetService<ICompileContext>(); 43 var intermediate = compiler.Execute();
51 compileContext.Messaging = this.Messaging;
52 compileContext.CompilationId = Guid.NewGuid().ToString("N");
53 compileContext.Extensions = this.ExtensionManager.Create<ICompilerExtension>();
54 compileContext.OutputPath = sourceFile.OutputPath;
55 compileContext.Platform = Platform.X86; // TODO: set this correctly
56 compileContext.Source = document;
57
58 var compiler = new Compiler();
59 var intermediate = compiler.Compile(compileContext);
60 44
61 intermediate.Save(sourceFile.OutputPath); 45 intermediate.Save(sourceFile.OutputPath);
62 } 46 }