From 84d1f05fee656c01938613bcc50bd8139006bbf6 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sun, 31 Dec 2017 00:43:02 -0800 Subject: Support preprocessing .wxl files --- src/WixToolset.Core/CommandLine/BuildCommand.cs | 57 ++++++++++++++++--------- 1 file changed, 37 insertions(+), 20 deletions(-) (limited to 'src/WixToolset.Core/CommandLine/BuildCommand.cs') 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 public int Execute() { - var intermediates = this.CompilePhase(); + var wixobjs = this.CompilePhase(); if (this.Messaging.EncounteredError) { return this.Messaging.LastErrorNumber; } - if (!intermediates.Any()) + if (!wixobjs.Any()) { return 1; } - if (this.OutputType == OutputType.Library) - { - var library = this.LibraryPhase(intermediates); + var wxls = this.LoadLocalizationFiles(); - library?.Save(this.OutputPath); + if (this.Messaging.EncounteredError) + { + return this.Messaging.LastErrorNumber; } - else if (this.OutputType == OutputType.IntermediatePostLink) + + if (this.OutputType == OutputType.Library) { - var output = this.LinkPhase(intermediates); + var wixlib = this.LibraryPhase(wixobjs, wxls); - output?.Save(this.OutputPath); + if (!this.Messaging.EncounteredError) + { + wixlib.Save(this.OutputPath); + } } else { - var output = this.LinkPhase(intermediates); + var wixipl = this.LinkPhase(wixobjs); if (!this.Messaging.EncounteredError) { - this.BindPhase(output); + if (this.OutputType == OutputType.IntermediatePostLink) + { + wixipl.Save(this.OutputPath); + } + else + { + this.BindPhase(wixipl, wxls); + } } } @@ -147,10 +158,8 @@ namespace WixToolset.Core.CommandLine return intermediates; } - private Intermediate LibraryPhase(IEnumerable intermediates) + private Intermediate LibraryPhase(IEnumerable intermediates, IEnumerable localizations) { - var localizations = this.LoadLocalizationFiles().ToList(); - // If there was an error loading localization files, then bail. if (this.Messaging.EncounteredError) { @@ -184,12 +193,8 @@ namespace WixToolset.Core.CommandLine return linker.Execute(); } - private void BindPhase(Intermediate output) + private void BindPhase(Intermediate output, IEnumerable localizations) { - var localizations = new List(output.Localizations); - - localizations.AddRange(this.LoadLocalizationFiles()); - // If there was an error loading localization files, then bail. if (this.Messaging.EncounteredError) { @@ -288,7 +293,19 @@ namespace WixToolset.Core.CommandLine { foreach (var loc in this.LocFiles) { - var localization = Localizer.ParseLocalizationFile(this.Messaging, loc); + var preprocessor = new Preprocessor(this.ServiceProvider); + preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; + preprocessor.Platform = Platform.X86; // TODO: set this correctly + preprocessor.SourcePath = loc; + preprocessor.Variables = this.PreprocessorVariables; + var document = preprocessor.Execute(); + + if (this.Messaging.EncounteredError) + { + continue; + } + + var localization = Localizer.ParseLocalizationFile(this.Messaging, document); yield return localization; } -- cgit v1.2.3-55-g6feb