diff options
Diffstat (limited to 'src/WixToolset.Core/CommandLine')
-rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 15 | ||||
-rw-r--r-- | src/WixToolset.Core/CommandLine/CommandLine.cs | 29 | ||||
-rw-r--r-- | src/WixToolset.Core/CommandLine/CompileCommand.cs | 13 |
3 files changed, 39 insertions, 18 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 54bf688d..79bacd22 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
@@ -40,6 +40,8 @@ namespace WixToolset.Core | |||
40 | 40 | ||
41 | public IExtensionManager ExtensionManager { get; } | 41 | public IExtensionManager ExtensionManager { get; } |
42 | 42 | ||
43 | public IEnumerable<string> IncludeSearchPaths { get; } | ||
44 | |||
43 | public IEnumerable<string> LocFiles { get; } | 45 | public IEnumerable<string> LocFiles { get; } |
44 | 46 | ||
45 | public IEnumerable<string> LibraryFiles { get; } | 47 | public IEnumerable<string> LibraryFiles { get; } |
@@ -102,15 +104,18 @@ namespace WixToolset.Core | |||
102 | { | 104 | { |
103 | var intermediates = new List<Intermediate>(); | 105 | var intermediates = new List<Intermediate>(); |
104 | 106 | ||
105 | |||
106 | foreach (var sourceFile in this.SourceFiles) | 107 | foreach (var sourceFile in this.SourceFiles) |
107 | { | 108 | { |
108 | //var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); | 109 | var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); |
109 | //preprocessContext.SourcePath = sourceFile.SourcePath; | 110 | preprocessContext.Messaging = Messaging.Instance; |
110 | //preprocessContext.Variables = this.PreprocessorVariables; | 111 | preprocessContext.Extensions = this.ExtensionManager.Create<IPreprocessorExtension>(); |
112 | preprocessContext.Platform = Platform.X86; // TODO: set this correctly | ||
113 | preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List<string>(); | ||
114 | preprocessContext.SourceFile = sourceFile.SourcePath; | ||
115 | preprocessContext.Variables = new Dictionary<string, string>(this.PreprocessorVariables); | ||
111 | 116 | ||
112 | var preprocessor = new Preprocessor(); | 117 | var preprocessor = new Preprocessor(); |
113 | var document = preprocessor.Process(sourceFile.SourcePath, this.PreprocessorVariables); | 118 | var document = preprocessor.Process(preprocessContext); |
114 | 119 | ||
115 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); | 120 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); |
116 | compileContext.Messaging = Messaging.Instance; | 121 | compileContext.Messaging = Messaging.Instance; |
diff --git a/src/WixToolset.Core/CommandLine/CommandLine.cs b/src/WixToolset.Core/CommandLine/CommandLine.cs index c6fe11b7..9bedca9a 100644 --- a/src/WixToolset.Core/CommandLine/CommandLine.cs +++ b/src/WixToolset.Core/CommandLine/CommandLine.cs | |||
@@ -22,7 +22,7 @@ namespace WixToolset.Core | |||
22 | Bind, | 22 | Bind, |
23 | } | 23 | } |
24 | 24 | ||
25 | internal class CommandLine : ICommandLine | 25 | internal class CommandLine : ICommandLine, IParseCommandLine |
26 | { | 26 | { |
27 | public CommandLine() | 27 | public CommandLine() |
28 | { | 28 | { |
@@ -57,10 +57,10 @@ namespace WixToolset.Core | |||
57 | args = CommandLine.ParseArgumentsToArray(context.Arguments).Union(args).ToArray(); | 57 | args = CommandLine.ParseArgumentsToArray(context.Arguments).Union(args).ToArray(); |
58 | } | 58 | } |
59 | 59 | ||
60 | return this.ParseStandardCommandLine(args); | 60 | return this.ParseStandardCommandLine(context, args); |
61 | } | 61 | } |
62 | 62 | ||
63 | private ICommandLineCommand ParseStandardCommandLine(string[] args) | 63 | private ICommandLineCommand ParseStandardCommandLine(ICommandLineContext context, string[] args) |
64 | { | 64 | { |
65 | var next = String.Empty; | 65 | var next = String.Empty; |
66 | 66 | ||
@@ -90,7 +90,7 @@ namespace WixToolset.Core | |||
90 | var builtOutputsFile = String.Empty; | 90 | var builtOutputsFile = String.Empty; |
91 | var wixProjectFile = String.Empty; | 91 | var wixProjectFile = String.Empty; |
92 | 92 | ||
93 | this.Parse(args, (cmdline, arg) => Enum.TryParse(arg, true, out command), (cmdline, arg) => | 93 | this.Parse(context, args, (cmdline, arg) => Enum.TryParse(arg, true, out command), (cmdline, arg) => |
94 | { | 94 | { |
95 | if (cmdline.IsSwitch(arg)) | 95 | if (cmdline.IsSwitch(arg)) |
96 | { | 96 | { |
@@ -279,13 +279,13 @@ namespace WixToolset.Core | |||
279 | } | 279 | } |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | private ICommandLine Parse(string[] commandLineArguments, Func<CommandLine, string, bool> parseCommand, Func<CommandLine, string, bool> parseArgument) | 282 | private ICommandLine Parse(ICommandLineContext context, string[] commandLineArguments, Func<CommandLine, string, bool> parseCommand, Func<CommandLine, string, bool> parseArgument) |
283 | { | 283 | { |
284 | this.FlattenArgumentsWithResponseFilesIntoOriginalArguments(commandLineArguments); | 284 | this.FlattenArgumentsWithResponseFilesIntoOriginalArguments(commandLineArguments); |
285 | 285 | ||
286 | this.QueueArgumentsAndLoadExtensions(this.OriginalArguments); | 286 | this.QueueArgumentsAndLoadExtensions(this.OriginalArguments); |
287 | 287 | ||
288 | this.ProcessRemainingArguments(parseArgument, parseCommand); | 288 | this.ProcessRemainingArguments(context, parseArgument, parseCommand); |
289 | 289 | ||
290 | return this; | 290 | return this; |
291 | } | 291 | } |
@@ -413,7 +413,7 @@ namespace WixToolset.Core | |||
413 | /// <returns>True if a valid switch exists there, false if not.</returns> | 413 | /// <returns>True if a valid switch exists there, false if not.</returns> |
414 | public bool IsSwitch(string arg) | 414 | public bool IsSwitch(string arg) |
415 | { | 415 | { |
416 | return arg != null && ('/' == arg[0] || '-' == arg[0]); | 416 | return arg != null && arg.Length > 1 && ('/' == arg[0] || '-' == arg[0]); |
417 | } | 417 | } |
418 | 418 | ||
419 | /// <summary> | 419 | /// <summary> |
@@ -522,10 +522,15 @@ namespace WixToolset.Core | |||
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | private void ProcessRemainingArguments(Func<CommandLine, string, bool> parseArgument, Func<CommandLine, string, bool> parseCommand) | 525 | private void ProcessRemainingArguments(ICommandLineContext context, Func<CommandLine, string, bool> parseArgument, Func<CommandLine, string, bool> parseCommand) |
526 | { | 526 | { |
527 | var extensions = this.ExtensionManager.Create<IExtensionCommandLine>(); | 527 | var extensions = this.ExtensionManager.Create<IExtensionCommandLine>(); |
528 | 528 | ||
529 | foreach (var extension in extensions) | ||
530 | { | ||
531 | extension.PreParse(context); | ||
532 | } | ||
533 | |||
529 | while (!this.ShowHelp && | 534 | while (!this.ShowHelp && |
530 | String.IsNullOrEmpty(this.ErrorArgument) && | 535 | String.IsNullOrEmpty(this.ErrorArgument) && |
531 | TryDequeue(this.RemainingArguments, out var arg)) | 536 | TryDequeue(this.RemainingArguments, out var arg)) |
@@ -566,10 +571,10 @@ namespace WixToolset.Core | |||
566 | { | 571 | { |
567 | foreach (var extension in extensions) | 572 | foreach (var extension in extensions) |
568 | { | 573 | { |
569 | //if (extension.ParseArgument(this, arg)) | 574 | if (extension.TryParseArgument(this, arg)) |
570 | //{ | 575 | { |
571 | // return true; | 576 | return true; |
572 | //} | 577 | } |
573 | } | 578 | } |
574 | 579 | ||
575 | return false; | 580 | return false; |
diff --git a/src/WixToolset.Core/CommandLine/CompileCommand.cs b/src/WixToolset.Core/CommandLine/CompileCommand.cs index 58ba9d29..e7fcdd4d 100644 --- a/src/WixToolset.Core/CommandLine/CompileCommand.cs +++ b/src/WixToolset.Core/CommandLine/CompileCommand.cs | |||
@@ -4,6 +4,7 @@ namespace WixToolset.Core | |||
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using System.Linq; | ||
7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
8 | using WixToolset.Extensibility; | 9 | using WixToolset.Extensibility; |
9 | using WixToolset.Extensibility.Services; | 10 | using WixToolset.Extensibility.Services; |
@@ -22,6 +23,8 @@ namespace WixToolset.Core | |||
22 | 23 | ||
23 | private IExtensionManager ExtensionManager { get; } | 24 | private IExtensionManager ExtensionManager { get; } |
24 | 25 | ||
26 | public IEnumerable<string> IncludeSearchPaths { get; } | ||
27 | |||
25 | private IEnumerable<SourceFile> SourceFiles { get; } | 28 | private IEnumerable<SourceFile> SourceFiles { get; } |
26 | 29 | ||
27 | private IDictionary<string, string> PreprocessorVariables { get; } | 30 | private IDictionary<string, string> PreprocessorVariables { get; } |
@@ -30,8 +33,16 @@ namespace WixToolset.Core | |||
30 | { | 33 | { |
31 | foreach (var sourceFile in this.SourceFiles) | 34 | foreach (var sourceFile in this.SourceFiles) |
32 | { | 35 | { |
36 | var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); | ||
37 | preprocessContext.Messaging = Messaging.Instance; | ||
38 | preprocessContext.Extensions = this.ExtensionManager.Create<IPreprocessorExtension>(); | ||
39 | preprocessContext.Platform = Platform.X86; // TODO: set this correctly | ||
40 | preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List<string>(); | ||
41 | preprocessContext.SourceFile = sourceFile.SourcePath; | ||
42 | preprocessContext.Variables = new Dictionary<string, string>(this.PreprocessorVariables); | ||
43 | |||
33 | var preprocessor = new Preprocessor(); | 44 | var preprocessor = new Preprocessor(); |
34 | var document = preprocessor.Process(sourceFile.SourcePath, this.PreprocessorVariables); | 45 | var document = preprocessor.Process(preprocessContext); |
35 | 46 | ||
36 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); | 47 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); |
37 | compileContext.Messaging = Messaging.Instance; | 48 | compileContext.Messaging = Messaging.Instance; |