aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/CommandLine/CompileCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/CommandLine/CompileCommand.cs')
-rw-r--r--src/WixToolset.Core/CommandLine/CompileCommand.cs27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/WixToolset.Core/CommandLine/CompileCommand.cs b/src/WixToolset.Core/CommandLine/CompileCommand.cs
index 855e7c6a..58ba9d29 100644
--- a/src/WixToolset.Core/CommandLine/CompileCommand.cs
+++ b/src/WixToolset.Core/CommandLine/CompileCommand.cs
@@ -2,32 +2,47 @@
2 2
3namespace WixToolset.Core 3namespace WixToolset.Core
4{ 4{
5 using System;
5 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using WixToolset.Data;
8 using WixToolset.Extensibility;
6 using WixToolset.Extensibility.Services; 9 using WixToolset.Extensibility.Services;
7 10
8 internal class CompileCommand : ICommandLineCommand 11 internal class CompileCommand : ICommandLineCommand
9 { 12 {
10 public CompileCommand(IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables) 13 public CompileCommand(IServiceProvider serviceProvider, IExtensionManager extensions, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables)
11 { 14 {
12 this.PreprocessorVariables = preprocessorVariables; 15 this.PreprocessorVariables = preprocessorVariables;
16 this.ServiceProvider = serviceProvider;
17 this.ExtensionManager = extensions;
13 this.SourceFiles = sources; 18 this.SourceFiles = sources;
14 } 19 }
15 20
21 private IServiceProvider ServiceProvider { get; }
22
23 private IExtensionManager ExtensionManager { get; }
24
16 private IEnumerable<SourceFile> SourceFiles { get; } 25 private IEnumerable<SourceFile> SourceFiles { get; }
17 26
18 private IDictionary<string, string> PreprocessorVariables { get; } 27 private IDictionary<string, string> PreprocessorVariables { get; }
19 28
20 public int Execute() 29 public int Execute()
21 { 30 {
22 var preprocessor = new Preprocessor();
23
24 var compiler = new Compiler();
25
26 foreach (var sourceFile in this.SourceFiles) 31 foreach (var sourceFile in this.SourceFiles)
27 { 32 {
33 var preprocessor = new Preprocessor();
28 var document = preprocessor.Process(sourceFile.SourcePath, this.PreprocessorVariables); 34 var document = preprocessor.Process(sourceFile.SourcePath, this.PreprocessorVariables);
29 35
30 var intermediate = compiler.Compile(document); 36 var compileContext = this.ServiceProvider.GetService<ICompileContext>();
37 compileContext.Messaging = Messaging.Instance;
38 compileContext.CompilationId = Guid.NewGuid().ToString("N");
39 compileContext.Extensions = this.ExtensionManager.Create<ICompilerExtension>();
40 compileContext.OutputPath = sourceFile.OutputPath;
41 compileContext.Platform = Platform.X86; // TODO: set this correctly
42 compileContext.Source = document;
43
44 var compiler = new Compiler();
45 var intermediate = compiler.Compile(compileContext);
31 46
32 intermediate.Save(sourceFile.OutputPath); 47 intermediate.Save(sourceFile.OutputPath);
33 } 48 }