diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-03-01 11:12:52 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@robmensching.com> | 2019-03-01 11:15:40 -0800 |
| commit | 5392cf57c09bddde7157e5b26c5c2a013f819ead (patch) | |
| tree | 96063a49293bd9eea122218e770b52d3c20812f2 /src/WixToolset.Core/CommandLine | |
| parent | a4f5a5a042c00254607fbecdf132a2e2a91a1bdd (diff) | |
| download | wix-5392cf57c09bddde7157e5b26c5c2a013f819ead.tar.gz wix-5392cf57c09bddde7157e5b26c5c2a013f819ead.tar.bz2 wix-5392cf57c09bddde7157e5b26c5c2a013f819ead.zip | |
Integrate interface-only WixToolset.Extensibility change
Diffstat (limited to 'src/WixToolset.Core/CommandLine')
| -rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 275 |
1 files changed, 144 insertions, 131 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index fbc88f08..b83aaec4 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
| @@ -21,7 +21,7 @@ namespace WixToolset.Core.CommandLine | |||
| 21 | this.ServiceProvider = serviceProvider; | 21 | this.ServiceProvider = serviceProvider; |
| 22 | this.Messaging = serviceProvider.GetService<IMessaging>(); | 22 | this.Messaging = serviceProvider.GetService<IMessaging>(); |
| 23 | this.ExtensionManager = serviceProvider.GetService<IExtensionManager>(); | 23 | this.ExtensionManager = serviceProvider.GetService<IExtensionManager>(); |
| 24 | this.commandLine = new CommandLine(this.Messaging); | 24 | this.commandLine = new CommandLine(this.ServiceProvider, this.Messaging); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | public bool ShowLogo => this.commandLine.ShowLogo; | 27 | public bool ShowLogo => this.commandLine.ShowLogo; |
| @@ -214,7 +214,7 @@ namespace WixToolset.Core.CommandLine | |||
| 214 | return intermediates; | 214 | return intermediates; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations, bool bindFiles, IEnumerable<BindPath> bindPaths) | 217 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations, bool bindFiles, IEnumerable<IBindPath> bindPaths) |
| 218 | { | 218 | { |
| 219 | var context = this.ServiceProvider.GetService<ILibraryContext>(); | 219 | var context = this.ServiceProvider.GetService<ILibraryContext>(); |
| 220 | context.BindFiles = bindFiles; | 220 | context.BindFiles = bindFiles; |
| @@ -257,7 +257,7 @@ namespace WixToolset.Core.CommandLine | |||
| 257 | return linker.Link(context); | 257 | return linker.Link(context); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations, IEnumerable<string> filterCultures, string cabCachePath, IEnumerable<BindPath> bindPaths) | 260 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations, IEnumerable<string> filterCultures, string cabCachePath, IEnumerable<IBindPath> bindPaths) |
| 261 | { | 261 | { |
| 262 | var intermediateFolder = this.IntermediateFolder; | 262 | var intermediateFolder = this.IntermediateFolder; |
| 263 | if (String.IsNullOrEmpty(intermediateFolder)) | 263 | if (String.IsNullOrEmpty(intermediateFolder)) |
| @@ -265,7 +265,7 @@ namespace WixToolset.Core.CommandLine | |||
| 265 | intermediateFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | 265 | intermediateFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | ResolveResult resolveResult; | 268 | IResolveResult resolveResult; |
| 269 | { | 269 | { |
| 270 | var context = this.ServiceProvider.GetService<IResolveContext>(); | 270 | var context = this.ServiceProvider.GetService<IResolveContext>(); |
| 271 | context.BindPaths = bindPaths; | 271 | context.BindPaths = bindPaths; |
| @@ -286,7 +286,7 @@ namespace WixToolset.Core.CommandLine | |||
| 286 | return; | 286 | return; |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | BindResult bindResult; | 289 | IBindResult bindResult; |
| 290 | { | 290 | { |
| 291 | var context = this.ServiceProvider.GetService<IBindContext>(); | 291 | var context = this.ServiceProvider.GetService<IBindContext>(); |
| 292 | //context.CabbingThreadCount = this.CabbingThreadCount; | 292 | //context.CabbingThreadCount = this.CabbingThreadCount; |
| @@ -397,7 +397,7 @@ namespace WixToolset.Core.CommandLine | |||
| 397 | 397 | ||
| 398 | public bool BindFiles { get; private set; } | 398 | public bool BindFiles { get; private set; } |
| 399 | 399 | ||
| 400 | public List<BindPath> BindPaths { get; } = new List<BindPath>(); | 400 | public List<IBindPath> BindPaths { get; } = new List<IBindPath>(); |
| 401 | 401 | ||
| 402 | public string CabCachePath { get; private set; } | 402 | public string CabCachePath { get; private set; } |
| 403 | 403 | ||
| @@ -431,11 +431,14 @@ namespace WixToolset.Core.CommandLine | |||
| 431 | 431 | ||
| 432 | public string BuiltOutputsFile { get; private set; } | 432 | public string BuiltOutputsFile { get; private set; } |
| 433 | 433 | ||
| 434 | public CommandLine(IMessaging messaging) | 434 | public CommandLine(IServiceProvider serviceProvider, IMessaging messaging) |
| 435 | { | 435 | { |
| 436 | this.ServiceProvider = serviceProvider; | ||
| 436 | this.Messaging = messaging; | 437 | this.Messaging = messaging; |
| 437 | } | 438 | } |
| 438 | 439 | ||
| 440 | private IServiceProvider ServiceProvider { get; } | ||
| 441 | |||
| 439 | private IMessaging Messaging { get; } | 442 | private IMessaging Messaging { get; } |
| 440 | 443 | ||
| 441 | public bool TryParseArgument(string arg, ICommandLineParser parser) | 444 | public bool TryParseArgument(string arg, ICommandLineParser parser) |
| @@ -445,109 +448,109 @@ namespace WixToolset.Core.CommandLine | |||
| 445 | var parameter = arg.Substring(1); | 448 | var parameter = arg.Substring(1); |
| 446 | switch (parameter.ToLowerInvariant()) | 449 | switch (parameter.ToLowerInvariant()) |
| 447 | { | 450 | { |
| 448 | case "?": | 451 | case "?": |
| 449 | case "h": | 452 | case "h": |
| 450 | case "help": | 453 | case "help": |
| 451 | this.ShowHelp = true; | 454 | this.ShowHelp = true; |
| 452 | return true; | ||
| 453 | |||
| 454 | case "arch": | ||
| 455 | case "platform": | ||
| 456 | { | ||
| 457 | var value = parser.GetNextArgumentOrError(arg); | ||
| 458 | if (Enum.TryParse(value, true, out Platform platform)) | ||
| 459 | { | ||
| 460 | this.Platform = platform; | ||
| 461 | return true; | 455 | return true; |
| 462 | } | ||
| 463 | break; | ||
| 464 | } | ||
| 465 | |||
| 466 | case "bindfiles": | ||
| 467 | this.BindFiles = true; | ||
| 468 | return true; | ||
| 469 | 456 | ||
| 470 | case "bindpath": | 457 | case "arch": |
| 471 | { | 458 | case "platform": |
| 472 | var value = parser.GetNextArgumentOrError(arg); | ||
| 473 | if (this.TryParseBindPath(value, out var bindPath)) | ||
| 474 | { | 459 | { |
| 475 | this.BindPaths.Add(bindPath); | 460 | var value = parser.GetNextArgumentOrError(arg); |
| 476 | return true; | 461 | if (Enum.TryParse(value, true, out Platform platform)) |
| 462 | { | ||
| 463 | this.Platform = platform; | ||
| 464 | return true; | ||
| 465 | } | ||
| 466 | break; | ||
| 477 | } | 467 | } |
| 478 | break; | 468 | |
| 479 | } | 469 | case "bindfiles": |
| 480 | case "cc": | 470 | this.BindFiles = true; |
| 481 | this.CabCachePath = parser.GetNextArgumentOrError(arg); | 471 | return true; |
| 482 | return true; | 472 | |
| 483 | 473 | case "bindpath": | |
| 484 | case "culture": | ||
| 485 | parser.GetNextArgumentOrError(arg, this.Cultures); | ||
| 486 | return true; | ||
| 487 | |||
| 488 | case "contentsfile": | ||
| 489 | this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 490 | return true; | ||
| 491 | case "outputsfile": | ||
| 492 | this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 493 | return true; | ||
| 494 | case "builtoutputsfile": | ||
| 495 | this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 496 | return true; | ||
| 497 | |||
| 498 | case "d": | ||
| 499 | case "define": | ||
| 500 | parser.GetNextArgumentOrError(arg, this.Defines); | ||
| 501 | return true; | ||
| 502 | |||
| 503 | case "i": | ||
| 504 | case "includepath": | ||
| 505 | parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths); | ||
| 506 | return true; | ||
| 507 | |||
| 508 | case "intermediatefolder": | ||
| 509 | this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); | ||
| 510 | return true; | ||
| 511 | |||
| 512 | case "loc": | ||
| 513 | parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths); | ||
| 514 | return true; | ||
| 515 | |||
| 516 | case "lib": | ||
| 517 | parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths); | ||
| 518 | return true; | ||
| 519 | |||
| 520 | case "o": | ||
| 521 | case "out": | ||
| 522 | this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 523 | return true; | ||
| 524 | |||
| 525 | case "outputtype": | ||
| 526 | this.OutputType = parser.GetNextArgumentOrError(arg); | ||
| 527 | return true; | ||
| 528 | |||
| 529 | case "nologo": | ||
| 530 | this.ShowLogo = false; | ||
| 531 | return true; | ||
| 532 | |||
| 533 | case "v": | ||
| 534 | case "verbose": | ||
| 535 | this.Messaging.ShowVerboseMessages = true; | ||
| 536 | return true; | ||
| 537 | |||
| 538 | case "sval": | ||
| 539 | // todo: implement | ||
| 540 | return true; | ||
| 541 | |||
| 542 | case "sw": | ||
| 543 | case "suppresswarning": | ||
| 544 | var warning = parser.GetNextArgumentOrError(arg); | ||
| 545 | if (!String.IsNullOrEmpty(warning)) | ||
| 546 | { | 474 | { |
| 547 | var warningNumber = Convert.ToInt32(warning); | 475 | var value = parser.GetNextArgumentOrError(arg); |
| 548 | this.Messaging.SuppressWarningMessage(warningNumber); | 476 | if (this.TryParseBindPath(value, out var bindPath)) |
| 477 | { | ||
| 478 | this.BindPaths.Add(bindPath); | ||
| 479 | return true; | ||
| 480 | } | ||
| 481 | break; | ||
| 549 | } | 482 | } |
| 550 | return true; | 483 | case "cc": |
| 484 | this.CabCachePath = parser.GetNextArgumentOrError(arg); | ||
| 485 | return true; | ||
| 486 | |||
| 487 | case "culture": | ||
| 488 | parser.GetNextArgumentOrError(arg, this.Cultures); | ||
| 489 | return true; | ||
| 490 | |||
| 491 | case "contentsfile": | ||
| 492 | this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 493 | return true; | ||
| 494 | case "outputsfile": | ||
| 495 | this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 496 | return true; | ||
| 497 | case "builtoutputsfile": | ||
| 498 | this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 499 | return true; | ||
| 500 | |||
| 501 | case "d": | ||
| 502 | case "define": | ||
| 503 | parser.GetNextArgumentOrError(arg, this.Defines); | ||
| 504 | return true; | ||
| 505 | |||
| 506 | case "i": | ||
| 507 | case "includepath": | ||
| 508 | parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths); | ||
| 509 | return true; | ||
| 510 | |||
| 511 | case "intermediatefolder": | ||
| 512 | this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); | ||
| 513 | return true; | ||
| 514 | |||
| 515 | case "loc": | ||
| 516 | parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths); | ||
| 517 | return true; | ||
| 518 | |||
| 519 | case "lib": | ||
| 520 | parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths); | ||
| 521 | return true; | ||
| 522 | |||
| 523 | case "o": | ||
| 524 | case "out": | ||
| 525 | this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); | ||
| 526 | return true; | ||
| 527 | |||
| 528 | case "outputtype": | ||
| 529 | this.OutputType = parser.GetNextArgumentOrError(arg); | ||
| 530 | return true; | ||
| 531 | |||
| 532 | case "nologo": | ||
| 533 | this.ShowLogo = false; | ||
| 534 | return true; | ||
| 535 | |||
| 536 | case "v": | ||
| 537 | case "verbose": | ||
| 538 | this.Messaging.ShowVerboseMessages = true; | ||
| 539 | return true; | ||
| 540 | |||
| 541 | case "sval": | ||
| 542 | // todo: implement | ||
| 543 | return true; | ||
| 544 | |||
| 545 | case "sw": | ||
| 546 | case "suppresswarning": | ||
| 547 | var warning = parser.GetNextArgumentOrError(arg); | ||
| 548 | if (!String.IsNullOrEmpty(warning)) | ||
| 549 | { | ||
| 550 | var warningNumber = Convert.ToInt32(warning); | ||
| 551 | this.Messaging.SuppressWarningMessage(warningNumber); | ||
| 552 | } | ||
| 553 | return true; | ||
| 551 | } | 554 | } |
| 552 | 555 | ||
| 553 | return false; | 556 | return false; |
| @@ -573,37 +576,37 @@ namespace WixToolset.Core.CommandLine | |||
| 573 | 576 | ||
| 574 | switch (this.OutputType.ToLowerInvariant()) | 577 | switch (this.OutputType.ToLowerInvariant()) |
| 575 | { | 578 | { |
| 576 | case "bundle": | 579 | case "bundle": |
| 577 | case ".exe": | 580 | case ".exe": |
| 578 | return Data.OutputType.Bundle; | 581 | return Data.OutputType.Bundle; |
| 579 | 582 | ||
| 580 | case "library": | 583 | case "library": |
| 581 | case ".wixlib": | 584 | case ".wixlib": |
| 582 | return Data.OutputType.Library; | 585 | return Data.OutputType.Library; |
| 583 | 586 | ||
| 584 | case "module": | 587 | case "module": |
| 585 | case ".msm": | 588 | case ".msm": |
| 586 | return Data.OutputType.Module; | 589 | return Data.OutputType.Module; |
| 587 | 590 | ||
| 588 | case "patch": | 591 | case "patch": |
| 589 | case ".msp": | 592 | case ".msp": |
| 590 | return Data.OutputType.Patch; | 593 | return Data.OutputType.Patch; |
| 591 | 594 | ||
| 592 | case ".pcp": | 595 | case ".pcp": |
| 593 | return Data.OutputType.PatchCreation; | 596 | return Data.OutputType.PatchCreation; |
| 594 | 597 | ||
| 595 | case "product": | 598 | case "product": |
| 596 | case "package": | 599 | case "package": |
| 597 | case ".msi": | 600 | case ".msi": |
| 598 | return Data.OutputType.Product; | 601 | return Data.OutputType.Product; |
| 599 | 602 | ||
| 600 | case "transform": | 603 | case "transform": |
| 601 | case ".mst": | 604 | case ".mst": |
| 602 | return Data.OutputType.Transform; | 605 | return Data.OutputType.Transform; |
| 603 | 606 | ||
| 604 | case "intermediatepostlink": | 607 | case "intermediatepostlink": |
| 605 | case ".wixipl": | 608 | case ".wixipl": |
| 606 | return Data.OutputType.IntermediatePostLink; | 609 | return Data.OutputType.IntermediatePostLink; |
| 607 | } | 610 | } |
| 608 | 611 | ||
| 609 | return Data.OutputType.Unknown; | 612 | return Data.OutputType.Unknown; |
| @@ -656,7 +659,6 @@ namespace WixToolset.Core.CommandLine | |||
| 656 | return variables; | 659 | return variables; |
| 657 | } | 660 | } |
| 658 | 661 | ||
| 659 | |||
| 660 | public IEnumerable<SourceFile> GatherSourceFiles(string intermediateDirectory) | 662 | public IEnumerable<SourceFile> GatherSourceFiles(string intermediateDirectory) |
| 661 | { | 663 | { |
| 662 | var files = new List<SourceFile>(); | 664 | var files = new List<SourceFile>(); |
| @@ -672,10 +674,21 @@ namespace WixToolset.Core.CommandLine | |||
| 672 | return files; | 674 | return files; |
| 673 | } | 675 | } |
| 674 | 676 | ||
| 675 | private bool TryParseBindPath(string bindPath, out BindPath bp) | 677 | private bool TryParseBindPath(string bindPath, out IBindPath bp) |
| 676 | { | 678 | { |
| 677 | var namedPath = bindPath.Split(BindPathSplit, 2); | 679 | var namedPath = bindPath.Split(BindPathSplit, 2); |
| 678 | bp = (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]); | 680 | |
| 681 | bp = this.ServiceProvider.GetService<IBindPath>(); | ||
| 682 | |||
| 683 | if (1 == namedPath.Length) | ||
| 684 | { | ||
| 685 | bp.Path = namedPath[0]; | ||
| 686 | } | ||
| 687 | else | ||
| 688 | { | ||
| 689 | bp.Name = namedPath[0]; | ||
| 690 | bp.Path = namedPath[1]; | ||
| 691 | } | ||
| 679 | 692 | ||
| 680 | if (File.Exists(bp.Path)) | 693 | if (File.Exists(bp.Path)) |
| 681 | { | 694 | { |
