diff options
author | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
commit | 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (patch) | |
tree | 59d1f151bfde8068b6014b05b5c8cfea3402c974 /src/WixToolset.Core/CommandLine/BuildCommand.cs | |
parent | 6f1665ed759b31bd095f186f9239232c653597cd (diff) | |
download | wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.gz wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.bz2 wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.zip |
Integrate simplified message handling
Diffstat (limited to 'src/WixToolset.Core/CommandLine/BuildCommand.cs')
-rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 7a63b869..43b75f33 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
@@ -13,9 +13,10 @@ namespace WixToolset.Core | |||
13 | 13 | ||
14 | internal class BuildCommand : ICommandLineCommand | 14 | internal class BuildCommand : ICommandLineCommand |
15 | { | 15 | { |
16 | public BuildCommand(IServiceProvider serviceProvider, 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, string wixProjectFile) | 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, string wixProjectFile) |
17 | { | 17 | { |
18 | this.ServiceProvider = serviceProvider; | 18 | this.ServiceProvider = serviceProvider; |
19 | this.Messaging = messaging; | ||
19 | this.ExtensionManager = extensions; | 20 | this.ExtensionManager = extensions; |
20 | this.LocFiles = locFiles; | 21 | this.LocFiles = locFiles; |
21 | this.LibraryFiles = libraryFiles; | 22 | this.LibraryFiles = libraryFiles; |
@@ -38,6 +39,8 @@ namespace WixToolset.Core | |||
38 | 39 | ||
39 | public IServiceProvider ServiceProvider { get; } | 40 | public IServiceProvider ServiceProvider { get; } |
40 | 41 | ||
42 | public IMessaging Messaging { get; } | ||
43 | |||
41 | public IExtensionManager ExtensionManager { get; } | 44 | public IExtensionManager ExtensionManager { get; } |
42 | 45 | ||
43 | public IEnumerable<string> IncludeSearchPaths { get; } | 46 | public IEnumerable<string> IncludeSearchPaths { get; } |
@@ -91,13 +94,13 @@ namespace WixToolset.Core | |||
91 | { | 94 | { |
92 | var output = this.LinkPhase(intermediates); | 95 | var output = this.LinkPhase(intermediates); |
93 | 96 | ||
94 | if (!Messaging.Instance.EncounteredError) | 97 | if (!this.Messaging.EncounteredError) |
95 | { | 98 | { |
96 | this.BindPhase(output); | 99 | this.BindPhase(output); |
97 | } | 100 | } |
98 | } | 101 | } |
99 | 102 | ||
100 | return Messaging.Instance.LastErrorNumber; | 103 | return this.Messaging.LastErrorNumber; |
101 | } | 104 | } |
102 | 105 | ||
103 | private IEnumerable<Intermediate> CompilePhase() | 106 | private IEnumerable<Intermediate> CompilePhase() |
@@ -107,7 +110,7 @@ namespace WixToolset.Core | |||
107 | foreach (var sourceFile in this.SourceFiles) | 110 | foreach (var sourceFile in this.SourceFiles) |
108 | { | 111 | { |
109 | var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); | 112 | var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); |
110 | preprocessContext.Messaging = Messaging.Instance; | 113 | preprocessContext.Messaging = this.Messaging; |
111 | preprocessContext.Extensions = this.ExtensionManager.Create<IPreprocessorExtension>(); | 114 | preprocessContext.Extensions = this.ExtensionManager.Create<IPreprocessorExtension>(); |
112 | preprocessContext.Platform = Platform.X86; // TODO: set this correctly | 115 | preprocessContext.Platform = Platform.X86; // TODO: set this correctly |
113 | preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List<string>(); | 116 | preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List<string>(); |
@@ -117,18 +120,24 @@ namespace WixToolset.Core | |||
117 | var preprocessor = new Preprocessor(); | 120 | var preprocessor = new Preprocessor(); |
118 | var document = preprocessor.Process(preprocessContext); | 121 | var document = preprocessor.Process(preprocessContext); |
119 | 122 | ||
120 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); | 123 | if (!this.Messaging.EncounteredError) |
121 | compileContext.Messaging = Messaging.Instance; | 124 | { |
122 | compileContext.CompilationId = Guid.NewGuid().ToString("N"); | 125 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); |
123 | compileContext.Extensions = this.ExtensionManager.Create<ICompilerExtension>(); | 126 | compileContext.Messaging = this.Messaging; |
124 | compileContext.OutputPath = sourceFile.OutputPath; | 127 | compileContext.CompilationId = Guid.NewGuid().ToString("N"); |
125 | compileContext.Platform = Platform.X86; // TODO: set this correctly | 128 | compileContext.Extensions = this.ExtensionManager.Create<ICompilerExtension>(); |
126 | compileContext.Source = document; | 129 | compileContext.OutputPath = sourceFile.OutputPath; |
127 | 130 | compileContext.Platform = Platform.X86; // TODO: set this correctly | |
128 | var compiler = new Compiler(); | 131 | compileContext.Source = document; |
129 | var intermediate = compiler.Compile(compileContext); | 132 | |
130 | 133 | var compiler = new Compiler(); | |
131 | intermediates.Add(intermediate); | 134 | var intermediate = compiler.Compile(compileContext); |
135 | |||
136 | if (!this.Messaging.EncounteredError) | ||
137 | { | ||
138 | intermediates.Add(intermediate); | ||
139 | } | ||
140 | } | ||
132 | } | 141 | } |
133 | 142 | ||
134 | return intermediates; | 143 | return intermediates; |
@@ -139,7 +148,7 @@ namespace WixToolset.Core | |||
139 | var localizations = this.LoadLocalizationFiles().ToList(); | 148 | var localizations = this.LoadLocalizationFiles().ToList(); |
140 | 149 | ||
141 | // If there was an error adding localization files, then bail. | 150 | // If there was an error adding localization files, then bail. |
142 | if (Messaging.Instance.EncounteredError) | 151 | if (this.Messaging.EncounteredError) |
143 | { | 152 | { |
144 | return null; | 153 | return null; |
145 | } | 154 | } |
@@ -166,7 +175,7 @@ namespace WixToolset.Core | |||
166 | var libraries = this.LoadLibraries(creator); | 175 | var libraries = this.LoadLibraries(creator); |
167 | 176 | ||
168 | var context = this.ServiceProvider.GetService<ILinkContext>(); | 177 | var context = this.ServiceProvider.GetService<ILinkContext>(); |
169 | context.Messaging = Messaging.Instance; | 178 | context.Messaging = this.Messaging; |
170 | context.Extensions = this.ExtensionManager.Create<ILinkerExtension>(); | 179 | context.Extensions = this.ExtensionManager.Create<ILinkerExtension>(); |
171 | context.ExtensionData = this.ExtensionManager.Create<IExtensionData>(); | 180 | context.ExtensionData = this.ExtensionManager.Create<IExtensionData>(); |
172 | context.ExpectedOutputType = this.OutputType; | 181 | context.ExpectedOutputType = this.OutputType; |
@@ -182,7 +191,7 @@ namespace WixToolset.Core | |||
182 | { | 191 | { |
183 | var localizations = this.LoadLocalizationFiles().ToList(); | 192 | var localizations = this.LoadLocalizationFiles().ToList(); |
184 | 193 | ||
185 | var localizer = new Localizer(localizations); | 194 | var localizer = new Localizer(this.Messaging, localizations); |
186 | 195 | ||
187 | var resolver = CreateWixResolverWithVariables(localizer, output); | 196 | var resolver = CreateWixResolverWithVariables(localizer, output); |
188 | 197 | ||
@@ -193,7 +202,7 @@ namespace WixToolset.Core | |||
193 | } | 202 | } |
194 | 203 | ||
195 | var context = this.ServiceProvider.GetService<IBindContext>(); | 204 | var context = this.ServiceProvider.GetService<IBindContext>(); |
196 | context.Messaging = Messaging.Instance; | 205 | context.Messaging = this.Messaging; |
197 | context.ExtensionManager = this.ExtensionManager; | 206 | context.ExtensionManager = this.ExtensionManager; |
198 | context.BindPaths = this.BindPaths ?? Array.Empty<BindPath>(); | 207 | context.BindPaths = this.BindPaths ?? Array.Empty<BindPath>(); |
199 | //context.CabbingThreadCount = this.CabbingThreadCount; | 208 | //context.CabbingThreadCount = this.CabbingThreadCount; |
@@ -234,11 +243,11 @@ namespace WixToolset.Core | |||
234 | } | 243 | } |
235 | catch (WixCorruptFileException e) | 244 | catch (WixCorruptFileException e) |
236 | { | 245 | { |
237 | Messaging.Instance.OnMessage(e.Error); | 246 | this.Messaging.Write(e.Error); |
238 | } | 247 | } |
239 | catch (WixUnexpectedFileFormatException e) | 248 | catch (WixUnexpectedFileFormatException e) |
240 | { | 249 | { |
241 | Messaging.Instance.OnMessage(e.Error); | 250 | this.Messaging.Write(e.Error); |
242 | } | 251 | } |
243 | } | 252 | } |
244 | } | 253 | } |
@@ -250,15 +259,15 @@ namespace WixToolset.Core | |||
250 | { | 259 | { |
251 | foreach (var loc in this.LocFiles) | 260 | foreach (var loc in this.LocFiles) |
252 | { | 261 | { |
253 | var localization = Localizer.ParseLocalizationFile(loc); | 262 | var localization = Localizer.ParseLocalizationFile(this.Messaging, loc); |
254 | 263 | ||
255 | yield return localization; | 264 | yield return localization; |
256 | } | 265 | } |
257 | } | 266 | } |
258 | 267 | ||
259 | private static WixVariableResolver CreateWixResolverWithVariables(Localizer localizer, Intermediate output) | 268 | private WixVariableResolver CreateWixResolverWithVariables(Localizer localizer, Intermediate output) |
260 | { | 269 | { |
261 | var resolver = new WixVariableResolver(localizer); | 270 | var resolver = new WixVariableResolver(this.Messaging, localizer); |
262 | 271 | ||
263 | // Gather all the wix variables. | 272 | // Gather all the wix variables. |
264 | var wixVariables = output?.Sections.SelectMany(s => s.Tuples).OfType<WixVariableTuple>(); | 273 | var wixVariables = output?.Sections.SelectMany(s => s.Tuples).OfType<WixVariableTuple>(); |