diff options
author | Rob Mensching <rob@firegiant.com> | 2017-12-31 00:43:02 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2017-12-31 00:43:02 -0800 |
commit | 84d1f05fee656c01938613bcc50bd8139006bbf6 (patch) | |
tree | 09397d0a8c952fbefe4298a1547087136e1828be /src | |
parent | c5190ae74ab8fe13609362efce88fa4b8cc24f34 (diff) | |
download | wix-84d1f05fee656c01938613bcc50bd8139006bbf6.tar.gz wix-84d1f05fee656c01938613bcc50bd8139006bbf6.tar.bz2 wix-84d1f05fee656c01938613bcc50bd8139006bbf6.zip |
Support preprocessing .wxl files
Diffstat (limited to '')
-rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 57 | ||||
-rw-r--r-- | src/WixToolset.Core/Localizer.cs | 17 |
2 files changed, 50 insertions, 24 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index e11cd15a..48f1b214 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
@@ -75,37 +75,48 @@ namespace WixToolset.Core.CommandLine | |||
75 | 75 | ||
76 | public int Execute() | 76 | public int Execute() |
77 | { | 77 | { |
78 | var intermediates = this.CompilePhase(); | 78 | var wixobjs = this.CompilePhase(); |
79 | 79 | ||
80 | if (this.Messaging.EncounteredError) | 80 | if (this.Messaging.EncounteredError) |
81 | { | 81 | { |
82 | return this.Messaging.LastErrorNumber; | 82 | return this.Messaging.LastErrorNumber; |
83 | } | 83 | } |
84 | 84 | ||
85 | if (!intermediates.Any()) | 85 | if (!wixobjs.Any()) |
86 | { | 86 | { |
87 | return 1; | 87 | return 1; |
88 | } | 88 | } |
89 | 89 | ||
90 | if (this.OutputType == OutputType.Library) | 90 | var wxls = this.LoadLocalizationFiles(); |
91 | { | ||
92 | var library = this.LibraryPhase(intermediates); | ||
93 | 91 | ||
94 | library?.Save(this.OutputPath); | 92 | if (this.Messaging.EncounteredError) |
93 | { | ||
94 | return this.Messaging.LastErrorNumber; | ||
95 | } | 95 | } |
96 | else if (this.OutputType == OutputType.IntermediatePostLink) | 96 | |
97 | if (this.OutputType == OutputType.Library) | ||
97 | { | 98 | { |
98 | var output = this.LinkPhase(intermediates); | 99 | var wixlib = this.LibraryPhase(wixobjs, wxls); |
99 | 100 | ||
100 | output?.Save(this.OutputPath); | 101 | if (!this.Messaging.EncounteredError) |
102 | { | ||
103 | wixlib.Save(this.OutputPath); | ||
104 | } | ||
101 | } | 105 | } |
102 | else | 106 | else |
103 | { | 107 | { |
104 | var output = this.LinkPhase(intermediates); | 108 | var wixipl = this.LinkPhase(wixobjs); |
105 | 109 | ||
106 | if (!this.Messaging.EncounteredError) | 110 | if (!this.Messaging.EncounteredError) |
107 | { | 111 | { |
108 | this.BindPhase(output); | 112 | if (this.OutputType == OutputType.IntermediatePostLink) |
113 | { | ||
114 | wixipl.Save(this.OutputPath); | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | this.BindPhase(wixipl, wxls); | ||
119 | } | ||
109 | } | 120 | } |
110 | } | 121 | } |
111 | 122 | ||
@@ -147,10 +158,8 @@ namespace WixToolset.Core.CommandLine | |||
147 | return intermediates; | 158 | return intermediates; |
148 | } | 159 | } |
149 | 160 | ||
150 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates) | 161 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations) |
151 | { | 162 | { |
152 | var localizations = this.LoadLocalizationFiles().ToList(); | ||
153 | |||
154 | // If there was an error loading localization files, then bail. | 163 | // If there was an error loading localization files, then bail. |
155 | if (this.Messaging.EncounteredError) | 164 | if (this.Messaging.EncounteredError) |
156 | { | 165 | { |
@@ -184,12 +193,8 @@ namespace WixToolset.Core.CommandLine | |||
184 | return linker.Execute(); | 193 | return linker.Execute(); |
185 | } | 194 | } |
186 | 195 | ||
187 | private void BindPhase(Intermediate output) | 196 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations) |
188 | { | 197 | { |
189 | var localizations = new List<Localization>(output.Localizations); | ||
190 | |||
191 | localizations.AddRange(this.LoadLocalizationFiles()); | ||
192 | |||
193 | // If there was an error loading localization files, then bail. | 198 | // If there was an error loading localization files, then bail. |
194 | if (this.Messaging.EncounteredError) | 199 | if (this.Messaging.EncounteredError) |
195 | { | 200 | { |
@@ -288,7 +293,19 @@ namespace WixToolset.Core.CommandLine | |||
288 | { | 293 | { |
289 | foreach (var loc in this.LocFiles) | 294 | foreach (var loc in this.LocFiles) |
290 | { | 295 | { |
291 | var localization = Localizer.ParseLocalizationFile(this.Messaging, loc); | 296 | var preprocessor = new Preprocessor(this.ServiceProvider); |
297 | preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; | ||
298 | preprocessor.Platform = Platform.X86; // TODO: set this correctly | ||
299 | preprocessor.SourcePath = loc; | ||
300 | preprocessor.Variables = this.PreprocessorVariables; | ||
301 | var document = preprocessor.Execute(); | ||
302 | |||
303 | if (this.Messaging.EncounteredError) | ||
304 | { | ||
305 | continue; | ||
306 | } | ||
307 | |||
308 | var localization = Localizer.ParseLocalizationFile(this.Messaging, document); | ||
292 | 309 | ||
293 | yield return localization; | 310 | yield return localization; |
294 | } | 311 | } |
diff --git a/src/WixToolset.Core/Localizer.cs b/src/WixToolset.Core/Localizer.cs index 38d8864e..cb9a4406 100644 --- a/src/WixToolset.Core/Localizer.cs +++ b/src/WixToolset.Core/Localizer.cs | |||
@@ -22,13 +22,22 @@ namespace WixToolset.Core | |||
22 | /// <summary> | 22 | /// <summary> |
23 | /// Loads a localization file from a path on disk. | 23 | /// Loads a localization file from a path on disk. |
24 | /// </summary> | 24 | /// </summary> |
25 | /// <param name="path">Path to library file saved on disk.</param> | 25 | /// <param name="path">Path to localization file saved on disk.</param> |
26 | /// <param name="tableDefinitions">Collection containing TableDefinitions to use when loading the localization file.</param> | ||
27 | /// <param name="suppressSchema">Suppress xml schema validation while loading.</param> | ||
28 | /// <returns>Returns the loaded localization file.</returns> | 26 | /// <returns>Returns the loaded localization file.</returns> |
29 | public static Localization ParseLocalizationFile(IMessaging messaging, string path) | 27 | public static Localization ParseLocalizationFile(IMessaging messaging, string path) |
30 | { | 28 | { |
31 | XElement root = XDocument.Load(path).Root; | 29 | var document = XDocument.Load(path); |
30 | return ParseLocalizationFile(messaging, document); | ||
31 | } | ||
32 | |||
33 | /// <summary> | ||
34 | /// Loads a localization file from memory. | ||
35 | /// </summary> | ||
36 | /// <param name="document">Document to parse as localization file.</param> | ||
37 | /// <returns>Returns the loaded localization file.</returns> | ||
38 | public static Localization ParseLocalizationFile(IMessaging messaging, XDocument document) | ||
39 | { | ||
40 | XElement root = document.Root; | ||
32 | Localization localization = null; | 41 | Localization localization = null; |
33 | 42 | ||
34 | SourceLineNumber sourceLineNumbers = SourceLineNumber.CreateFromXObject(root); | 43 | SourceLineNumber sourceLineNumbers = SourceLineNumber.CreateFromXObject(root); |