From 79473d778b6cc4c8eec93b92e3b244aed904dac1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 31 Jul 2018 15:29:40 -0700 Subject: Support build of a .wixipl to final output --- src/WixToolset.Core/Binder.cs | 1 - src/WixToolset.Core/CommandLine/BuildCommand.cs | 72 +++++++++++++++++-------- 2 files changed, 49 insertions(+), 24 deletions(-) (limited to 'src/WixToolset.Core') 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 using System.Linq; using System.Reflection; using WixToolset.Data; - using WixToolset.Data.Bind; using WixToolset.Data.Tuples; using WixToolset.Extensibility; 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 public int Execute() { - var wixobjs = this.CompilePhase(); + var creator = this.ServiceProvider.GetService(); + + this.EvaluateSourceFiles(creator, out var codeFiles, out var wixipl); if (this.Messaging.EncounteredError) { return this.Messaging.LastErrorNumber; } - if (!wixobjs.Any()) - { - return 1; - } + var wixobjs = this.CompilePhase(codeFiles); var wxls = this.LoadLocalizationFiles().ToList(); @@ -104,7 +103,10 @@ namespace WixToolset.Core.CommandLine } else { - var wixipl = this.LinkPhase(wixobjs); + if (wixipl == null) + { + wixipl = this.LinkPhase(wixobjs, creator); + } if (!this.Messaging.EncounteredError) { @@ -122,11 +124,49 @@ namespace WixToolset.Core.CommandLine return this.Messaging.LastErrorNumber; } - private IEnumerable CompilePhase() + private void EvaluateSourceFiles(ITupleDefinitionCreator creator, out List codeFiles, out Intermediate wixipl) { - var intermediates = new List(); + codeFiles = new List(); + + wixipl = null; foreach (var sourceFile in this.SourceFiles) + { + var extension = Path.GetExtension(sourceFile.SourcePath); + + if (wixipl != null || ".wxs".Equals(extension, StringComparison.OrdinalIgnoreCase)) + { + codeFiles.Add(sourceFile); + } + else + { + try + { + wixipl = Intermediate.Load(sourceFile.SourcePath, creator); + } + catch (WixException) + { + // We'll assume anything that isn't a valid intermediate is source code to compile. + codeFiles.Add(sourceFile); + } + } + } + + if (wixipl == null && codeFiles.Count == 0) + { + this.Messaging.Write(ErrorMessages.NoSourceFiles()); + } + else if (wixipl != null && codeFiles.Count != 0) + { + this.Messaging.Write(ErrorMessages.WixiplSourceFileIsExclusive()); + } + } + + private IEnumerable CompilePhase(IEnumerable sourceFiles) + { + var intermediates = new List(); + + foreach (var sourceFile in sourceFiles) { var preprocessor = new Preprocessor(this.ServiceProvider); preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; @@ -159,12 +199,6 @@ namespace WixToolset.Core.CommandLine private Intermediate LibraryPhase(IEnumerable intermediates, IEnumerable localizations) { - // If there was an error loading localization files, then bail. - if (this.Messaging.EncounteredError) - { - return null; - } - var librarian = new Librarian(this.ServiceProvider); librarian.BindFiles = this.BindFiles; librarian.BindPaths = this.BindPaths; @@ -173,10 +207,8 @@ namespace WixToolset.Core.CommandLine return librarian.Execute(); } - private Intermediate LinkPhase(IEnumerable intermediates) + private Intermediate LinkPhase(IEnumerable intermediates, ITupleDefinitionCreator creator) { - var creator = this.ServiceProvider.GetService(); - var libraries = this.LoadLibraries(creator); if (this.Messaging.EncounteredError) @@ -194,12 +226,6 @@ namespace WixToolset.Core.CommandLine private void BindPhase(Intermediate output, IEnumerable localizations) { - // If there was an error loading localization files, then bail. - if (this.Messaging.EncounteredError) - { - return; - } - ResolveResult resolveResult; { var resolver = new Resolver(this.ServiceProvider); -- cgit v1.2.3-55-g6feb