diff options
Diffstat (limited to 'src/WixToolset.Core/CommandLine/BuildCommand.cs')
-rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 8392131f..8602c514 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
@@ -6,6 +6,8 @@ namespace WixToolset.Core.CommandLine | |||
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using System.IO; | 7 | using System.IO; |
8 | using System.Linq; | 8 | using System.Linq; |
9 | using System.Threading; | ||
10 | using System.Threading.Tasks; | ||
9 | using System.Xml.Linq; | 11 | using System.Xml.Linq; |
10 | using WixToolset.Data; | 12 | using WixToolset.Data; |
11 | using WixToolset.Extensibility; | 13 | using WixToolset.Extensibility; |
@@ -54,12 +56,12 @@ namespace WixToolset.Core.CommandLine | |||
54 | 56 | ||
55 | private string BuiltOutputsFile { get; set; } | 57 | private string BuiltOutputsFile { get; set; } |
56 | 58 | ||
57 | public int Execute() | 59 | public Task<int> ExecuteAsync(CancellationToken cancellationToken) |
58 | { | 60 | { |
59 | if (this.commandLine.ShowHelp) | 61 | if (this.commandLine.ShowHelp) |
60 | { | 62 | { |
61 | Console.WriteLine("TODO: Show build command help"); | 63 | Console.WriteLine("TODO: Show build command help"); |
62 | return -1; | 64 | return Task.FromResult(-1); |
63 | } | 65 | } |
64 | 66 | ||
65 | this.IntermediateFolder = this.commandLine.CalculateIntermedateFolder(); | 67 | this.IntermediateFolder = this.commandLine.CalculateIntermedateFolder(); |
@@ -107,23 +109,23 @@ namespace WixToolset.Core.CommandLine | |||
107 | 109 | ||
108 | if (this.Messaging.EncounteredError) | 110 | if (this.Messaging.EncounteredError) |
109 | { | 111 | { |
110 | return this.Messaging.LastErrorNumber; | 112 | return Task.FromResult(this.Messaging.LastErrorNumber); |
111 | } | 113 | } |
112 | 114 | ||
113 | var wixobjs = this.CompilePhase(preprocessorVariables, codeFiles); | 115 | var wixobjs = this.CompilePhase(preprocessorVariables, codeFiles, cancellationToken); |
114 | 116 | ||
115 | var wxls = this.LoadLocalizationFiles(this.commandLine.LocalizationFilePaths, preprocessorVariables); | 117 | var wxls = this.LoadLocalizationFiles(this.commandLine.LocalizationFilePaths, preprocessorVariables, cancellationToken); |
116 | 118 | ||
117 | if (this.Messaging.EncounteredError) | 119 | if (this.Messaging.EncounteredError) |
118 | { | 120 | { |
119 | return this.Messaging.LastErrorNumber; | 121 | return Task.FromResult(this.Messaging.LastErrorNumber); |
120 | } | 122 | } |
121 | 123 | ||
122 | if (this.OutputType == OutputType.Library) | 124 | if (this.OutputType == OutputType.Library) |
123 | { | 125 | { |
124 | using (new IntermediateFieldContext("wix.lib")) | 126 | using (new IntermediateFieldContext("wix.lib")) |
125 | { | 127 | { |
126 | var wixlib = this.LibraryPhase(wixobjs, wxls, this.commandLine.BindFiles, this.commandLine.BindPaths); | 128 | var wixlib = this.LibraryPhase(wixobjs, wxls, this.commandLine.BindFiles, this.commandLine.BindPaths, cancellationToken); |
127 | 129 | ||
128 | if (!this.Messaging.EncounteredError) | 130 | if (!this.Messaging.EncounteredError) |
129 | { | 131 | { |
@@ -137,7 +139,7 @@ namespace WixToolset.Core.CommandLine | |||
137 | { | 139 | { |
138 | if (wixipl == null) | 140 | if (wixipl == null) |
139 | { | 141 | { |
140 | wixipl = this.LinkPhase(wixobjs, this.commandLine.LibraryFilePaths, creator); | 142 | wixipl = this.LinkPhase(wixobjs, this.commandLine.LibraryFilePaths, creator, cancellationToken); |
141 | } | 143 | } |
142 | 144 | ||
143 | if (!this.Messaging.EncounteredError) | 145 | if (!this.Messaging.EncounteredError) |
@@ -157,14 +159,14 @@ namespace WixToolset.Core.CommandLine | |||
157 | { | 159 | { |
158 | using (new IntermediateFieldContext("wix.bind")) | 160 | using (new IntermediateFieldContext("wix.bind")) |
159 | { | 161 | { |
160 | this.BindPhase(wixipl, wxls, filterCultures, this.commandLine.CabCachePath, this.commandLine.BindPaths); | 162 | this.BindPhase(wixipl, wxls, filterCultures, this.commandLine.CabCachePath, this.commandLine.BindPaths, cancellationToken); |
161 | } | 163 | } |
162 | } | 164 | } |
163 | } | 165 | } |
164 | } | 166 | } |
165 | } | 167 | } |
166 | 168 | ||
167 | return this.Messaging.LastErrorNumber; | 169 | return Task.FromResult(this.Messaging.LastErrorNumber); |
168 | } | 170 | } |
169 | 171 | ||
170 | public bool TryParseArgument(ICommandLineParser parser, string argument) | 172 | public bool TryParseArgument(ICommandLineParser parser, string argument) |
@@ -210,13 +212,13 @@ namespace WixToolset.Core.CommandLine | |||
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | private IEnumerable<Intermediate> CompilePhase(IDictionary<string, string> preprocessorVariables, IEnumerable<SourceFile> sourceFiles) | 215 | private IEnumerable<Intermediate> CompilePhase(IDictionary<string, string> preprocessorVariables, IEnumerable<SourceFile> sourceFiles, CancellationToken cancellationToken) |
214 | { | 216 | { |
215 | var intermediates = new List<Intermediate>(); | 217 | var intermediates = new List<Intermediate>(); |
216 | 218 | ||
217 | foreach (var sourceFile in sourceFiles) | 219 | foreach (var sourceFile in sourceFiles) |
218 | { | 220 | { |
219 | var document = this.Preprocess(preprocessorVariables, sourceFile.SourcePath); | 221 | var document = this.Preprocess(preprocessorVariables, sourceFile.SourcePath, cancellationToken); |
220 | 222 | ||
221 | if (this.Messaging.EncounteredError) | 223 | if (this.Messaging.EncounteredError) |
222 | { | 224 | { |
@@ -228,6 +230,7 @@ namespace WixToolset.Core.CommandLine | |||
228 | context.OutputPath = sourceFile.OutputPath; | 230 | context.OutputPath = sourceFile.OutputPath; |
229 | context.Platform = this.Platform; | 231 | context.Platform = this.Platform; |
230 | context.Source = document; | 232 | context.Source = document; |
233 | context.CancellationToken = cancellationToken; | ||
231 | 234 | ||
232 | Intermediate intermediate = null; | 235 | Intermediate intermediate = null; |
233 | try | 236 | try |
@@ -251,7 +254,7 @@ namespace WixToolset.Core.CommandLine | |||
251 | return intermediates; | 254 | return intermediates; |
252 | } | 255 | } |
253 | 256 | ||
254 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations, bool bindFiles, IEnumerable<IBindPath> bindPaths) | 257 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations, bool bindFiles, IEnumerable<IBindPath> bindPaths, CancellationToken cancellationToken) |
255 | { | 258 | { |
256 | var context = this.ServiceProvider.GetService<ILibraryContext>(); | 259 | var context = this.ServiceProvider.GetService<ILibraryContext>(); |
257 | context.BindFiles = bindFiles; | 260 | context.BindFiles = bindFiles; |
@@ -259,6 +262,7 @@ namespace WixToolset.Core.CommandLine | |||
259 | context.Extensions = this.ExtensionManager.GetServices<ILibrarianExtension>(); | 262 | context.Extensions = this.ExtensionManager.GetServices<ILibrarianExtension>(); |
260 | context.Localizations = localizations; | 263 | context.Localizations = localizations; |
261 | context.Intermediates = intermediates; | 264 | context.Intermediates = intermediates; |
265 | context.CancellationToken = cancellationToken; | ||
262 | 266 | ||
263 | Intermediate library = null; | 267 | Intermediate library = null; |
264 | try | 268 | try |
@@ -274,7 +278,7 @@ namespace WixToolset.Core.CommandLine | |||
274 | return library; | 278 | return library; |
275 | } | 279 | } |
276 | 280 | ||
277 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates, IEnumerable<string> libraryFiles, ITupleDefinitionCreator creator) | 281 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates, IEnumerable<string> libraryFiles, ITupleDefinitionCreator creator, CancellationToken cancellationToken) |
278 | { | 282 | { |
279 | var libraries = this.LoadLibraries(libraryFiles, creator); | 283 | var libraries = this.LoadLibraries(libraryFiles, creator); |
280 | 284 | ||
@@ -289,12 +293,13 @@ namespace WixToolset.Core.CommandLine | |||
289 | context.ExpectedOutputType = this.OutputType; | 293 | context.ExpectedOutputType = this.OutputType; |
290 | context.Intermediates = intermediates.Concat(libraries).ToList(); | 294 | context.Intermediates = intermediates.Concat(libraries).ToList(); |
291 | context.TupleDefinitionCreator = creator; | 295 | context.TupleDefinitionCreator = creator; |
296 | context.CancellationToken = cancellationToken; | ||
292 | 297 | ||
293 | var linker = this.ServiceProvider.GetService<ILinker>(); | 298 | var linker = this.ServiceProvider.GetService<ILinker>(); |
294 | return linker.Link(context); | 299 | return linker.Link(context); |
295 | } | 300 | } |
296 | 301 | ||
297 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations, IEnumerable<string> filterCultures, string cabCachePath, IEnumerable<IBindPath> bindPaths) | 302 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations, IEnumerable<string> filterCultures, string cabCachePath, IEnumerable<IBindPath> bindPaths, CancellationToken cancellationToken) |
298 | { | 303 | { |
299 | var intermediateFolder = this.IntermediateFolder; | 304 | var intermediateFolder = this.IntermediateFolder; |
300 | if (String.IsNullOrEmpty(intermediateFolder)) | 305 | if (String.IsNullOrEmpty(intermediateFolder)) |
@@ -312,6 +317,7 @@ namespace WixToolset.Core.CommandLine | |||
312 | context.IntermediateFolder = intermediateFolder; | 317 | context.IntermediateFolder = intermediateFolder; |
313 | context.IntermediateRepresentation = output; | 318 | context.IntermediateRepresentation = output; |
314 | context.Localizations = localizations; | 319 | context.Localizations = localizations; |
320 | context.CancellationToken = cancellationToken; | ||
315 | 321 | ||
316 | var resolver = this.ServiceProvider.GetService<IResolver>(); | 322 | var resolver = this.ServiceProvider.GetService<IResolver>(); |
317 | resolveResult = resolver.Resolve(context); | 323 | resolveResult = resolver.Resolve(context); |
@@ -343,6 +349,7 @@ namespace WixToolset.Core.CommandLine | |||
343 | context.PdbPath = this.PdbType == PdbType.None ? null : this.PdbFile ?? Path.ChangeExtension(this.OutputFile, ".wixpdb"); | 349 | context.PdbPath = this.PdbType == PdbType.None ? null : this.PdbFile ?? Path.ChangeExtension(this.OutputFile, ".wixpdb"); |
344 | context.SuppressIces = Array.Empty<string>(); // TODO: set this correctly | 350 | context.SuppressIces = Array.Empty<string>(); // TODO: set this correctly |
345 | context.SuppressValidation = true; // TODO: set this correctly | 351 | context.SuppressValidation = true; // TODO: set this correctly |
352 | context.CancellationToken = cancellationToken; | ||
346 | 353 | ||
347 | var binder = this.ServiceProvider.GetService<IBinder>(); | 354 | var binder = this.ServiceProvider.GetService<IBinder>(); |
348 | bindResult = binder.Bind(context); | 355 | bindResult = binder.Bind(context); |
@@ -363,6 +370,7 @@ namespace WixToolset.Core.CommandLine | |||
363 | context.OutputsFile = this.OutputsFile; | 370 | context.OutputsFile = this.OutputsFile; |
364 | context.BuiltOutputsFile = this.BuiltOutputsFile; | 371 | context.BuiltOutputsFile = this.BuiltOutputsFile; |
365 | context.SuppressAclReset = false; // TODO: correctly set SuppressAclReset | 372 | context.SuppressAclReset = false; // TODO: correctly set SuppressAclReset |
373 | context.CancellationToken = cancellationToken; | ||
366 | 374 | ||
367 | var layout = this.ServiceProvider.GetService<ILayoutCreator>(); | 375 | var layout = this.ServiceProvider.GetService<ILayoutCreator>(); |
368 | layout.Layout(context); | 376 | layout.Layout(context); |
@@ -392,14 +400,14 @@ namespace WixToolset.Core.CommandLine | |||
392 | return Array.Empty<Intermediate>(); | 400 | return Array.Empty<Intermediate>(); |
393 | } | 401 | } |
394 | 402 | ||
395 | private IEnumerable<Localization> LoadLocalizationFiles(IEnumerable<string> locFiles, IDictionary<string, string> preprocessorVariables) | 403 | private IEnumerable<Localization> LoadLocalizationFiles(IEnumerable<string> locFiles, IDictionary<string, string> preprocessorVariables, CancellationToken cancellationToken) |
396 | { | 404 | { |
397 | var localizations = new List<Localization>(); | 405 | var localizations = new List<Localization>(); |
398 | var parser = this.ServiceProvider.GetService<ILocalizationParser>(); | 406 | var parser = this.ServiceProvider.GetService<ILocalizationParser>(); |
399 | 407 | ||
400 | foreach (var loc in locFiles) | 408 | foreach (var loc in locFiles) |
401 | { | 409 | { |
402 | var document = this.Preprocess(preprocessorVariables, loc); | 410 | var document = this.Preprocess(preprocessorVariables, loc, cancellationToken); |
403 | 411 | ||
404 | if (this.Messaging.EncounteredError) | 412 | if (this.Messaging.EncounteredError) |
405 | { | 413 | { |
@@ -413,7 +421,7 @@ namespace WixToolset.Core.CommandLine | |||
413 | return localizations; | 421 | return localizations; |
414 | } | 422 | } |
415 | 423 | ||
416 | private XDocument Preprocess(IDictionary<string, string> preprocessorVariables, string sourcePath) | 424 | private XDocument Preprocess(IDictionary<string, string> preprocessorVariables, string sourcePath, CancellationToken cancellationToken) |
417 | { | 425 | { |
418 | var context = this.ServiceProvider.GetService<IPreprocessContext>(); | 426 | var context = this.ServiceProvider.GetService<IPreprocessContext>(); |
419 | context.Extensions = this.ExtensionManager.GetServices<IPreprocessorExtension>(); | 427 | context.Extensions = this.ExtensionManager.GetServices<IPreprocessorExtension>(); |
@@ -421,6 +429,7 @@ namespace WixToolset.Core.CommandLine | |||
421 | context.IncludeSearchPaths = this.IncludeSearchPaths; | 429 | context.IncludeSearchPaths = this.IncludeSearchPaths; |
422 | context.SourcePath = sourcePath; | 430 | context.SourcePath = sourcePath; |
423 | context.Variables = preprocessorVariables; | 431 | context.Variables = preprocessorVariables; |
432 | context.CancellationToken = cancellationToken; | ||
424 | 433 | ||
425 | IPreprocessResult result = null; | 434 | IPreprocessResult result = null; |
426 | try | 435 | try |