diff options
Diffstat (limited to 'src/wixext/DifxAppCompiler.cs')
-rw-r--r-- | src/wixext/DifxAppCompiler.cs | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/src/wixext/DifxAppCompiler.cs b/src/wixext/DifxAppCompiler.cs index 63396932..98f36b3f 100644 --- a/src/wixext/DifxAppCompiler.cs +++ b/src/wixext/DifxAppCompiler.cs | |||
@@ -1,26 +1,27 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolset.Extensions | 3 | namespace WixToolset.DifxApp |
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using System.Xml.Linq; | 7 | using System.Xml.Linq; |
8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
9 | using WixToolset.DifxApp.Tuples; | ||
9 | using WixToolset.Extensibility; | 10 | using WixToolset.Extensibility; |
10 | 11 | ||
11 | /// <summary> | 12 | /// <summary> |
12 | /// The compiler for the WiX Toolset Driver Install Frameworks for Applications Extension. | 13 | /// The compiler for the WiX Toolset Driver Install Frameworks for Applications Extension. |
13 | /// </summary> | 14 | /// </summary> |
14 | public sealed class DifxAppCompiler : CompilerExtension | 15 | public sealed class DifxAppCompiler : BaseCompilerExtension |
15 | { | 16 | { |
16 | private HashSet<string> components; | 17 | private HashSet<string> components; |
17 | 18 | ||
19 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/difxapp"; | ||
18 | /// <summary> | 20 | /// <summary> |
19 | /// Instantiate a new DifxAppCompiler. | 21 | /// Instantiate a new DifxAppCompiler. |
20 | /// </summary> | 22 | /// </summary> |
21 | public DifxAppCompiler() | 23 | public DifxAppCompiler() |
22 | { | 24 | { |
23 | this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/difxapp"; | ||
24 | this.components = new HashSet<string>(); | 25 | this.components = new HashSet<string>(); |
25 | } | 26 | } |
26 | 27 | ||
@@ -31,26 +32,27 @@ namespace WixToolset.Extensions | |||
31 | /// <param name="parentElement">Parent element of element to process.</param> | 32 | /// <param name="parentElement">Parent element of element to process.</param> |
32 | /// <param name="element">Element to process.</param> | 33 | /// <param name="element">Element to process.</param> |
33 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> | 34 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> |
34 | public override void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context) | 35 | public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) |
35 | { | 36 | { |
36 | switch (parentElement.Name.LocalName) | 37 | switch (parentElement.Name.LocalName) |
37 | { | 38 | { |
38 | case "Component": | 39 | case "Component": |
39 | string componentId = context["ComponentId"]; | 40 | string componentId = context["ComponentId"]; |
40 | string directoryId = context["DirectoryId"]; | 41 | string directoryId = context["DirectoryId"]; |
42 | bool componentWin64 = Boolean.Parse(context["Win64"]); | ||
41 | 43 | ||
42 | switch (element.Name.LocalName) | 44 | switch (element.Name.LocalName) |
43 | { | 45 | { |
44 | case "Driver": | 46 | case "Driver": |
45 | this.ParseDriverElement(element, componentId); | 47 | this.ParseDriverElement(intermediate, section, element, componentId, componentWin64); |
46 | break; | 48 | break; |
47 | default: | 49 | default: |
48 | this.Core.UnexpectedElement(parentElement, element); | 50 | this.ParseHelper.UnexpectedElement(parentElement, element); |
49 | break; | 51 | break; |
50 | } | 52 | } |
51 | break; | 53 | break; |
52 | default: | 54 | default: |
53 | this.Core.UnexpectedElement(parentElement, element); | 55 | this.ParseHelper.UnexpectedElement(parentElement, element); |
54 | break; | 56 | break; |
55 | } | 57 | } |
56 | } | 58 | } |
@@ -60,9 +62,9 @@ namespace WixToolset.Extensions | |||
60 | /// </summary> | 62 | /// </summary> |
61 | /// <param name="node">Element to parse.</param> | 63 | /// <param name="node">Element to parse.</param> |
62 | /// <param name="componentId">Identifier for parent component.</param> | 64 | /// <param name="componentId">Identifier for parent component.</param> |
63 | private void ParseDriverElement(XElement node, string componentId) | 65 | private void ParseDriverElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, bool win64) |
64 | { | 66 | { |
65 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 67 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
66 | int attributes = 0; | 68 | int attributes = 0; |
67 | int sequence = CompilerConstants.IntegerNotSet; | 69 | int sequence = CompilerConstants.IntegerNotSet; |
68 | 70 | ||
@@ -71,7 +73,7 @@ namespace WixToolset.Extensions | |||
71 | { | 73 | { |
72 | if (this.components.Contains(componentId)) | 74 | if (this.components.Contains(componentId)) |
73 | { | 75 | { |
74 | this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); | 76 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); |
75 | } | 77 | } |
76 | else | 78 | else |
77 | { | 79 | { |
@@ -86,62 +88,74 @@ namespace WixToolset.Extensions | |||
86 | switch (attrib.Name.LocalName) | 88 | switch (attrib.Name.LocalName) |
87 | { | 89 | { |
88 | case "AddRemovePrograms": | 90 | case "AddRemovePrograms": |
89 | if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 91 | if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
90 | { | 92 | { |
91 | attributes |= 0x4; | 93 | attributes |= 0x4; |
92 | } | 94 | } |
93 | break; | 95 | break; |
94 | case "DeleteFiles": | 96 | case "DeleteFiles": |
95 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 97 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
96 | { | 98 | { |
97 | attributes |= 0x10; | 99 | attributes |= 0x10; |
98 | } | 100 | } |
99 | break; | 101 | break; |
100 | case "ForceInstall": | 102 | case "ForceInstall": |
101 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 103 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
102 | { | 104 | { |
103 | attributes |= 0x1; | 105 | attributes |= 0x1; |
104 | } | 106 | } |
105 | break; | 107 | break; |
106 | case "Legacy": | 108 | case "Legacy": |
107 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 109 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
108 | { | 110 | { |
109 | attributes |= 0x8; | 111 | attributes |= 0x8; |
110 | } | 112 | } |
111 | break; | 113 | break; |
112 | case "PlugAndPlayPrompt": | 114 | case "PlugAndPlayPrompt": |
113 | if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 115 | if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
114 | { | 116 | { |
115 | attributes |= 0x2; | 117 | attributes |= 0x2; |
116 | } | 118 | } |
117 | break; | 119 | break; |
118 | case "Sequence": | 120 | case "Sequence": |
119 | sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); | 121 | sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); |
120 | break; | 122 | break; |
121 | default: | 123 | default: |
122 | this.Core.UnexpectedAttribute(node, attrib); | 124 | this.ParseHelper.UnexpectedAttribute(node, attrib); |
123 | break; | 125 | break; |
124 | } | 126 | } |
125 | } | 127 | } |
126 | else | 128 | else |
127 | { | 129 | { |
128 | this.Core.ParseExtensionAttribute(node, attrib); | 130 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); |
129 | } | 131 | } |
130 | } | 132 | } |
131 | 133 | ||
132 | this.Core.ParseForExtensionElements(node); | 134 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); |
133 | 135 | ||
134 | if (!this.Core.EncounteredError) | 136 | if (!this.Messaging.EncounteredError) |
135 | { | 137 | { |
136 | Row row = this.Core.CreateRow(sourceLineNumbers, "MsiDriverPackages"); | 138 | switch (this.Context.Platform) |
137 | row[0] = componentId; | ||
138 | row[1] = attributes; | ||
139 | if (CompilerConstants.IntegerNotSet != sequence) | ||
140 | { | 139 | { |
141 | row[2] = sequence; | 140 | case Platform.X86: |
141 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MsiProcessDrivers"); | ||
142 | break; | ||
143 | case Platform.X64: | ||
144 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MsiProcessDrivers_x64"); | ||
145 | break; | ||
146 | case Platform.IA64: | ||
147 | case Platform.ARM: | ||
148 | this.Messaging.Write(ErrorMessages.UnsupportedPlatformForElement(sourceLineNumbers, this.Context.Platform.ToString(), node.Name.LocalName)); | ||
149 | break; | ||
142 | } | 150 | } |
143 | 151 | ||
144 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "MsiProcessDrivers"); | 152 | var row = (MsiDriverPackagesTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "MsiDriverPackages"); |
153 | row.Set(0, componentId); | ||
154 | row.Set(1, attributes); | ||
155 | if (CompilerConstants.IntegerNotSet != sequence) | ||
156 | { | ||
157 | row.Set(2, sequence); | ||
158 | } | ||
145 | } | 159 | } |
146 | } | 160 | } |
147 | } | 161 | } |