aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2023-10-23 00:17:18 -0400
committerBob Arnson <github@bobs.org>2023-10-28 21:18:18 -0400
commitb84202794f5fd4f21e0fb1fc74c2f5d531035db3 (patch)
treecdf4f858489a50fefef122843837252c760ef4c0 /src/api
parentbb691bde8bff680ead1e6b0cf41cf3af7736331b (diff)
downloadwix-b84202794f5fd4f21e0fb1fc74c2f5d531035db3.tar.gz
wix-b84202794f5fd4f21e0fb1fc74c2f5d531035db3.tar.bz2
wix-b84202794f5fd4f21e0fb1fc74c2f5d531035db3.zip
Introduce a new phase in the build pipeline.
A useful point in the build pipeline is after all the files in the project have been compiled but before they've been linked. The WiX core and extensions can operate on symbols across the project but without operating at the source-code level. This phase is currently named "optimize," after a moderately-similar phase in other compiler architectures. The name is, for now, a stake in the ground and a better alternate is welcome.
Diffstat (limited to '')
-rw-r--r--src/api/wix/WixToolset.Extensibility/BaseOptimizerExtension.cs26
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs2
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/IOptimizeContext.cs61
-rw-r--r--src/api/wix/WixToolset.Extensibility/IOptimizerExtension.cs22
4 files changed, 110 insertions, 1 deletions
diff --git a/src/api/wix/WixToolset.Extensibility/BaseOptimizerExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseOptimizerExtension.cs
new file mode 100644
index 00000000..5bb89272
--- /dev/null
+++ b/src/api/wix/WixToolset.Extensibility/BaseOptimizerExtension.cs
@@ -0,0 +1,26 @@
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.Extensibility
4{
5 using WixToolset.Extensibility.Data;
6
7 /// <summary>
8 /// Base class for creating an optimizer extension.
9 /// </summary>
10 public abstract class BaseOptimizerExtension : IOptimizerExtension
11 {
12 /// <summary>
13 /// Called after all files have been compiled, before built-in optimizations, and before all sections are linked into a single section.
14 /// </summary>
15 public virtual void PreOptimize(IOptimizeContext context)
16 {
17 }
18
19 /// <summary>
20 /// Called after all files have been compiled, after built-in optimizations, and before all sections are linked into a single section.
21 /// </summary>
22 public virtual void PostOptimize(IOptimizeContext context)
23 {
24 }
25 }
26}
diff --git a/src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs b/src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs
index 7006fde8..cfccd0a9 100644
--- a/src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs
+++ b/src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs
@@ -55,7 +55,7 @@ namespace WixToolset.Extensibility.Data
55 XDocument Source { get; set; } 55 XDocument Source { get; set; }
56 56
57 /// <summary> 57 /// <summary>
58 /// Cancellation token to abort cancellation. 58 /// Cancellation token.
59 /// </summary> 59 /// </summary>
60 CancellationToken CancellationToken { get; set; } 60 CancellationToken CancellationToken { get; set; }
61 } 61 }
diff --git a/src/api/wix/WixToolset.Extensibility/Data/IOptimizeContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IOptimizeContext.cs
new file mode 100644
index 00000000..5684ebcd
--- /dev/null
+++ b/src/api/wix/WixToolset.Extensibility/Data/IOptimizeContext.cs
@@ -0,0 +1,61 @@
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.Extensibility.Data
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Threading;
8 using WixToolset.Data;
9
10 /// <summary>
11 /// Context provided to the optimizer.
12 /// </summary>
13 public interface IOptimizeContext
14 {
15 /// <summary>
16 /// Service provider made available to the optimizer and its extensions.
17 /// </summary>
18 IServiceProvider ServiceProvider { get; }
19
20 /// <summary>
21 /// Set of extensions provided to the optimizer.
22 /// </summary>
23 IReadOnlyCollection<IOptimizerExtension> Extensions { get; set; }
24
25 /// <summary>
26 /// Intermediate folder.
27 /// </summary>
28 string IntermediateFolder { get; set; }
29
30 /// <summary>
31 /// Collection of bindpaths used to bind files.
32 /// </summary>
33 IReadOnlyCollection<IBindPath> BindPaths { get; set; }
34
35 /// <summary>
36 /// Bind variables used during optimization.
37 /// </summary>
38 IDictionary<string, string> BindVariables { get; set; }
39
40 /// <summary>
41 /// Gets or sets the platform which the optimizer will use when defaulting 64-bit symbol properties.
42 /// </summary>
43 /// <value>The platform which the optimizer will use when defaulting 64-bit symbol properties.</value>
44 Platform Platform { get; set; }
45
46 /// <summary>
47 /// Collection of intermediates to optimize.
48 /// </summary>
49 IReadOnlyCollection<Intermediate> Intermediates { get; set; }
50
51 /// <summary>
52 /// Collection of localization files to use in the optimizer.
53 /// </summary>
54 IReadOnlyCollection<Localization> Localizations { get; set; }
55
56 /// <summary>
57 /// Cancellation token.
58 /// </summary>
59 CancellationToken CancellationToken { get; set; }
60 }
61}
diff --git a/src/api/wix/WixToolset.Extensibility/IOptimizerExtension.cs b/src/api/wix/WixToolset.Extensibility/IOptimizerExtension.cs
new file mode 100644
index 00000000..589e7ecc
--- /dev/null
+++ b/src/api/wix/WixToolset.Extensibility/IOptimizerExtension.cs
@@ -0,0 +1,22 @@
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.Extensibility
4{
5 using WixToolset.Extensibility.Data;
6
7 /// <summary>
8 /// Interface that all optimizer extensions implement.
9 /// </summary>
10 public interface IOptimizerExtension
11 {
12 /// <summary>
13 /// Called after all files have been compiled, before built-in optimizations, and before all sections are linked into a single section.
14 /// </summary>
15 void PreOptimize(IOptimizeContext context);
16
17 /// <summary>
18 /// Called after all files have been compiled, after built-in optimizations, and before all sections are linked into a single section.
19 /// </summary>
20 void PostOptimize(IOptimizeContext context);
21 }
22}