aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2018-10-03 14:30:58 -0700
committerRob Mensching <rob@robmensching.com>2018-10-03 14:41:49 -0700
commitbe612cbcea4e74196445940c41b42acb6ffa5ebd (patch)
tree7d7232f5cabe537d5fcfee0782f646c6d2221b57 /src/WixToolset.Core
parenta0d67c99eb5be2ce6e83f9a8a46d52b61d9871dc (diff)
downloadwix-be612cbcea4e74196445940c41b42acb6ffa5ebd.tar.gz
wix-be612cbcea4e74196445940c41b42acb6ffa5ebd.tar.bz2
wix-be612cbcea4e74196445940c41b42acb6ffa5ebd.zip
Implement -arch switch
Fixes wixtoolset/issues#5863
Diffstat (limited to 'src/WixToolset.Core')
-rw-r--r--src/WixToolset.Core/CommandLine/BuildCommand.cs9
-rw-r--r--src/WixToolset.Core/CommandLine/CommandLineParser.cs23
-rw-r--r--src/WixToolset.Core/CommandLine/CompileCommand.cs7
3 files changed, 29 insertions, 10 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs
index 16c98c83..76502bb0 100644
--- a/src/WixToolset.Core/CommandLine/BuildCommand.cs
+++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs
@@ -13,7 +13,7 @@ namespace WixToolset.Core.CommandLine
13 13
14 internal class BuildCommand : ICommandLineCommand 14 internal class BuildCommand : ICommandLineCommand
15 { 15 {
16 public BuildCommand(IServiceProvider serviceProvider, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables, IEnumerable<string> locFiles, IEnumerable<string> libraryFiles, IEnumerable<string> filterCultures, string outputPath, OutputType outputType, string cabCachePath, bool bindFiles, IEnumerable<BindPath> bindPaths, IEnumerable<string> includeSearchPaths, 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, IEnumerable<string> filterCultures, string outputPath, OutputType outputType, Platform platform, string cabCachePath, bool bindFiles, IEnumerable<BindPath> bindPaths, IEnumerable<string> includeSearchPaths, string intermediateFolder, string contentsFile, string outputsFile, string builtOutputsFile)
17 { 17 {
18 this.ServiceProvider = serviceProvider; 18 this.ServiceProvider = serviceProvider;
19 this.Messaging = serviceProvider.GetService<IMessaging>(); 19 this.Messaging = serviceProvider.GetService<IMessaging>();
@@ -25,6 +25,7 @@ namespace WixToolset.Core.CommandLine
25 this.SourceFiles = sources; 25 this.SourceFiles = sources;
26 this.OutputPath = outputPath; 26 this.OutputPath = outputPath;
27 this.OutputType = outputType; 27 this.OutputType = outputType;
28 this.Platform = platform;
28 29
29 this.CabCachePath = cabCachePath; 30 this.CabCachePath = cabCachePath;
30 this.BindFiles = bindFiles; 31 this.BindFiles = bindFiles;
@@ -59,6 +60,8 @@ namespace WixToolset.Core.CommandLine
59 60
60 private OutputType OutputType { get; } 61 private OutputType OutputType { get; }
61 62
63 private Platform Platform { get; }
64
62 public string CabCachePath { get; } 65 public string CabCachePath { get; }
63 66
64 public bool BindFiles { get; } 67 public bool BindFiles { get; }
@@ -171,7 +174,7 @@ namespace WixToolset.Core.CommandLine
171 { 174 {
172 var preprocessor = new Preprocessor(this.ServiceProvider); 175 var preprocessor = new Preprocessor(this.ServiceProvider);
173 preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; 176 preprocessor.IncludeSearchPaths = this.IncludeSearchPaths;
174 preprocessor.Platform = Platform.X86; // TODO: set this correctly 177 preprocessor.Platform = this.Platform;
175 preprocessor.SourcePath = sourceFile.SourcePath; 178 preprocessor.SourcePath = sourceFile.SourcePath;
176 preprocessor.Variables = this.PreprocessorVariables; 179 preprocessor.Variables = this.PreprocessorVariables;
177 180
@@ -192,7 +195,7 @@ namespace WixToolset.Core.CommandLine
192 195
193 var compiler = new Compiler(this.ServiceProvider); 196 var compiler = new Compiler(this.ServiceProvider);
194 compiler.OutputPath = sourceFile.OutputPath; 197 compiler.OutputPath = sourceFile.OutputPath;
195 compiler.Platform = Platform.X86; // TODO: set this correctly 198 compiler.Platform = this.Platform;
196 compiler.SourceDocument = document; 199 compiler.SourceDocument = document;
197 var intermediate = compiler.Execute(); 200 var intermediate = compiler.Execute();
198 201
diff --git a/src/WixToolset.Core/CommandLine/CommandLineParser.cs b/src/WixToolset.Core/CommandLine/CommandLineParser.cs
index b0ad6cad..d0484e45 100644
--- a/src/WixToolset.Core/CommandLine/CommandLineParser.cs
+++ b/src/WixToolset.Core/CommandLine/CommandLineParser.cs
@@ -59,6 +59,7 @@ namespace WixToolset.Core.CommandLine
59 var outputFolder = String.Empty; 59 var outputFolder = String.Empty;
60 var outputFile = String.Empty; 60 var outputFile = String.Empty;
61 var outputType = String.Empty; 61 var outputType = String.Empty;
62 var platformType = String.Empty;
62 var verbose = false; 63 var verbose = false;
63 var files = new List<string>(); 64 var files = new List<string>();
64 var defines = new List<string>(); 65 var defines = new List<string>();
@@ -91,6 +92,11 @@ namespace WixToolset.Core.CommandLine
91 cmdline.ShowHelp = true; 92 cmdline.ShowHelp = true;
92 return true; 93 return true;
93 94
95 case "arch":
96 case "platform":
97 platformType = parser.GetNextArgumentOrError(arg);
98 return true;
99
94 case "bindfiles": 100 case "bindfiles":
95 bindFiles = true; 101 bindFiles = true;
96 return true; 102 return true;
@@ -211,14 +217,16 @@ namespace WixToolset.Core.CommandLine
211 var bindPathList = this.GatherBindPaths(bindPaths); 217 var bindPathList = this.GatherBindPaths(bindPaths);
212 var filterCultures = CalculateFilterCultures(cultures); 218 var filterCultures = CalculateFilterCultures(cultures);
213 var type = CalculateOutputType(outputType, outputFile); 219 var type = CalculateOutputType(outputType, outputFile);
214 return new BuildCommand(this.ServiceProvider, sourceFiles, variables, locFiles, libraryFiles, filterCultures, outputFile, type, cabCachePath, bindFiles, bindPathList, includePaths, intermediateFolder, contentsFile, outputsFile, builtOutputsFile); 220 var platform = CalculatePlatform(platformType);
221 return new BuildCommand(this.ServiceProvider, sourceFiles, variables, locFiles, libraryFiles, filterCultures, outputFile, type, platform, cabCachePath, bindFiles, bindPathList, includePaths, intermediateFolder, contentsFile, outputsFile, builtOutputsFile);
215 } 222 }
216 223
217 case Commands.Compile: 224 case Commands.Compile:
218 { 225 {
219 var sourceFiles = GatherSourceFiles(files, outputFolder); 226 var sourceFiles = GatherSourceFiles(files, outputFolder);
220 var variables = GatherPreprocessorVariables(defines); 227 var variables = this.GatherPreprocessorVariables(defines);
221 return new CompileCommand(this.ServiceProvider, sourceFiles, variables); 228 var platform = CalculatePlatform(platformType);
229 return new CompileCommand(this.ServiceProvider, sourceFiles, variables, platform);
222 } 230 }
223 } 231 }
224 232
@@ -297,6 +305,11 @@ namespace WixToolset.Core.CommandLine
297 return OutputType.Unknown; 305 return OutputType.Unknown;
298 } 306 }
299 307
308 private static Platform CalculatePlatform(string platformType)
309 {
310 return Enum.TryParse(platformType, true, out Platform platform) ? platform : Platform.X86;
311 }
312
300 private ICommandLineParser Parse(ICommandLineContext context, Func<CommandLineParser, string, bool> parseCommand, Func<CommandLineParser, IParseCommandLine, string, bool> parseArgument) 313 private ICommandLineParser Parse(ICommandLineContext context, Func<CommandLineParser, string, bool> parseCommand, Func<CommandLineParser, IParseCommandLine, string, bool> parseArgument)
301 { 314 {
302 var extensions = this.ExtensionManager.Create<IExtensionCommandLine>(); 315 var extensions = this.ExtensionManager.Create<IExtensionCommandLine>();
@@ -372,7 +385,7 @@ namespace WixToolset.Core.CommandLine
372 385
373 foreach (var pair in defineConstants) 386 foreach (var pair in defineConstants)
374 { 387 {
375 string[] value = pair.Split(new[] { '=' }, 2); 388 var value = pair.Split(new[] { '=' }, 2);
376 389
377 if (variables.ContainsKey(value[0])) 390 if (variables.ContainsKey(value[0]))
378 { 391 {
@@ -422,7 +435,7 @@ namespace WixToolset.Core.CommandLine
422 435
423 public static BindPath ParseBindPath(string bindPath) 436 public static BindPath ParseBindPath(string bindPath)
424 { 437 {
425 string[] namedPath = bindPath.Split(BindPathSplit, 2); 438 var namedPath = bindPath.Split(BindPathSplit, 2);
426 return (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]); 439 return (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]);
427 } 440 }
428 } 441 }
diff --git a/src/WixToolset.Core/CommandLine/CompileCommand.cs b/src/WixToolset.Core/CommandLine/CompileCommand.cs
index ec1ce602..621571b1 100644
--- a/src/WixToolset.Core/CommandLine/CompileCommand.cs
+++ b/src/WixToolset.Core/CommandLine/CompileCommand.cs
@@ -11,12 +11,13 @@ namespace WixToolset.Core.CommandLine
11 11
12 internal class CompileCommand : ICommandLineCommand 12 internal class CompileCommand : ICommandLineCommand
13 { 13 {
14 public CompileCommand(IServiceProvider serviceProvider, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables) 14 public CompileCommand(IServiceProvider serviceProvider, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables, Platform platform)
15 { 15 {
16 this.ServiceProvider = serviceProvider; 16 this.ServiceProvider = serviceProvider;
17 this.Messaging = serviceProvider.GetService<IMessaging>(); 17 this.Messaging = serviceProvider.GetService<IMessaging>();
18 this.SourceFiles = sources; 18 this.SourceFiles = sources;
19 this.PreprocessorVariables = preprocessorVariables; 19 this.PreprocessorVariables = preprocessorVariables;
20 this.Platform = platform;
20 } 21 }
21 22
22 private IServiceProvider ServiceProvider { get; } 23 private IServiceProvider ServiceProvider { get; }
@@ -27,6 +28,8 @@ namespace WixToolset.Core.CommandLine
27 28
28 private IDictionary<string, string> PreprocessorVariables { get; } 29 private IDictionary<string, string> PreprocessorVariables { get; }
29 30
31 private Platform Platform { get; }
32
30 public IEnumerable<string> IncludeSearchPaths { get; } 33 public IEnumerable<string> IncludeSearchPaths { get; }
31 34
32 public int Execute() 35 public int Execute()
@@ -56,7 +59,7 @@ namespace WixToolset.Core.CommandLine
56 59
57 var compiler = new Compiler(this.ServiceProvider); 60 var compiler = new Compiler(this.ServiceProvider);
58 compiler.OutputPath = sourceFile.OutputPath; 61 compiler.OutputPath = sourceFile.OutputPath;
59 compiler.Platform = Platform.X86; // TODO: set this correctly 62 compiler.Platform = this.Platform;
60 compiler.SourceDocument = document; 63 compiler.SourceDocument = document;
61 var intermediate = compiler.Execute(); 64 var intermediate = compiler.Execute();
62 65