diff options
author | Rob Mensching <rob@firegiant.com> | 2019-05-08 23:57:15 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2019-05-09 00:04:17 -0700 |
commit | 32b691d23c76fbe12790808d65b0b615640ebebe (patch) | |
tree | 2f62c185af5dc02355459d5f4719aa0bbf7b0f20 /src/WixToolset.Core | |
parent | 75fd55d5a71c492c6ea904768858c51aa97da29f (diff) | |
download | wix-32b691d23c76fbe12790808d65b0b615640ebebe.tar.gz wix-32b691d23c76fbe12790808d65b0b615640ebebe.tar.bz2 wix-32b691d23c76fbe12790808d65b0b615640ebebe.zip |
Implement and use IParseHelper.ScheduleActionTuple
Diffstat (limited to 'src/WixToolset.Core')
-rw-r--r-- | src/WixToolset.Core/Compiler.cs | 20 | ||||
-rw-r--r-- | src/WixToolset.Core/CompilerCore.cs | 59 | ||||
-rw-r--r-- | src/WixToolset.Core/Compiler_2.cs | 51 | ||||
-rw-r--r-- | src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | 63 |
4 files changed, 72 insertions, 121 deletions
diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index 8eff4aac..48e22f6d 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs | |||
@@ -7284,34 +7284,28 @@ namespace WixToolset.Core | |||
7284 | } | 7284 | } |
7285 | 7285 | ||
7286 | // finally, schedule RemoveExistingProducts | 7286 | // finally, schedule RemoveExistingProducts |
7287 | var actionTuple = new WixActionTuple(sourceLineNumbers, new Identifier(AccessModifier.Public, "InstallExecuteSequence", "RemoveExistingProducts")) | 7287 | string after = null; |
7288 | { | ||
7289 | SequenceTable = SequenceTable.InstallExecuteSequence, | ||
7290 | Action = "RemoveExistingProducts", | ||
7291 | Overridable = false, | ||
7292 | }; | ||
7293 | |||
7294 | switch (schedule) | 7288 | switch (schedule) |
7295 | { | 7289 | { |
7296 | case null: | 7290 | case null: |
7297 | case "afterInstallValidate": | 7291 | case "afterInstallValidate": |
7298 | actionTuple.After = "InstallValidate"; | 7292 | after = "InstallValidate"; |
7299 | break; | 7293 | break; |
7300 | case "afterInstallInitialize": | 7294 | case "afterInstallInitialize": |
7301 | actionTuple.After = "InstallInitialize"; | 7295 | after = "InstallInitialize"; |
7302 | break; | 7296 | break; |
7303 | case "afterInstallExecute": | 7297 | case "afterInstallExecute": |
7304 | actionTuple.After = "InstallExecute"; | 7298 | after = "InstallExecute"; |
7305 | break; | 7299 | break; |
7306 | case "afterInstallExecuteAgain": | 7300 | case "afterInstallExecuteAgain": |
7307 | actionTuple.After = "InstallExecuteAgain"; | 7301 | after = "InstallExecuteAgain"; |
7308 | break; | 7302 | break; |
7309 | case "afterInstallFinalize": | 7303 | case "afterInstallFinalize": |
7310 | actionTuple.After = "InstallFinalize"; | 7304 | after = "InstallFinalize"; |
7311 | break; | 7305 | break; |
7312 | } | 7306 | } |
7313 | 7307 | ||
7314 | this.Core.AddTuple(actionTuple); | 7308 | this.Core.ScheduleActionTuple(sourceLineNumbers, AccessModifier.Public, SequenceTable.InstallExecuteSequence, "RemoveExistingProducts", afterAction: after); |
7315 | } | 7309 | } |
7316 | } | 7310 | } |
7317 | 7311 | ||
diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs index d21e490f..ea235a97 100644 --- a/src/WixToolset.Core/CompilerCore.cs +++ b/src/WixToolset.Core/CompilerCore.cs | |||
@@ -402,7 +402,7 @@ namespace WixToolset.Core | |||
402 | /// <returns>Identifier of the leaf directory created.</returns> | 402 | /// <returns>Identifier of the leaf directory created.</returns> |
403 | public string CreateDirectoryReferenceFromInlineSyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId) | 403 | public string CreateDirectoryReferenceFromInlineSyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId) |
404 | { | 404 | { |
405 | return this.parseHelper.CreateDirectoryReferenceFromInlineSyntax(this.ActiveSection, sourceLineNumbers, attribute, parentId); | 405 | return this.parseHelper.CreateDirectoryReferenceFromInlineSyntax(this.ActiveSection, sourceLineNumbers, parentId, attribute, this.activeSectionInlinedDirectoryIds); |
406 | } | 406 | } |
407 | 407 | ||
408 | /// <summary> | 408 | /// <summary> |
@@ -1147,57 +1147,7 @@ namespace WixToolset.Core | |||
1147 | /// <returns>Identifier for the newly created row.</returns> | 1147 | /// <returns>Identifier for the newly created row.</returns> |
1148 | internal Identifier CreateDirectoryRow(SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null) | 1148 | internal Identifier CreateDirectoryRow(SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null) |
1149 | { | 1149 | { |
1150 | //string defaultDir = null; | 1150 | return this.parseHelper.CreateDirectoryRow(this.ActiveSection, sourceLineNumbers, id, parentId, name, this.activeSectionInlinedDirectoryIds, shortName, sourceName, shortSourceName); |
1151 | |||
1152 | //if (name.Equals("SourceDir") || this.IsValidShortFilename(name, false)) | ||
1153 | //{ | ||
1154 | // defaultDir = name; | ||
1155 | //} | ||
1156 | //else | ||
1157 | //{ | ||
1158 | // if (String.IsNullOrEmpty(shortName)) | ||
1159 | // { | ||
1160 | // shortName = this.CreateShortName(name, false, false, "Directory", parentId); | ||
1161 | // } | ||
1162 | |||
1163 | // defaultDir = String.Concat(shortName, "|", name); | ||
1164 | //} | ||
1165 | |||
1166 | //if (!String.IsNullOrEmpty(sourceName)) | ||
1167 | //{ | ||
1168 | // if (this.IsValidShortFilename(sourceName, false)) | ||
1169 | // { | ||
1170 | // defaultDir = String.Concat(defaultDir, ":", sourceName); | ||
1171 | // } | ||
1172 | // else | ||
1173 | // { | ||
1174 | // if (String.IsNullOrEmpty(shortSourceName)) | ||
1175 | // { | ||
1176 | // shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId); | ||
1177 | // } | ||
1178 | |||
1179 | // defaultDir = String.Concat(defaultDir, ":", shortSourceName, "|", sourceName); | ||
1180 | // } | ||
1181 | //} | ||
1182 | |||
1183 | //// For anonymous directories, create the identifier. If this identifier already exists in the | ||
1184 | //// active section, bail so we don't add duplicate anonymous directory rows (which are legal | ||
1185 | //// but bloat the intermediate and ultimately make the linker do "busy work"). | ||
1186 | //if (null == id) | ||
1187 | //{ | ||
1188 | // id = this.CreateIdentifier("dir", parentId, name, shortName, sourceName, shortSourceName); | ||
1189 | |||
1190 | // if (!this.activeSectionInlinedDirectoryIds.Add(id.Id)) | ||
1191 | // { | ||
1192 | // return id; | ||
1193 | // } | ||
1194 | //} | ||
1195 | |||
1196 | //var row = this.CreateRow(sourceLineNumbers, TupleDefinitionType.Directory, id); | ||
1197 | //row.Set(1, parentId); | ||
1198 | //row.Set(2, defaultDir); | ||
1199 | //return id; | ||
1200 | return this.parseHelper.CreateDirectoryRow(this.ActiveSection, sourceLineNumbers, id, parentId, name, shortName, sourceName, shortSourceName, this.activeSectionInlinedDirectoryIds); | ||
1201 | } | 1151 | } |
1202 | 1152 | ||
1203 | /// <summary> | 1153 | /// <summary> |
@@ -1212,6 +1162,11 @@ namespace WixToolset.Core | |||
1212 | return this.parseHelper.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attribute, resultUsedToCreateReference); | 1162 | return this.parseHelper.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attribute, resultUsedToCreateReference); |
1213 | } | 1163 | } |
1214 | 1164 | ||
1165 | internal WixActionTuple ScheduleActionTuple(SourceLineNumber sourceLineNumbers, AccessModifier access, SequenceTable sequence, string actionName, string condition = null, string beforeAction = null, string afterAction = null, bool overridable = false) | ||
1166 | { | ||
1167 | return this.parseHelper.ScheduleActionTuple(this.ActiveSection, sourceLineNumbers, access, sequence, actionName, condition, beforeAction, afterAction, overridable); | ||
1168 | } | ||
1169 | |||
1215 | /// <summary> | 1170 | /// <summary> |
1216 | /// Finds a compiler extension by namespace URI. | 1171 | /// Finds a compiler extension by namespace URI. |
1217 | /// </summary> | 1172 | /// </summary> |
diff --git a/src/WixToolset.Core/Compiler_2.cs b/src/WixToolset.Core/Compiler_2.cs index f42c9da1..0efaec6e 100644 --- a/src/WixToolset.Core/Compiler_2.cs +++ b/src/WixToolset.Core/Compiler_2.cs | |||
@@ -4126,18 +4126,7 @@ namespace WixToolset.Core | |||
4126 | 4126 | ||
4127 | foreach (var sequence in sequences) | 4127 | foreach (var sequence in sequences) |
4128 | { | 4128 | { |
4129 | var sequenceId = new Identifier(AccessModifier.Public, sequence.ToString(), actionName); | 4129 | this.Core.ScheduleActionTuple(sourceLineNumbers, AccessModifier.Public, sequence, actionName, condition, afterAction: "CostInitialize"); |
4130 | |||
4131 | var sequenceTuple = new WixActionTuple(sourceLineNumbers, sequenceId) | ||
4132 | { | ||
4133 | SequenceTable = sequence, | ||
4134 | Action = actionName, | ||
4135 | Condition = condition, | ||
4136 | After = "CostInialize", | ||
4137 | Overridable = false | ||
4138 | }; | ||
4139 | |||
4140 | this.Core.AddTuple(tuple); | ||
4141 | } | 4130 | } |
4142 | } | 4131 | } |
4143 | } | 4132 | } |
@@ -4287,43 +4276,7 @@ namespace WixToolset.Core | |||
4287 | 4276 | ||
4288 | foreach (var sequence in sequences) | 4277 | foreach (var sequence in sequences) |
4289 | { | 4278 | { |
4290 | var sequenceId = new Identifier(AccessModifier.Public, sequence.ToString(), actionName); | 4279 | this.Core.ScheduleActionTuple(sourceLineNumbers, AccessModifier.Public, sequence, actionName, condition, beforeAction, afterAction); |
4291 | |||
4292 | var sequenceTuple = new WixActionTuple(sourceLineNumbers, sequenceId) | ||
4293 | { | ||
4294 | SequenceTable = sequence, | ||
4295 | Action = actionName, | ||
4296 | Condition = condition, | ||
4297 | Before = beforeAction, | ||
4298 | After = afterAction, | ||
4299 | Overridable = false | ||
4300 | }; | ||
4301 | |||
4302 | this.Core.AddTuple(tuple); | ||
4303 | |||
4304 | if (null != beforeAction) | ||
4305 | { | ||
4306 | if (WindowsInstallerStandard.IsStandardAction(beforeAction)) | ||
4307 | { | ||
4308 | this.Core.CreateSimpleReference(sourceLineNumbers, "WixAction", sequence.ToString(), beforeAction); | ||
4309 | } | ||
4310 | else | ||
4311 | { | ||
4312 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", beforeAction); | ||
4313 | } | ||
4314 | } | ||
4315 | |||
4316 | if (null != afterAction) | ||
4317 | { | ||
4318 | if (WindowsInstallerStandard.IsStandardAction(afterAction)) | ||
4319 | { | ||
4320 | this.Core.CreateSimpleReference(sourceLineNumbers, "WixAction", sequence.ToString(), afterAction); | ||
4321 | } | ||
4322 | else | ||
4323 | { | ||
4324 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", afterAction); | ||
4325 | } | ||
4326 | } | ||
4327 | } | 4280 | } |
4328 | } | 4281 | } |
4329 | } | 4282 | } |
diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index 9d4a7cbd..73a78a1f 100644 --- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | |||
@@ -13,6 +13,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
13 | using System.Xml.Linq; | 13 | using System.Xml.Linq; |
14 | using WixToolset.Data; | 14 | using WixToolset.Data; |
15 | using WixToolset.Data.Tuples; | 15 | using WixToolset.Data.Tuples; |
16 | using WixToolset.Data.WindowsInstaller; | ||
16 | using WixToolset.Extensibility; | 17 | using WixToolset.Extensibility; |
17 | using WixToolset.Extensibility.Data; | 18 | using WixToolset.Extensibility.Data; |
18 | using WixToolset.Extensibility.Services; | 19 | using WixToolset.Extensibility.Services; |
@@ -63,9 +64,9 @@ namespace WixToolset.Core.ExtensibilityServices | |||
63 | this.CreateWixGroupRow(section, sourceLineNumbers, parentType, parentId, childType, childId); | 64 | this.CreateWixGroupRow(section, sourceLineNumbers, parentType, parentId, childType, childId); |
64 | } | 65 | } |
65 | 66 | ||
66 | public Identifier CreateDirectoryRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null, ISet<string> sectionInlinedDirectoryIds = null) | 67 | public Identifier CreateDirectoryRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, ISet<string> sectionInlinedDirectoryIds, string shortName = null, string sourceName = null, string shortSourceName = null) |
67 | { | 68 | { |
68 | string defaultDir = null; | 69 | string defaultDir; |
69 | 70 | ||
70 | if (name.Equals("SourceDir") || this.IsValidShortFilename(name, false)) | 71 | if (name.Equals("SourceDir") || this.IsValidShortFilename(name, false)) |
71 | { | 72 | { |
@@ -111,13 +112,18 @@ namespace WixToolset.Core.ExtensibilityServices | |||
111 | } | 112 | } |
112 | } | 113 | } |
113 | 114 | ||
114 | var row = this.CreateRow(section, sourceLineNumbers, TupleDefinitionType.Directory, id); | 115 | var tuple = new DirectoryTuple(sourceLineNumbers, id) |
115 | row.Set(1, parentId); | 116 | { |
116 | row.Set(2, defaultDir); | 117 | Directory_Parent = parentId, |
118 | DefaultDir = defaultDir, | ||
119 | }; | ||
120 | |||
121 | section.Tuples.Add(tuple); | ||
122 | |||
117 | return id; | 123 | return id; |
118 | } | 124 | } |
119 | 125 | ||
120 | public string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId) | 126 | public string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, string parentId, XAttribute attribute, ISet<string> sectionInlinedDirectoryIds) |
121 | { | 127 | { |
122 | string id = null; | 128 | string id = null; |
123 | string[] inlineSyntax = this.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attribute, true); | 129 | string[] inlineSyntax = this.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attribute, true); |
@@ -152,7 +158,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
152 | 158 | ||
153 | for (int i = pathStartsAt; i < inlineSyntax.Length; ++i) | 159 | for (int i = pathStartsAt; i < inlineSyntax.Length; ++i) |
154 | { | 160 | { |
155 | Identifier inlineId = this.CreateDirectoryRow(section, sourceLineNumbers, null, id, inlineSyntax[i]); | 161 | Identifier inlineId = this.CreateDirectoryRow(section, sourceLineNumbers, null, id, inlineSyntax[i], sectionInlinedDirectoryIds); |
156 | id = inlineId.Id; | 162 | id = inlineId.Id; |
157 | } | 163 | } |
158 | } | 164 | } |
@@ -826,6 +832,49 @@ namespace WixToolset.Core.ExtensibilityServices | |||
826 | } | 832 | } |
827 | } | 833 | } |
828 | 834 | ||
835 | public WixActionTuple ScheduleActionTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, AccessModifier access, SequenceTable sequence, string actionName, string condition, string beforeAction, string afterAction, bool overridable = false) | ||
836 | { | ||
837 | var actionId = new Identifier(access, sequence, actionName); | ||
838 | |||
839 | var actionTuple = new WixActionTuple(sourceLineNumbers, actionId) | ||
840 | { | ||
841 | SequenceTable = sequence, | ||
842 | Action = actionName, | ||
843 | Condition = condition, | ||
844 | Before = beforeAction, | ||
845 | After = afterAction, | ||
846 | Overridable = overridable, | ||
847 | }; | ||
848 | |||
849 | section.Tuples.Add(actionTuple); | ||
850 | |||
851 | if (null != beforeAction) | ||
852 | { | ||
853 | if (WindowsInstallerStandard.IsStandardAction(beforeAction)) | ||
854 | { | ||
855 | this.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence.ToString(), beforeAction); | ||
856 | } | ||
857 | else | ||
858 | { | ||
859 | this.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", beforeAction); | ||
860 | } | ||
861 | } | ||
862 | |||
863 | if (null != afterAction) | ||
864 | { | ||
865 | if (WindowsInstallerStandard.IsStandardAction(afterAction)) | ||
866 | { | ||
867 | this.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence.ToString(), afterAction); | ||
868 | } | ||
869 | else | ||
870 | { | ||
871 | this.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", afterAction); | ||
872 | } | ||
873 | } | ||
874 | |||
875 | return actionTuple; | ||
876 | } | ||
877 | |||
829 | public void UnexpectedAttribute(XElement element, XAttribute attribute) | 878 | public void UnexpectedAttribute(XElement element, XAttribute attribute) |
830 | { | 879 | { |
831 | var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(element); | 880 | var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(element); |