diff options
author | Rob Mensching <rob@firegiant.com> | 2018-07-31 15:29:40 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2018-07-31 15:29:40 -0700 |
commit | 79473d778b6cc4c8eec93b92e3b244aed904dac1 (patch) | |
tree | 9b0ee8c776c10e59e4578d34ce66e54957d5a436 /src/WixToolset.Core | |
parent | f1cb7b29489d795781895727e2bab4f734b57351 (diff) | |
download | wix-79473d778b6cc4c8eec93b92e3b244aed904dac1.tar.gz wix-79473d778b6cc4c8eec93b92e3b244aed904dac1.tar.bz2 wix-79473d778b6cc4c8eec93b92e3b244aed904dac1.zip |
Support build of a .wixipl to final output
Diffstat (limited to 'src/WixToolset.Core')
-rw-r--r-- | src/WixToolset.Core/Binder.cs | 1 | ||||
-rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 72 |
2 files changed, 49 insertions, 24 deletions
diff --git a/src/WixToolset.Core/Binder.cs b/src/WixToolset.Core/Binder.cs index 23f1ba21..2a40ce71 100644 --- a/src/WixToolset.Core/Binder.cs +++ b/src/WixToolset.Core/Binder.cs | |||
@@ -8,7 +8,6 @@ namespace WixToolset.Core | |||
8 | using System.Linq; | 8 | using System.Linq; |
9 | using System.Reflection; | 9 | using System.Reflection; |
10 | using WixToolset.Data; | 10 | using WixToolset.Data; |
11 | using WixToolset.Data.Bind; | ||
12 | using WixToolset.Data.Tuples; | 11 | using WixToolset.Data.Tuples; |
13 | using WixToolset.Extensibility; | 12 | using WixToolset.Extensibility; |
14 | using WixToolset.Extensibility.Data; | 13 | using WixToolset.Extensibility.Data; |
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index d8327b7a..822c4a9a 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
@@ -74,17 +74,16 @@ namespace WixToolset.Core.CommandLine | |||
74 | 74 | ||
75 | public int Execute() | 75 | public int Execute() |
76 | { | 76 | { |
77 | var wixobjs = this.CompilePhase(); | 77 | var creator = this.ServiceProvider.GetService<ITupleDefinitionCreator>(); |
78 | |||
79 | this.EvaluateSourceFiles(creator, out var codeFiles, out var wixipl); | ||
78 | 80 | ||
79 | if (this.Messaging.EncounteredError) | 81 | if (this.Messaging.EncounteredError) |
80 | { | 82 | { |
81 | return this.Messaging.LastErrorNumber; | 83 | return this.Messaging.LastErrorNumber; |
82 | } | 84 | } |
83 | 85 | ||
84 | if (!wixobjs.Any()) | 86 | var wixobjs = this.CompilePhase(codeFiles); |
85 | { | ||
86 | return 1; | ||
87 | } | ||
88 | 87 | ||
89 | var wxls = this.LoadLocalizationFiles().ToList(); | 88 | var wxls = this.LoadLocalizationFiles().ToList(); |
90 | 89 | ||
@@ -104,7 +103,10 @@ namespace WixToolset.Core.CommandLine | |||
104 | } | 103 | } |
105 | else | 104 | else |
106 | { | 105 | { |
107 | var wixipl = this.LinkPhase(wixobjs); | 106 | if (wixipl == null) |
107 | { | ||
108 | wixipl = this.LinkPhase(wixobjs, creator); | ||
109 | } | ||
108 | 110 | ||
109 | if (!this.Messaging.EncounteredError) | 111 | if (!this.Messaging.EncounteredError) |
110 | { | 112 | { |
@@ -122,12 +124,50 @@ namespace WixToolset.Core.CommandLine | |||
122 | return this.Messaging.LastErrorNumber; | 124 | return this.Messaging.LastErrorNumber; |
123 | } | 125 | } |
124 | 126 | ||
125 | private IEnumerable<Intermediate> CompilePhase() | 127 | private void EvaluateSourceFiles(ITupleDefinitionCreator creator, out List<SourceFile> codeFiles, out Intermediate wixipl) |
126 | { | 128 | { |
127 | var intermediates = new List<Intermediate>(); | 129 | codeFiles = new List<SourceFile>(); |
130 | |||
131 | wixipl = null; | ||
128 | 132 | ||
129 | foreach (var sourceFile in this.SourceFiles) | 133 | foreach (var sourceFile in this.SourceFiles) |
130 | { | 134 | { |
135 | var extension = Path.GetExtension(sourceFile.SourcePath); | ||
136 | |||
137 | if (wixipl != null || ".wxs".Equals(extension, StringComparison.OrdinalIgnoreCase)) | ||
138 | { | ||
139 | codeFiles.Add(sourceFile); | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | try | ||
144 | { | ||
145 | wixipl = Intermediate.Load(sourceFile.SourcePath, creator); | ||
146 | } | ||
147 | catch (WixException) | ||
148 | { | ||
149 | // We'll assume anything that isn't a valid intermediate is source code to compile. | ||
150 | codeFiles.Add(sourceFile); | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | if (wixipl == null && codeFiles.Count == 0) | ||
156 | { | ||
157 | this.Messaging.Write(ErrorMessages.NoSourceFiles()); | ||
158 | } | ||
159 | else if (wixipl != null && codeFiles.Count != 0) | ||
160 | { | ||
161 | this.Messaging.Write(ErrorMessages.WixiplSourceFileIsExclusive()); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | private IEnumerable<Intermediate> CompilePhase(IEnumerable<SourceFile> sourceFiles) | ||
166 | { | ||
167 | var intermediates = new List<Intermediate>(); | ||
168 | |||
169 | foreach (var sourceFile in sourceFiles) | ||
170 | { | ||
131 | var preprocessor = new Preprocessor(this.ServiceProvider); | 171 | var preprocessor = new Preprocessor(this.ServiceProvider); |
132 | preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; | 172 | preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; |
133 | preprocessor.Platform = Platform.X86; // TODO: set this correctly | 173 | preprocessor.Platform = Platform.X86; // TODO: set this correctly |
@@ -159,12 +199,6 @@ namespace WixToolset.Core.CommandLine | |||
159 | 199 | ||
160 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations) | 200 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations) |
161 | { | 201 | { |
162 | // If there was an error loading localization files, then bail. | ||
163 | if (this.Messaging.EncounteredError) | ||
164 | { | ||
165 | return null; | ||
166 | } | ||
167 | |||
168 | var librarian = new Librarian(this.ServiceProvider); | 202 | var librarian = new Librarian(this.ServiceProvider); |
169 | librarian.BindFiles = this.BindFiles; | 203 | librarian.BindFiles = this.BindFiles; |
170 | librarian.BindPaths = this.BindPaths; | 204 | librarian.BindPaths = this.BindPaths; |
@@ -173,10 +207,8 @@ namespace WixToolset.Core.CommandLine | |||
173 | return librarian.Execute(); | 207 | return librarian.Execute(); |
174 | } | 208 | } |
175 | 209 | ||
176 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates) | 210 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates, ITupleDefinitionCreator creator) |
177 | { | 211 | { |
178 | var creator = this.ServiceProvider.GetService<ITupleDefinitionCreator>(); | ||
179 | |||
180 | var libraries = this.LoadLibraries(creator); | 212 | var libraries = this.LoadLibraries(creator); |
181 | 213 | ||
182 | if (this.Messaging.EncounteredError) | 214 | if (this.Messaging.EncounteredError) |
@@ -194,12 +226,6 @@ namespace WixToolset.Core.CommandLine | |||
194 | 226 | ||
195 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations) | 227 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations) |
196 | { | 228 | { |
197 | // If there was an error loading localization files, then bail. | ||
198 | if (this.Messaging.EncounteredError) | ||
199 | { | ||
200 | return; | ||
201 | } | ||
202 | |||
203 | ResolveResult resolveResult; | 229 | ResolveResult resolveResult; |
204 | { | 230 | { |
205 | var resolver = new Resolver(this.ServiceProvider); | 231 | var resolver = new Resolver(this.ServiceProvider); |