aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-12-21 13:42:52 -0800
committerRob Mensching <rob@firegiant.com>2017-12-21 13:42:52 -0800
commitdc9f4c329e6f55ce7595970463e0caf148096f4b (patch)
tree86155ac36c76acda0a4b1673c77f54a9780c6885 /src/WixToolset.Core.WindowsInstaller/Bind
parent155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (diff)
downloadwix-dc9f4c329e6f55ce7595970463e0caf148096f4b.tar.gz
wix-dc9f4c329e6f55ce7595970463e0caf148096f4b.tar.bz2
wix-dc9f4c329e6f55ce7595970463e0caf148096f4b.zip
Support wixout and extract Resolve and Layout from Binder
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs98
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs2
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs3
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs2
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs2
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs105
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs11
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs31
8 files changed, 151 insertions, 103 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
index 410e462a..2f161305 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
@@ -22,31 +22,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind
22 // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs. 22 // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs.
23 internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}"); 23 internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}");
24 24
25 public BindDatabaseCommand(IBindContext context, IEnumerable<IWindowsInstallerBackendExtension> backendExtension, Validator validator) 25 public BindDatabaseCommand(WixToolset.Extensibility.IBindContext context, IEnumerable<IWindowsInstallerBackendExtension> backendExtension, Validator validator)
26 { 26 {
27 this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); 27 this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions();
28 28
29 this.BindPaths = context.BindPaths;
30 this.CabbingThreadCount = context.CabbingThreadCount; 29 this.CabbingThreadCount = context.CabbingThreadCount;
31 this.CabCachePath = context.CabCachePath; 30 this.CabCachePath = context.CabCachePath;
32 this.Codepage = context.Codepage; 31 this.Codepage = context.Codepage;
33 this.DefaultCompressionLevel = context.DefaultCompressionLevel; 32 this.DefaultCompressionLevel = context.DefaultCompressionLevel;
34 this.DelayedFields = context.DelayedFields; 33 this.DelayedFields = context.DelayedFields;
35 this.ExpectedEmbeddedFiles = context.ExpectedEmbeddedFiles; 34 this.ExpectedEmbeddedFiles = context.ExpectedEmbeddedFiles;
36 this.Extensions = context.Extensions; 35 this.FileSystemExtensions = context.FileSystemExtensions;
37 this.Intermediate = context.IntermediateRepresentation; 36 this.Intermediate = context.IntermediateRepresentation;
38 this.Messaging = context.Messaging; 37 this.Messaging = context.Messaging;
39 this.OutputPath = context.OutputPath; 38 this.OutputPath = context.OutputPath;
40 this.PdbFile = context.OutputPdbPath; 39 this.PdbFile = context.OutputPdbPath;
41 this.IntermediateFolder = context.IntermediateFolder; 40 this.IntermediateFolder = context.IntermediateFolder;
42 this.Validator = validator; 41 this.Validator = validator;
43 this.WixVariableResolver = context.WixVariableResolver; 42
44
45 this.BackendExtensions = backendExtension; 43 this.BackendExtensions = backendExtension;
46 } 44 }
47 45
48 private IEnumerable<BindPath> BindPaths { get; }
49
50 private int Codepage { get; } 46 private int Codepage { get; }
51 47
52 private int CabbingThreadCount { get; } 48 private int CabbingThreadCount { get; }
@@ -59,12 +55,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
59 55
60 public IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; } 56 public IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; }
61 57
58 public IEnumerable<IFileSystemExtension> FileSystemExtensions { get; }
59
62 public bool DeltaBinaryPatch { get; set; } 60 public bool DeltaBinaryPatch { get; set; }
63 61
64 private IEnumerable<IWindowsInstallerBackendExtension> BackendExtensions { get; } 62 private IEnumerable<IWindowsInstallerBackendExtension> BackendExtensions { get; }
65 63
66 private IEnumerable<IBinderExtension> Extensions { get; }
67
68 private string PdbFile { get; } 64 private string PdbFile { get; }
69 65
70 private Intermediate Intermediate { get; } 66 private Intermediate Intermediate { get; }
@@ -83,7 +79,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
83 79
84 private Validator Validator { get; } 80 private Validator Validator { get; }
85 81
86 private IBindVariableResolver WixVariableResolver { get; }
87 82
88 public IEnumerable<FileTransfer> FileTransfers { get; private set; } 83 public IEnumerable<FileTransfer> FileTransfers { get; private set; }
89 84
@@ -100,8 +95,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
100 // If there are any fields to resolve later, create the cache to populate during bind. 95 // If there are any fields to resolve later, create the cache to populate during bind.
101 var variableCache = this.DelayedFields.Any() ? new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) : null; 96 var variableCache = this.DelayedFields.Any() ? new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) : null;
102 97
103 this.LocalizeUI(section);
104
105 // Process the summary information table before the other tables. 98 // Process the summary information table before the other tables.
106 bool compressed; 99 bool compressed;
107 bool longNames; 100 bool longNames;
@@ -534,85 +527,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
534 intermediate.Save(Path.ChangeExtension(this.OutputPath, "wir")); 527 intermediate.Save(Path.ChangeExtension(this.OutputPath, "wir"));
535 } 528 }
536 529
537 /// <summary>
538 /// Localize dialogs and controls.
539 /// </summary>
540 /// <param name="tables">The tables to localize.</param>
541 private void LocalizeUI(IntermediateSection section)
542 {
543 foreach (var row in section.Tuples.OfType<DialogTuple>())
544 {
545 string dialog = row.Dialog;
546
547 if (this.WixVariableResolver.TryGetLocalizedControl(dialog, null, out LocalizedControl localizedControl))
548 {
549 if (CompilerConstants.IntegerNotSet != localizedControl.X)
550 {
551 row.HCentering = localizedControl.X;
552 }
553
554 if (CompilerConstants.IntegerNotSet != localizedControl.Y)
555 {
556 row.VCentering = localizedControl.Y;
557 }
558
559 if (CompilerConstants.IntegerNotSet != localizedControl.Width)
560 {
561 row.Width = localizedControl.Width;
562 }
563
564 if (CompilerConstants.IntegerNotSet != localizedControl.Height)
565 {
566 row.Height = localizedControl.Height;
567 }
568
569 row.Attributes = row.Attributes | localizedControl.Attributes;
570
571 if (!String.IsNullOrEmpty(localizedControl.Text))
572 {
573 row.Title = localizedControl.Text;
574 }
575 }
576 }
577
578
579 foreach (var row in section.Tuples.OfType<ControlTuple>())
580 {
581 string dialog = row.Dialog_;
582 string control = row.Control;
583
584 if (this.WixVariableResolver.TryGetLocalizedControl(dialog, control, out LocalizedControl localizedControl))
585 {
586 if (CompilerConstants.IntegerNotSet != localizedControl.X)
587 {
588 row.X = localizedControl.X;
589 }
590
591 if (CompilerConstants.IntegerNotSet != localizedControl.Y)
592 {
593 row.Y = localizedControl.Y;
594 }
595
596 if (CompilerConstants.IntegerNotSet != localizedControl.Width)
597 {
598 row.Width = localizedControl.Width;
599 }
600
601 if (CompilerConstants.IntegerNotSet != localizedControl.Height)
602 {
603 row.Height = localizedControl.Height;
604 }
605
606 row.Attributes = row.Attributes | localizedControl.Attributes;
607
608 if (!String.IsNullOrEmpty(localizedControl.Text))
609 {
610 row.Text = localizedControl.Text;
611 }
612 }
613 }
614 }
615
616#if TODO_FINISH_PATCH 530#if TODO_FINISH_PATCH
617 /// <summary> 531 /// <summary>
618 /// Copy file data between transform substorages and the patch output object 532 /// Copy file data between transform substorages and the patch output object
@@ -984,7 +898,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
984 private void GenerateDatabase(Output output, string databaseFile, bool keepAddedColumns, bool useSubdirectory) 898 private void GenerateDatabase(Output output, string databaseFile, bool keepAddedColumns, bool useSubdirectory)
985 { 899 {
986 var command = new GenerateDatabaseCommand(); 900 var command = new GenerateDatabaseCommand();
987 command.Extensions = this.Extensions; 901 command.Extensions = this.FileSystemExtensions;
988 command.Output = output; 902 command.Output = output;
989 command.OutputPath = databaseFile; 903 command.OutputPath = databaseFile;
990 command.KeepAddedColumns = keepAddedColumns; 904 command.KeepAddedColumns = keepAddedColumns;
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs
index 800ebac0..8cb0e0de 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs
@@ -15,7 +15,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
15 15
16 internal class BindTransformCommand 16 internal class BindTransformCommand
17 { 17 {
18 public IEnumerable<IBinderExtension> Extensions { private get; set; } 18 public IEnumerable<IFileSystemExtension> Extensions { private get; set; }
19 19
20 public TableDefinitionCollection TableDefinitions { private get; set; } 20 public TableDefinitionCollection TableDefinitions { private get; set; }
21 21
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
index 056f92a7..76747728 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
@@ -6,7 +6,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO; 7 using System.IO;
8 using System.Linq; 8 using System.Linq;
9 using WixToolset.Bind;
10 using WixToolset.Core.Native; 9 using WixToolset.Core.Native;
11 using WixToolset.Data; 10 using WixToolset.Data;
12 using WixToolset.Data.Tuples; 11 using WixToolset.Data.Tuples;
@@ -135,7 +134,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
135 if (fileRow.File == componentRow.KeyPath) 134 if (fileRow.File == componentRow.KeyPath)
136 { 135 {
137 // calculate the key file's canonical target path 136 // calculate the key file's canonical target path
138 string directoryPath = Binder.GetDirectoryPath(targetPathsByDirectoryId, componentIdGenSeeds, componentRow.Directory_, true); 137 string directoryPath = PathResolver.GetDirectoryPath(targetPathsByDirectoryId, componentIdGenSeeds, componentRow.Directory_, true);
139 string fileName = Common.GetName(fileRow.LongFileName, false, true).ToLowerInvariant(); 138 string fileName = Common.GetName(fileRow.LongFileName, false, true).ToLowerInvariant();
140 path = Path.Combine(directoryPath, fileName); 139 path = Path.Combine(directoryPath, fileName);
141 140
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs
index 13408312..6ff03941 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CopyTransformDataCommand.cs
@@ -18,7 +18,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
18 { 18 {
19 public bool CopyOutFileRows { private get; set; } 19 public bool CopyOutFileRows { private get; set; }
20 20
21 public IEnumerable<IBinderExtension> Extensions { private get; set; } 21 public IEnumerable<IFileSystemExtension> Extensions { private get; set; }
22 22
23 public IMessaging Messaging { private get; set; } 23 public IMessaging Messaging { private get; set; }
24 24
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs
index ee7cc61b..cc920ac2 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs
@@ -19,7 +19,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
19 { 19 {
20 public int Codepage { private get; set; } 20 public int Codepage { private get; set; }
21 21
22 public IEnumerable<IBinderExtension> Extensions { private get; set; } 22 public IEnumerable<IFileSystemExtension> Extensions { private get; set; }
23 23
24 /// <summary> 24 /// <summary>
25 /// Whether to keep columns added in a transform. 25 /// Whether to keep columns added in a transform.
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs
new file mode 100644
index 00000000..492c9137
--- /dev/null
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs
@@ -0,0 +1,105 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Core.WindowsInstaller.Bind
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using WixToolset.Data;
9
10 internal static class PathResolver
11 {
12 /// <summary>
13 /// Get the source path of a directory.
14 /// </summary>
15 /// <param name="directories">All cached directories.</param>
16 /// <param name="componentIdGenSeeds">Hash table of Component GUID generation seeds indexed by directory id.</param>
17 /// <param name="directory">Directory identifier.</param>
18 /// <param name="canonicalize">Canonicalize the path for standard directories.</param>
19 /// <returns>Source path of a directory.</returns>
20 public static string GetDirectoryPath(Dictionary<string, ResolvedDirectory> directories, Dictionary<string, string> componentIdGenSeeds, string directory, bool canonicalize)
21 {
22 if (!directories.TryGetValue(directory, out var resolvedDirectory))
23 {
24 throw new WixException(ErrorMessages.ExpectedDirectory(directory));
25 }
26
27 if (null == resolvedDirectory.Path)
28 {
29 if (null != componentIdGenSeeds && componentIdGenSeeds.ContainsKey(directory))
30 {
31 resolvedDirectory.Path = (string)componentIdGenSeeds[directory];
32 }
33 else if (canonicalize && WindowsInstallerStandard.IsStandardDirectory(directory))
34 {
35 // when canonicalization is on, standard directories are treated equally
36 resolvedDirectory.Path = directory;
37 }
38 else
39 {
40 string name = resolvedDirectory.Name;
41
42 if (canonicalize)
43 {
44 name = name?.ToLowerInvariant();
45 }
46
47 if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent))
48 {
49 resolvedDirectory.Path = name;
50 }
51 else
52 {
53 string parentPath = GetDirectoryPath(directories, componentIdGenSeeds, resolvedDirectory.DirectoryParent, canonicalize);
54
55 if (null != resolvedDirectory.Name)
56 {
57 resolvedDirectory.Path = Path.Combine(parentPath, name);
58 }
59 else
60 {
61 resolvedDirectory.Path = parentPath;
62 }
63 }
64 }
65 }
66
67 return resolvedDirectory.Path;
68 }
69
70 /// <summary>
71 /// Gets the source path of a file.
72 /// </summary>
73 /// <param name="directories">All cached directories in <see cref="ResolvedDirectory"/>.</param>
74 /// <param name="directoryId">Parent directory identifier.</param>
75 /// <param name="fileName">File name (in long|source format).</param>
76 /// <param name="compressed">Specifies the package is compressed.</param>
77 /// <param name="useLongName">Specifies the package uses long file names.</param>
78 /// <returns>Source path of file relative to package directory.</returns>
79 public static string GetFileSourcePath(Dictionary<string, ResolvedDirectory> directories, string directoryId, string fileName, bool compressed, bool useLongName)
80 {
81 string fileSourcePath = Common.GetName(fileName, true, useLongName);
82
83 if (compressed)
84 {
85 // Use just the file name of the file since all uncompressed files must appear
86 // in the root of the image in a compressed package.
87 }
88 else
89 {
90 // Get the relative path of where we want the file to be layed out as specified
91 // in the Directory table.
92 string directoryPath = PathResolver.GetDirectoryPath(directories, null, directoryId, false);
93 fileSourcePath = Path.Combine(directoryPath, fileSourcePath);
94 }
95
96 // Strip off "SourceDir" if it's still on there.
97 if (fileSourcePath.StartsWith("SourceDir\\", StringComparison.Ordinal))
98 {
99 fileSourcePath = fileSourcePath.Substring(10);
100 }
101
102 return fileSourcePath;
103 }
104 }
105}
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
index e1a26a67..39771508 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
@@ -5,14 +5,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO; 7 using System.IO;
8 using WixToolset.Data; 8 using System.Linq;
9 using WixToolset.Msi;
10 using WixToolset.Core.Native;
11 using WixToolset.Bind;
12 using WixToolset.Core.Bind; 9 using WixToolset.Core.Bind;
10 using WixToolset.Core.Native;
11 using WixToolset.Data;
13 using WixToolset.Data.Bind; 12 using WixToolset.Data.Bind;
14 using WixToolset.Data.Tuples; 13 using WixToolset.Data.Tuples;
15 using System.Linq; 14 using WixToolset.Msi;
16 15
17 /// <summary> 16 /// <summary>
18 /// Defines the file transfers necessary to layout the uncompressed files. 17 /// Defines the file transfers necessary to layout the uncompressed files.
@@ -100,7 +99,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
100 throw new WixException(ErrorMessages.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.File)); 99 throw new WixException(ErrorMessages.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.File));
101 } 100 }
102 101
103 relativeFileLayoutPath = Binder.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], this.Compressed, this.LongNamesInImage); 102 relativeFileLayoutPath = PathResolver.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], this.Compressed, this.LongNamesInImage);
104 } 103 }
105 104
106 // finally put together the base media layout path and the relative file layout path 105 // finally put together the base media layout path and the relative file layout path
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs
new file mode 100644
index 00000000..e06321cf
--- /dev/null
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs
@@ -0,0 +1,31 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Core.WindowsInstaller.Bind
4{
5 /// <summary>
6 /// Structure used for resolved directory information.
7 /// </summary>
8 internal struct ResolvedDirectory
9 {
10 /// <summary>
11 /// Constructor for ResolvedDirectory.
12 /// </summary>
13 /// <param name="directoryParent">Parent directory.</param>
14 /// <param name="name">The directory name.</param>
15 public ResolvedDirectory(string directoryParent, string name)
16 {
17 this.DirectoryParent = directoryParent;
18 this.Name = name;
19 this.Path = null;
20 }
21
22 /// <summary>The directory parent.</summary>
23 public string DirectoryParent { get; set; }
24
25 /// <summary>The name of this directory.</summary>
26 public string Name { get; set; }
27
28 /// <summary>The path of this directory.</summary>
29 public string Path { get; set; }
30 }
31}