From c6456e5a41709997f62656e2406017321b346e48 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 3 Mar 2020 16:08:40 -0500 Subject: Add CreateCustomActionReference method ...to simplify creating custom action references following naming conventions. --- .../ExtensibilityServices/CustomActionPlatforms.cs | 31 ++++++++++++++ .../ExtensibilityServices/ParseHelper.cs | 48 ++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/WixToolset.Core/ExtensibilityServices/CustomActionPlatforms.cs (limited to 'src') diff --git a/src/WixToolset.Core/ExtensibilityServices/CustomActionPlatforms.cs b/src/WixToolset.Core/ExtensibilityServices/CustomActionPlatforms.cs new file mode 100644 index 00000000..17f381ac --- /dev/null +++ b/src/WixToolset.Core/ExtensibilityServices/CustomActionPlatforms.cs @@ -0,0 +1,31 @@ +// 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. + +namespace WixToolset.Core.ExtensibilityServices +{ + using System; + + /// + /// Platforms supported by custom actions. + /// + [Flags] + public enum CustomActionPlatforms + { + /// Not specified. + None = 0, + + /// x86. + X86 = 0x1, + + /// x64. + X64 = 0x2, + + /// ia64. + IA64 = 0x4, + + /// arm. + ARM = 0x8, + + /// arm64. + ARM64 = 0x10 + } +} diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index 8fbfdd87..271e5697 100644 --- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs @@ -892,6 +892,54 @@ namespace WixToolset.Core.ExtensibilityServices return actionTuple; } + /// + /// Create a reference in the specified section for a custom action specialized for specific platforms, + /// given standard prefixes for naming and suffixes for platforms. + /// + /// Source line information. + /// The custom action base name. + /// The platforms for which there are specialized custom actions. + public void CreateCustomActionReference(SourceLineNumber sourceLineNumbers, IntermediateSection section, string customAction, Platform platform, CustomActionPlatforms supportedPlatforms) + { + if (!this.Messaging.EncounteredError) + { + var name = String.Concat("Wix4", customAction); + + switch (platform) + { + case Platform.X86: + if ((supportedPlatforms & CustomActionPlatforms.X86) == CustomActionPlatforms.X86) + { + name = String.Concat(customAction, "_X86"); + } + break; + case Platform.X64: + if ((supportedPlatforms & CustomActionPlatforms.X64) == CustomActionPlatforms.X64) + { + name = String.Concat(customAction, "_X64"); + } + break; + case Platform.ARM: + if ((supportedPlatforms & CustomActionPlatforms.ARM) == CustomActionPlatforms.ARM) + { + name = String.Concat(customAction, "_A32"); + } + break; + case Platform.ARM64: + if ((supportedPlatforms & CustomActionPlatforms.ARM64) == CustomActionPlatforms.ARM64) + { + name = String.Concat(customAction, "_A64"); + } + break; + case Platform.IA64: + // yeah, no + break; + } + + this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), name); + } + } + public void UnexpectedAttribute(XElement element, XAttribute attribute) { var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(element); -- cgit v1.2.3-55-g6feb