diff options
Diffstat (limited to 'src/WixToolset.Core/CommandLine')
-rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 89 | ||||
-rw-r--r-- | src/WixToolset.Core/CommandLine/CommandLineParser.cs | 4 | ||||
-rw-r--r-- | src/WixToolset.Core/CommandLine/CompileCommand.cs | 42 |
3 files changed, 55 insertions, 80 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 5653afca..b5ad0b0e 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
@@ -13,11 +13,11 @@ namespace WixToolset.Core.CommandLine | |||
13 | 13 | ||
14 | internal class BuildCommand : ICommandLineCommand | 14 | internal class BuildCommand : ICommandLineCommand |
15 | { | 15 | { |
16 | public BuildCommand(IServiceProvider serviceProvider, IMessaging messaging, IExtensionManager extensions, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables, IEnumerable<string> locFiles, IEnumerable<string> libraryFiles, string outputPath, OutputType outputType, string cabCachePath, IEnumerable<string> cultures, bool bindFiles, IEnumerable<BindPath> bindPaths, string intermediateFolder, string contentsFile, string outputsFile, string builtOutputsFile) | 16 | public BuildCommand(IServiceProvider serviceProvider, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables, IEnumerable<string> locFiles, IEnumerable<string> libraryFiles, string outputPath, OutputType outputType, string cabCachePath, IEnumerable<string> cultures, bool bindFiles, IEnumerable<BindPath> bindPaths, string intermediateFolder, string contentsFile, string outputsFile, string builtOutputsFile) |
17 | { | 17 | { |
18 | this.ServiceProvider = serviceProvider; | 18 | this.ServiceProvider = serviceProvider; |
19 | this.Messaging = messaging; | 19 | this.Messaging = serviceProvider.GetService<IMessaging>(); |
20 | this.ExtensionManager = extensions; | 20 | this.ExtensionManager = serviceProvider.GetService<IExtensionManager>(); |
21 | this.LocFiles = locFiles; | 21 | this.LocFiles = locFiles; |
22 | this.LibraryFiles = libraryFiles; | 22 | this.LibraryFiles = libraryFiles; |
23 | this.PreprocessorVariables = preprocessorVariables; | 23 | this.PreprocessorVariables = preprocessorVariables; |
@@ -76,6 +76,11 @@ namespace WixToolset.Core.CommandLine | |||
76 | { | 76 | { |
77 | var intermediates = this.CompilePhase(); | 77 | var intermediates = this.CompilePhase(); |
78 | 78 | ||
79 | if (this.Messaging.EncounteredError) | ||
80 | { | ||
81 | return this.Messaging.LastErrorNumber; | ||
82 | } | ||
83 | |||
79 | if (!intermediates.Any()) | 84 | if (!intermediates.Any()) |
80 | { | 85 | { |
81 | return 1; | 86 | return 1; |
@@ -112,35 +117,30 @@ namespace WixToolset.Core.CommandLine | |||
112 | 117 | ||
113 | foreach (var sourceFile in this.SourceFiles) | 118 | foreach (var sourceFile in this.SourceFiles) |
114 | { | 119 | { |
115 | var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); | 120 | var preprocessor = new Preprocessor(this.ServiceProvider); |
116 | preprocessContext.Messaging = this.Messaging; | 121 | preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; |
117 | preprocessContext.Extensions = this.ExtensionManager.Create<IPreprocessorExtension>(); | 122 | preprocessor.Platform = Platform.X86; // TODO: set this correctly |
118 | preprocessContext.Platform = Platform.X86; // TODO: set this correctly | 123 | preprocessor.SourcePath = sourceFile.SourcePath; |
119 | preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List<string>(); | 124 | preprocessor.Variables = this.PreprocessorVariables; |
120 | preprocessContext.SourceFile = sourceFile.SourcePath; | 125 | var document = preprocessor.Execute(); |
121 | preprocessContext.Variables = new Dictionary<string, string>(this.PreprocessorVariables); | 126 | |
127 | if (this.Messaging.EncounteredError) | ||
128 | { | ||
129 | continue; | ||
130 | } | ||
122 | 131 | ||
123 | var preprocessor = new Preprocessor(); | 132 | var compiler = new Compiler(this.ServiceProvider); |
124 | var document = preprocessor.Process(preprocessContext); | 133 | compiler.OutputPath = sourceFile.OutputPath; |
134 | compiler.Platform = Platform.X86; // TODO: set this correctly | ||
135 | compiler.SourceDocument = document; | ||
136 | var intermediate = compiler.Execute(); | ||
125 | 137 | ||
126 | if (!this.Messaging.EncounteredError) | 138 | if (this.Messaging.EncounteredError) |
127 | { | 139 | { |
128 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); | 140 | continue; |
129 | compileContext.Messaging = this.Messaging; | ||
130 | compileContext.CompilationId = Guid.NewGuid().ToString("N"); | ||
131 | compileContext.Extensions = this.ExtensionManager.Create<ICompilerExtension>(); | ||
132 | compileContext.OutputPath = sourceFile.OutputPath; | ||
133 | compileContext.Platform = Platform.X86; // TODO: set this correctly | ||
134 | compileContext.Source = document; | ||
135 | |||
136 | var compiler = new Compiler(); | ||
137 | var intermediate = compiler.Compile(compileContext); | ||
138 | |||
139 | if (!this.Messaging.EncounteredError) | ||
140 | { | ||
141 | intermediates.Add(intermediate); | ||
142 | } | ||
143 | } | 141 | } |
142 | |||
143 | intermediates.Add(intermediate); | ||
144 | } | 144 | } |
145 | 145 | ||
146 | return intermediates; | 146 | return intermediates; |
@@ -156,17 +156,12 @@ namespace WixToolset.Core.CommandLine | |||
156 | return null; | 156 | return null; |
157 | } | 157 | } |
158 | 158 | ||
159 | var context = new LibraryContext(); | 159 | var librarian = new Librarian(this.ServiceProvider); |
160 | context.Messaging = this.Messaging; | 160 | librarian.BindFiles = this.BindFiles; |
161 | context.BindFiles = this.BindFiles; | 161 | librarian.BindPaths = this.BindPaths; |
162 | context.BindPaths = this.BindPaths; | 162 | librarian.Intermediates = intermediates; |
163 | context.Extensions = this.ExtensionManager.Create<ILibrarianExtension>(); | 163 | librarian.Localizations = localizations; |
164 | context.Localizations = localizations; | 164 | return librarian.Execute(); |
165 | context.LibraryId = Guid.NewGuid().ToString("N"); | ||
166 | context.Intermediates = intermediates; | ||
167 | |||
168 | var librarian = new Librarian(); | ||
169 | return librarian.Combine(context); | ||
170 | } | 165 | } |
171 | 166 | ||
172 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates) | 167 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates) |
@@ -180,16 +175,12 @@ namespace WixToolset.Core.CommandLine | |||
180 | return null; | 175 | return null; |
181 | } | 176 | } |
182 | 177 | ||
183 | var context = this.ServiceProvider.GetService<ILinkContext>(); | 178 | var linker = new Linker(this.ServiceProvider); |
184 | context.Messaging = this.Messaging; | 179 | linker.OutputType = this.OutputType; |
185 | context.Extensions = this.ExtensionManager.Create<ILinkerExtension>(); | 180 | linker.Intermediates = intermediates; |
186 | context.ExtensionData = this.ExtensionManager.Create<IExtensionData>(); | 181 | linker.Libraries = libraries; |
187 | context.ExpectedOutputType = this.OutputType; | 182 | linker.TupleDefinitionCreator = creator; |
188 | context.Intermediates = intermediates.Union(libraries).ToList(); | 183 | return linker.Execute(); |
189 | context.TupleDefinitionCreator = creator; | ||
190 | |||
191 | var linker = new Linker(); | ||
192 | return linker.Link(context); | ||
193 | } | 184 | } |
194 | 185 | ||
195 | private void BindPhase(Intermediate output) | 186 | private void BindPhase(Intermediate output) |
diff --git a/src/WixToolset.Core/CommandLine/CommandLineParser.cs b/src/WixToolset.Core/CommandLine/CommandLineParser.cs index 0e7da42a..c5d3c03b 100644 --- a/src/WixToolset.Core/CommandLine/CommandLineParser.cs +++ b/src/WixToolset.Core/CommandLine/CommandLineParser.cs | |||
@@ -207,14 +207,14 @@ namespace WixToolset.Core.CommandLine | |||
207 | var variables = this.GatherPreprocessorVariables(defines); | 207 | var variables = this.GatherPreprocessorVariables(defines); |
208 | var bindPathList = this.GatherBindPaths(bindPaths); | 208 | var bindPathList = this.GatherBindPaths(bindPaths); |
209 | var type = CalculateOutputType(outputType, outputFile); | 209 | var type = CalculateOutputType(outputType, outputFile); |
210 | return new BuildCommand(this.ServiceProvider, this.Messaging, this.ExtensionManager, sourceFiles, variables, locFiles, libraryFiles, outputFile, type, cabCachePath, cultures, bindFiles, bindPathList, intermediateFolder, contentsFile, outputsFile, builtOutputsFile); | 210 | return new BuildCommand(this.ServiceProvider, sourceFiles, variables, locFiles, libraryFiles, outputFile, type, cabCachePath, cultures, bindFiles, bindPathList, intermediateFolder, contentsFile, outputsFile, builtOutputsFile); |
211 | } | 211 | } |
212 | 212 | ||
213 | case Commands.Compile: | 213 | case Commands.Compile: |
214 | { | 214 | { |
215 | var sourceFiles = GatherSourceFiles(files, outputFolder); | 215 | var sourceFiles = GatherSourceFiles(files, outputFolder); |
216 | var variables = GatherPreprocessorVariables(defines); | 216 | var variables = GatherPreprocessorVariables(defines); |
217 | return new CompileCommand(this.ServiceProvider, this.Messaging, this.ExtensionManager, sourceFiles, variables); | 217 | return new CompileCommand(this.ServiceProvider, sourceFiles, variables); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
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 | } |