diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-26 15:11:40 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-26 15:11:40 -0800 |
| commit | 1d6ff8af3c423ee4622185edc986ae5caad6b122 (patch) | |
| tree | 0fd320bb2e249da3a2fbebcd3e0aa49879aa27b0 /src/WixToolset.Core/CommandLine/BuildCommand.cs | |
| parent | ecf3a0cca5a424a91ab98557d963d2535963d582 (diff) | |
| download | wix-1d6ff8af3c423ee4622185edc986ae5caad6b122.tar.gz wix-1d6ff8af3c423ee4622185edc986ae5caad6b122.tar.bz2 wix-1d6ff8af3c423ee4622185edc986ae5caad6b122.zip | |
Standardize creation of public objects in move towards interfaces
Diffstat (limited to 'src/WixToolset.Core/CommandLine/BuildCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 89 |
1 files changed, 40 insertions, 49 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 5653afca..b5ad0b0e 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
| @@ -13,11 +13,11 @@ namespace WixToolset.Core.CommandLine | |||
| 13 | 13 | ||
| 14 | internal class BuildCommand : ICommandLineCommand | 14 | internal class BuildCommand : ICommandLineCommand |
| 15 | { | 15 | { |
| 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) | 16 | public BuildCommand(IServiceProvider serviceProvider, 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) |
| 17 | { | 17 | { |
| 18 | this.ServiceProvider = serviceProvider; | 18 | this.ServiceProvider = serviceProvider; |
| 19 | this.Messaging = messaging; | 19 | this.Messaging = serviceProvider.GetService<IMessaging>(); |
| 20 | this.ExtensionManager = extensions; | 20 | this.ExtensionManager = serviceProvider.GetService<IExtensionManager>(); |
| 21 | this.LocFiles = locFiles; | 21 | this.LocFiles = locFiles; |
| 22 | this.LibraryFiles = libraryFiles; | 22 | this.LibraryFiles = libraryFiles; |
| 23 | this.PreprocessorVariables = preprocessorVariables; | 23 | this.PreprocessorVariables = preprocessorVariables; |
| @@ -76,6 +76,11 @@ namespace WixToolset.Core.CommandLine | |||
| 76 | { | 76 | { |
| 77 | var intermediates = this.CompilePhase(); | 77 | var intermediates = this.CompilePhase(); |
| 78 | 78 | ||
| 79 | if (this.Messaging.EncounteredError) | ||
| 80 | { | ||
| 81 | return this.Messaging.LastErrorNumber; | ||
| 82 | } | ||
| 83 | |||
| 79 | if (!intermediates.Any()) | 84 | if (!intermediates.Any()) |
| 80 | { | 85 | { |
| 81 | return 1; | 86 | return 1; |
| @@ -112,35 +117,30 @@ namespace WixToolset.Core.CommandLine | |||
| 112 | 117 | ||
| 113 | foreach (var sourceFile in this.SourceFiles) | 118 | foreach (var sourceFile in this.SourceFiles) |
| 114 | { | 119 | { |
| 115 | var preprocessContext = this.ServiceProvider.GetService<IPreprocessContext>(); | 120 | var preprocessor = new Preprocessor(this.ServiceProvider); |
| 116 | preprocessContext.Messaging = this.Messaging; | 121 | preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; |
| 117 | preprocessContext.Extensions = this.ExtensionManager.Create<IPreprocessorExtension>(); | 122 | preprocessor.Platform = Platform.X86; // TODO: set this correctly |
| 118 | preprocessContext.Platform = Platform.X86; // TODO: set this correctly | 123 | preprocessor.SourcePath = sourceFile.SourcePath; |
| 119 | preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List<string>(); | 124 | preprocessor.Variables = this.PreprocessorVariables; |
| 120 | preprocessContext.SourceFile = sourceFile.SourcePath; | 125 | var document = preprocessor.Execute(); |
| 121 | preprocessContext.Variables = new Dictionary<string, string>(this.PreprocessorVariables); | 126 | |
| 127 | if (this.Messaging.EncounteredError) | ||
| 128 | { | ||
| 129 | continue; | ||
| 130 | } | ||
| 122 | 131 | ||
| 123 | var preprocessor = new Preprocessor(); | 132 | var compiler = new Compiler(this.ServiceProvider); |
| 124 | var document = preprocessor.Process(preprocessContext); | 133 | compiler.OutputPath = sourceFile.OutputPath; |
| 134 | compiler.Platform = Platform.X86; // TODO: set this correctly | ||
| 135 | compiler.SourceDocument = document; | ||
| 136 | var intermediate = compiler.Execute(); | ||
| 125 | 137 | ||
| 126 | if (!this.Messaging.EncounteredError) | 138 | if (this.Messaging.EncounteredError) |
| 127 | { | 139 | { |
| 128 | var compileContext = this.ServiceProvider.GetService<ICompileContext>(); | 140 | continue; |
| 129 | compileContext.Messaging = this.Messaging; | ||
| 130 | compileContext.CompilationId = Guid.NewGuid().ToString("N"); | ||
| 131 | compileContext.Extensions = this.ExtensionManager.Create<ICompilerExtension>(); | ||
| 132 | compileContext.OutputPath = sourceFile.OutputPath; | ||
| 133 | compileContext.Platform = Platform.X86; // TODO: set this correctly | ||
| 134 | compileContext.Source = document; | ||
| 135 | |||
| 136 | var compiler = new Compiler(); | ||
| 137 | var intermediate = compiler.Compile(compileContext); | ||
| 138 | |||
| 139 | if (!this.Messaging.EncounteredError) | ||
| 140 | { | ||
| 141 | intermediates.Add(intermediate); | ||
| 142 | } | ||
| 143 | } | 141 | } |
| 142 | |||
| 143 | intermediates.Add(intermediate); | ||
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | return intermediates; | 146 | return intermediates; |
| @@ -156,17 +156,12 @@ namespace WixToolset.Core.CommandLine | |||
| 156 | return null; | 156 | return null; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | var context = new LibraryContext(); | 159 | var librarian = new Librarian(this.ServiceProvider); |
| 160 | context.Messaging = this.Messaging; | 160 | librarian.BindFiles = this.BindFiles; |
| 161 | context.BindFiles = this.BindFiles; | 161 | librarian.BindPaths = this.BindPaths; |
| 162 | context.BindPaths = this.BindPaths; | 162 | librarian.Intermediates = intermediates; |
| 163 | context.Extensions = this.ExtensionManager.Create<ILibrarianExtension>(); | 163 | librarian.Localizations = localizations; |
| 164 | context.Localizations = localizations; | 164 | return librarian.Execute(); |
| 165 | context.LibraryId = Guid.NewGuid().ToString("N"); | ||
| 166 | context.Intermediates = intermediates; | ||
| 167 | |||
| 168 | var librarian = new Librarian(); | ||
| 169 | return librarian.Combine(context); | ||
| 170 | } | 165 | } |
| 171 | 166 | ||
| 172 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates) | 167 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates) |
| @@ -180,16 +175,12 @@ namespace WixToolset.Core.CommandLine | |||
| 180 | return null; | 175 | return null; |
| 181 | } | 176 | } |
| 182 | 177 | ||
| 183 | var context = this.ServiceProvider.GetService<ILinkContext>(); | 178 | var linker = new Linker(this.ServiceProvider); |
| 184 | context.Messaging = this.Messaging; | 179 | linker.OutputType = this.OutputType; |
| 185 | context.Extensions = this.ExtensionManager.Create<ILinkerExtension>(); | 180 | linker.Intermediates = intermediates; |
| 186 | context.ExtensionData = this.ExtensionManager.Create<IExtensionData>(); | 181 | linker.Libraries = libraries; |
| 187 | context.ExpectedOutputType = this.OutputType; | 182 | linker.TupleDefinitionCreator = creator; |
| 188 | context.Intermediates = intermediates.Union(libraries).ToList(); | 183 | return linker.Execute(); |
| 189 | context.TupleDefinitionCreator = creator; | ||
| 190 | |||
| 191 | var linker = new Linker(); | ||
| 192 | return linker.Link(context); | ||
| 193 | } | 184 | } |
| 194 | 185 | ||
| 195 | private void BindPhase(Intermediate output) | 186 | private void BindPhase(Intermediate output) |
