Skip to content

Commit a5b2f7a

Browse files
committed
Aligned head and MultiTarget generation
1 parent e661644 commit a5b2f7a

File tree

10 files changed

+68
-62
lines changed

10 files changed

+68
-62
lines changed

GenerateAllSolution.ps1

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,31 @@
77
88
Otherwise it is recommended to focus on an individual component's solution instead.
99
.PARAMETER IncludeHeads
10-
List of TFM based projects to include. This can be 'all', 'uwp', or 'winappsdk'.
10+
List of TFM based projects to include. This can be 'all', 'uwp', or 'wasdk'.
1111
12-
Defaults to 'all' for local-use.
12+
Defaults to 'all'.
1313
.PARAMETER UseDiagnostics
1414
Add extra diagnostic output to running slngen, such as a binlog, etc...
1515
.EXAMPLE
16-
C:\PS> .\GenerateAllSolution -IncludeHeads winappsdk
16+
C:\PS> .\GenerateAllSolution -IncludeHeads wasdk
1717
Build a solution that doesn't contain UWP projects.
1818
.NOTES
1919
Author: Windows Community Toolkit Labs Team
2020
Date: April 27, 2022
2121
#>
2222
Param (
23-
[Parameter(HelpMessage = "The heads to include for building platform samples and tests.", ParameterSetName = "IncludeHeads")]
24-
[ValidateSet('all', 'uwp', 'winappsdk')]
25-
[string]$IncludeHeads = 'all',
23+
[Parameter(HelpMessage = "The heads to include for building the sample gallery and tests.", ParameterSetName = "IncludeHeads")]
24+
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android')]
25+
[string[]]$IncludeHeads = @('all'),
2626

2727
[Parameter(HelpMessage = "Add extra diagnostic output to slngen generator.")]
2828
[switch]$UseDiagnostics = $false
2929
)
3030

31+
if ($IncludeHeads.Contains('all')) {
32+
$IncludeHeads = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android')
33+
}
34+
3135
# Generate required props for "All" solution.
3236
& ./tooling/MultiTarget/GenerateAllProjectReferences.ps1
3337

@@ -55,18 +59,21 @@ $projects = [System.Collections.ArrayList]::new()
5559
# Common/Dependencies for shared infrastructure
5660
[void]$projects.Add(".\tooling\CommunityToolkit*\*.*proj")
5761

58-
# App Head and Test Head
59-
if ($IncludeHeads -ne 'winappsdk')
60-
{
61-
[void]$projects.Add(".\tooling\ProjectHeads\AllComponents\**\*.Uwp.csproj")
62-
}
62+
# TODO: this handles separate project heads, but won't directly handle the unified Skia head from Uno.
63+
# Once we have that, just do a transform on the csproj filename inside this loop to decide the same csproj for those separate MultiTargets.
64+
foreach ($multitarget in $IncludeHeads) {
65+
# capitalize first letter, avoid case sensitivity issues on linux
66+
$csprojFileNamePartForMultiTarget = $multitarget.substring(0,1).ToUpper() + $multitarget.Substring(1).ToLower()
6367

64-
if ($IncludeHeads -ne 'uwp')
65-
{
66-
[void]$projects.Add(".\tooling\ProjectHeads\AllComponents\**\*.WinAppSdk.csproj")
67-
}
68+
$path = ".\tooling\ProjectHeads\AllComponents\**\*.$csprojFileNamePartForMultiTarget.csproj";
6869

69-
[void]$projects.Add(".\tooling\ProjectHeads\AllComponents\**\*.Wasm.csproj")
70+
if (Test-Path $path) {
71+
[void]$projects.Add($path)
72+
}
73+
else {
74+
Write-Warning "No project head could be found at $path for MultiTarget $multitarget. Skipping."
75+
}
76+
}
7077

7178
# Individual projects
7279
[void]$projects.Add(".\components\**\src\*.csproj")

MultiTarget/UseTargetFrameworks.ps1

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,32 @@
33
Changes the target frameworks to build for each package created within the repository.
44
.DESCRIPTION
55
By default, only the UWP, Windows App SDK, and WASM heads are built to simplify dependencies
6-
needed to build projects within the repository. The CI will enable all targets to build a package
6+
needed to build projects within the repository. The CI will enable all include to build a package
77
that works on all supported platforms.
88
99
Note: Projects which rely on target platforms that are excluded will be unable to build.
10-
.PARAMETER targets
11-
List of targets to set as TFM platforms to build for. Possible values match those provided to the <MultiTarget> MSBuild property, as well as 'all', 'all-uwp', 'all-wasdk', or blank.
12-
When run as blank, the defaults (uwp, winappsdk, wasm) will be used.
13-
'all', 'all-uwp', and 'all-wasdk' shouldn't be used with other targets or each other.
14-
.PARAMETER allowGitChanges
15-
Enabling this flag will allow changes to the props file to be checked into source control.
16-
By default the file is ignored so local changes to building don't accidently get checked in.
10+
.PARAMETER include
11+
List of include to set as TFM platforms to build for. Possible values match those provided to the <MultiTarget> MSBuild property.
12+
By default, uwp, wasdk, and wasm will included.
13+
.PARAMETER exclude
14+
List to exclude from build. Possible values match those provided to the <MultiTarget> MSBuild property.
15+
By default, none will excluded.
1716
.EXAMPLE
18-
C:\PS> .\UseTargetFrameworks winappsdk
19-
Build targets for just the WindowsAppSDK.
17+
C:\PS> .\UseTargetFrameworks wasdk
18+
Build include for just the WindowsAppSDK.
2019
.NOTES
2120
Author: Windows Community Toolkit Labs Team
2221
Date: April 8, 2022
2322
#>
2423
Param (
2524
[Parameter(HelpMessage = "The target frameworks to enable.")]
26-
[ValidateSet('all', 'all-uwp', 'all-wasdk', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
27-
[string[]]$targets = @('uwp', 'winappsdk', 'wasm') # default settings
28-
)
25+
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
26+
[string[]]$include = @('uwp', 'wasdk', 'wasm'), # default settings
27+
28+
[Parameter(HelpMessage = "The target frameworks to disable.")]
29+
[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
30+
[string[]]$exclude = @() # default settings
31+
)3
2932

3033
$UwpTfm = "UwpTargetFramework";
3134
$WinAppSdkTfm = "WinAppSdkTargetFramework";
@@ -39,71 +42,67 @@ $NetstandardTfm = "DotnetStandardCommonTargetFramework";
3942

4043
$fileContents = Get-Content -Path $PSScriptRoot/AvailableTargetFrameworks.props
4144

42-
$allTargetFrameworks = @(
43-
$WasmTfm,
44-
$UwpTfm,
45-
$WinAppSdkTfm,
46-
$WpfTfm,
47-
$GtkTfm,
48-
$macOSTfm,
49-
$iOSTfm,
50-
$DroidTfm,
51-
$NetstandardTfm
52-
);
53-
54-
$desiredTfmValues = @();
55-
56-
if ($targets.Contains("all")) {
57-
$desiredTfmValues = $allTargetFrameworks;
45+
# 'all' represents many '$include' values
46+
if ($include.Contains("all")) {
47+
$include = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')
5848
}
5949

60-
if ($targets.Contains("all-uwp")) {
61-
$desiredTfmValues = $allTargetFrameworks.Replace($UwpTfm, "");
50+
# Exclude as needed
51+
foreach ($excluded in $exclude) {
52+
$include = $include.Where({ $_ -ne $excluded });
6253
}
6354

64-
if ($targets.Contains("all-wasdk")) {
65-
$desiredTfmValues = $allTargetFrameworks.Replace($WinAppSdkTfm, "");
66-
}
55+
Write-Output "Setting enabled TargetFrameworks: $include"
56+
57+
$desiredTfmValues = @();
6758

68-
if ($targets.Contains("wasm")) {
59+
if ($include.Contains("wasm")) {
6960
$desiredTfmValues += $WasmTfm;
7061
}
7162

72-
if ($targets.Contains("uwp")) {
63+
if ($include.Contains("uwp")) {
7364
$desiredTfmValues += $UwpTfm;
7465
}
7566

76-
if ($targets.Contains("wasdk")) {
67+
if ($include.Contains("wasdk")) {
7768
$desiredTfmValues += $WinAppSdkTfm;
7869
}
7970

80-
if ($targets.Contains("wpf")) {
71+
if ($include.Contains("wpf")) {
8172
$desiredTfmValues += $WpfTfm;
8273
}
8374

84-
if ($targets.Contains("linuxgtk")) {
75+
if ($include.Contains("linuxgtk")) {
8576
$desiredTfmValues += $GtkTfm;
8677
}
8778

88-
if ($targets.Contains("macos")) {
79+
if ($include.Contains("macos")) {
8980
$desiredTfmValues += $macOSTfm;
9081
}
9182

92-
if ($targets.Contains("ios")) {
83+
if ($include.Contains("ios")) {
9384
$desiredTfmValues += $iOSTfm;
9485
}
9586

96-
if ($targets.Contains("android")) {
87+
if ($include.Contains("android")) {
9788
$desiredTfmValues += $DroidTfm;
9889
}
9990

100-
if ($targets.Contains("netstandard")) {
91+
if ($include.Contains("netstandard")) {
10192
$desiredTfmValues += $NetstandardTfm;
10293
}
10394

104-
Write-Output "Setting enabled TargetFrameworks: $targets"
105-
106-
$targetFrameworksToRemove = $allTargetFrameworks.Where({ -not $desiredTfmValues.Contains($_) })
95+
$targetFrameworksToRemove = @(
96+
$WasmTfm,
97+
$UwpTfm,
98+
$WinAppSdkTfm,
99+
$WpfTfm,
100+
$GtkTfm,
101+
$macOSTfm,
102+
$iOSTfm,
103+
$DroidTfm,
104+
$NetstandardTfm
105+
).Where({ -not $desiredTfmValues.Contains($_) })
107106

108107
$targetFrameworksToRemoveRegexPartial = $targetFrameworksToRemove -join "|";
109108

0 commit comments

Comments
 (0)