aboutsummaryrefslogtreecommitdiff
path: root/src/wixext/UtilCompiler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wixext/UtilCompiler.cs')
-rw-r--r--src/wixext/UtilCompiler.cs198
1 files changed, 101 insertions, 97 deletions
diff --git a/src/wixext/UtilCompiler.cs b/src/wixext/UtilCompiler.cs
index 6b359591..6e3c2531 100644
--- a/src/wixext/UtilCompiler.cs
+++ b/src/wixext/UtilCompiler.cs
@@ -230,6 +230,8 @@ namespace WixToolset.Util
230 break; 230 break;
231 case "ComponentSearch": 231 case "ComponentSearch":
232 case "ComponentSearchRef": 232 case "ComponentSearchRef":
233 case "DetectSHA2Support":
234 case "DetectSHA2SupportRef":
233 case "DirectorySearch": 235 case "DirectorySearch":
234 case "DirectorySearchRef": 236 case "DirectorySearchRef":
235 case "FileSearch": 237 case "FileSearch":
@@ -251,6 +253,12 @@ namespace WixToolset.Util
251 case "ComponentSearchRef": 253 case "ComponentSearchRef":
252 this.ParseComponentSearchRefElement(intermediate, section, element); 254 this.ParseComponentSearchRefElement(intermediate, section, element);
253 break; 255 break;
256 case "DetectSHA2Support":
257 this.ParseDetectSHA2SupportElement(intermediate, section, element);
258 break;
259 case "DetectSHA2SupportRef":
260 this.ParseDetectSHA2SupportRefElement(intermediate, section, element);
261 break;
254 case "DirectorySearch": 262 case "DirectorySearch":
255 this.ParseDirectorySearchElement(intermediate, section, element); 263 this.ParseDirectorySearchElement(intermediate, section, element);
256 break; 264 break;
@@ -422,11 +430,6 @@ namespace WixToolset.Util
422 } 430 }
423 } 431 }
424 432
425 if (null == variable)
426 {
427 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Variable"));
428 }
429
430 if (null == guid) 433 if (null == guid)
431 { 434 {
432 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Guid")); 435 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Guid"));
@@ -439,16 +442,10 @@ namespace WixToolset.Util
439 442
440 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); 443 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
441 444
445 this.ParseHelper.CreateWixSearchTuple(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, null);
446
442 if (!this.Messaging.EncounteredError) 447 if (!this.Messaging.EncounteredError)
443 { 448 {
444 this.CreateWixSearchRow(section, sourceLineNumbers, id, variable, condition);
445 if (after != null)
446 {
447 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixSearch", after);
448 // TODO: We're currently defaulting to "always run after", which we will need to change...
449 this.CreateWixSearchRelationRow(section, sourceLineNumbers, id, after, 2);
450 }
451
452 WixComponentSearchAttributes attributes = WixComponentSearchAttributes.KeyPath; 449 WixComponentSearchAttributes attributes = WixComponentSearchAttributes.KeyPath;
453 switch (result) 450 switch (result)
454 { 451 {
@@ -506,6 +503,89 @@ namespace WixToolset.Util
506 } 503 }
507 504
508 /// <summary> 505 /// <summary>
506 /// Parses a DetectSHA2Support element.
507 /// </summary>
508 /// <param name="element">Element to parse.</param>
509 private void ParseDetectSHA2SupportElement(Intermediate intermediate, IntermediateSection section, XElement element)
510 {
511 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
512 Identifier id = null;
513 string variable = null;
514 string condition = null;
515 string after = null;
516
517 foreach (var attrib in element.Attributes())
518 {
519 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
520 {
521 switch (attrib.Name.LocalName)
522 {
523 case "Id":
524 case "Variable":
525 case "Condition":
526 case "After":
527 this.ParseCommonSearchAttributes(sourceLineNumbers, attrib, ref id, ref variable, ref condition, ref after);
528 break;
529 default:
530 this.ParseHelper.UnexpectedAttribute(element, attrib);
531 break;
532 }
533 }
534 else
535 {
536 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
537 }
538 }
539
540 if (id == null)
541 {
542 id = this.ParseHelper.CreateIdentifier("wds2s", variable, condition, after);
543 }
544
545 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
546
547 this.ParseHelper.CreateWixSearchTuple(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, UtilConstants.UtilBundleExtensionId);
548
549 if (!this.Messaging.EncounteredError)
550 {
551 section.Tuples.Add(new WixDetectSHA2SupportTuple(sourceLineNumbers, id));
552 }
553 }
554
555 /// <summary>
556 /// Parses a DetectSHA2SupportRef element
557 /// </summary>
558 /// <param name="element">Element to parse.</param>
559 private void ParseDetectSHA2SupportRefElement(Intermediate intermediate, IntermediateSection section, XElement element)
560 {
561 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
562 string refId = null;
563
564 foreach (var attrib in element.Attributes())
565 {
566 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
567 {
568 switch (attrib.Name.LocalName)
569 {
570 case "Id":
571 refId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
572 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixDetectSHA2Support", refId);
573 break;
574 default:
575 this.ParseHelper.UnexpectedAttribute(element, attrib);
576 break;
577 }
578 }
579 else
580 {
581 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
582 }
583 }
584
585 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
586 }
587
588 /// <summary>
509 /// Parses an event source element. 589 /// Parses an event source element.
510 /// </summary> 590 /// </summary>
511 /// <param name="element">Element to parse.</param> 591 /// <param name="element">Element to parse.</param>
@@ -868,11 +948,6 @@ namespace WixToolset.Util
868 } 948 }
869 } 949 }
870 950
871 if (null == variable)
872 {
873 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Variable"));
874 }
875
876 if (null == path) 951 if (null == path)
877 { 952 {
878 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Path")); 953 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Path"));
@@ -885,16 +960,10 @@ namespace WixToolset.Util
885 960
886 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); 961 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
887 962
963 this.ParseHelper.CreateWixSearchTuple(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, null);
964
888 if (!this.Messaging.EncounteredError) 965 if (!this.Messaging.EncounteredError)
889 { 966 {
890 this.CreateWixSearchRow(section, sourceLineNumbers, id, variable, condition);
891 if (after != null)
892 {
893 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixSearch", after);
894 // TODO: We're currently defaulting to "always run after", which we will need to change...
895 this.CreateWixSearchRelationRow(section, sourceLineNumbers, id, after, 2);
896 }
897
898 WixFileSearchAttributes attributes = WixFileSearchAttributes.IsDirectory; 967 WixFileSearchAttributes attributes = WixFileSearchAttributes.IsDirectory;
899 switch (result) 968 switch (result)
900 { 969 {
@@ -990,11 +1059,6 @@ namespace WixToolset.Util
990 } 1059 }
991 } 1060 }
992 1061
993 if (null == variable)
994 {
995 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Variable"));
996 }
997
998 if (null == path) 1062 if (null == path)
999 { 1063 {
1000 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Path")); 1064 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Path"));
@@ -1007,16 +1071,10 @@ namespace WixToolset.Util
1007 1071
1008 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); 1072 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);
1009 1073
1074 this.ParseHelper.CreateWixSearchTuple(section, sourceLineNumbers, node.Name.LocalName, id, variable, condition, after, null);
1075
1010 if (!this.Messaging.EncounteredError) 1076 if (!this.Messaging.EncounteredError)
1011 { 1077 {
1012 this.CreateWixSearchRow(section, sourceLineNumbers, id, variable, condition);
1013 if (after != null)
1014 {
1015 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixSearch", after);
1016 // TODO: We're currently defaulting to "always run after", which we will need to change...
1017 this.CreateWixSearchRelationRow(section, sourceLineNumbers, id, after, 2);
1018 }
1019
1020 WixFileSearchAttributes attributes = WixFileSearchAttributes.Default; 1078 WixFileSearchAttributes attributes = WixFileSearchAttributes.Default;
1021 switch (result) 1079 switch (result)
1022 { 1080 {
@@ -1049,38 +1107,6 @@ namespace WixToolset.Util
1049 } 1107 }
1050 1108
1051 /// <summary> 1109 /// <summary>
1052 /// Creates a row in the WixSearch table.
1053 /// </summary>
1054 /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
1055 /// <param name="id">Identifier of the search.</param>
1056 /// <param name="variable">The Burn variable to store the result into.</param>
1057 /// <param name="condition">A condition to test before evaluating the search.</param>
1058 private void CreateWixSearchRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string variable, string condition)
1059 {
1060 section.Tuples.Add(new WixSearchTuple(sourceLineNumbers, id)
1061 {
1062 Variable = variable,
1063 Condition = condition,
1064 });
1065 }
1066
1067 /// <summary>
1068 ///
1069 /// </summary>
1070 /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
1071 /// <param name="id">Identifier of the search (key into the WixSearch table)</param>
1072 /// <param name="parentId">Identifier of the search that comes before (key into the WixSearch table)</param>
1073 /// <param name="attributes">Further details about the relation between id and parentId.</param>
1074 private void CreateWixSearchRelationRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, int attributes)
1075 {
1076 section.Tuples.Add(new WixSearchRelationTuple(sourceLineNumbers, id)
1077 {
1078 ParentSearchRef = parentId,
1079 Attributes = attributes,
1080 });
1081 }
1082
1083 /// <summary>
1084 /// Parses a file share element. 1110 /// Parses a file share element.
1085 /// </summary> 1111 /// </summary>
1086 /// <param name="element">Element to parse.</param> 1112 /// <param name="element">Element to parse.</param>
@@ -2523,11 +2549,6 @@ namespace WixToolset.Util
2523 } 2549 }
2524 } 2550 }
2525 2551
2526 if (null == variable)
2527 {
2528 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Variable"));
2529 }
2530
2531 if (null == upgradeCode && null == productCode) 2552 if (null == upgradeCode && null == productCode)
2532 { 2553 {
2533 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "ProductCode", "UpgradeCode", true)); 2554 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "ProductCode", "UpgradeCode", true));
@@ -2545,16 +2566,10 @@ namespace WixToolset.Util
2545 2566
2546 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); 2567 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
2547 2568
2569 this.ParseHelper.CreateWixSearchTuple(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, null);
2570
2548 if (!this.Messaging.EncounteredError) 2571 if (!this.Messaging.EncounteredError)
2549 { 2572 {
2550 this.CreateWixSearchRow(section, sourceLineNumbers, id, variable, condition);
2551 if (after != null)
2552 {
2553 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixSearch", after);
2554 // TODO: We're currently defaulting to "always run after", which we will need to change...
2555 this.CreateWixSearchRelationRow(section, sourceLineNumbers, id, after, 2);
2556 }
2557
2558 WixProductSearchAttributes attributes = WixProductSearchAttributes.Version; 2573 WixProductSearchAttributes attributes = WixProductSearchAttributes.Version;
2559 switch (result) 2574 switch (result)
2560 { 2575 {
@@ -2662,11 +2677,6 @@ namespace WixToolset.Util
2662 } 2677 }
2663 } 2678 }
2664 2679
2665 if (null == variable)
2666 {
2667 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Variable"));
2668 }
2669
2670 if (!root.HasValue) 2680 if (!root.HasValue)
2671 { 2681 {
2672 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Root")); 2682 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Root"));
@@ -2726,16 +2736,10 @@ namespace WixToolset.Util
2726 2736
2727 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); 2737 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
2728 2738
2739 this.ParseHelper.CreateWixSearchTuple(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, null);
2740
2729 if (!this.Messaging.EncounteredError) 2741 if (!this.Messaging.EncounteredError)
2730 { 2742 {
2731 this.CreateWixSearchRow(section, sourceLineNumbers, id, variable, condition);
2732 if (after != null)
2733 {
2734 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixSearch", after);
2735 // TODO: We're currently defaulting to "always run after", which we will need to change...
2736 this.CreateWixSearchRelationRow(section, sourceLineNumbers, id, after, 2);
2737 }
2738
2739 section.Tuples.Add(new WixRegistrySearchTuple(sourceLineNumbers, id) 2743 section.Tuples.Add(new WixRegistrySearchTuple(sourceLineNumbers, id)
2740 { 2744 {
2741 Root = (RegistryRootType)root, 2745 Root = (RegistryRootType)root,