Skip to content

Commit d834485

Browse files
authored
Merge branch 'main' into fix/build-scripts/gallery/labs
2 parents 088712d + acc45f7 commit d834485

14 files changed

+185
-97
lines changed

Build-Toolkit-Components.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@
5858
#>
5959
Param (
6060
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
61-
[string[]]$MultiTargets = @('all'),
61+
[Alias("mt")]
62+
[string[]]$MultiTargets = @('uwp', 'wasdk', 'wasm'), # default settings
6263

6364
[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
64-
[string[]]$ExcludeMultiTargets = @('wpf', 'linuxgtk', 'macos', 'ios', 'android'),
65+
[string[]]$ExcludeMultiTargets = @(), # default settings
6566

67+
[Alias("c")]
6668
[string[]]$Components = @("all"),
6769

6870
[string[]]$ExcludeComponents,
@@ -76,10 +78,13 @@ Param (
7678
[Alias("bl")]
7779
[switch]$EnableBinLogs,
7880

81+
[Alias("blo")]
7982
[string]$BinlogOutput,
80-
83+
84+
[Alias("p")]
8185
[hashtable]$AdditionalProperties,
8286

87+
[Alias("winui")]
8388
[int]$WinUIMajorVersion = 2,
8489

8590
[string]$ComponentDir = "src",

Build-Toolkit-Gallery.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Specifies the MultiTarget TFM(s) to exclude for building the components. The default value excludes targets that require additional tooling or workloads to build: 'wpf', 'linuxgtk', 'macos', 'ios', and 'android'. Run uno-check to install the required workloads.
1313
1414
.PARAMETER Heads
15-
The heads to include in the build. Default is 'Uwp', 'WinAppSdk', 'Wasm'.
15+
The heads to include in the build. Default is 'Uwp', 'Wasdk', 'Wasm'.
1616
1717
.PARAMETER ExcludeHeads
1818
The heads to exclude from the build. Default is none.
@@ -47,26 +47,31 @@
4747
#>
4848
Param (
4949
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
50-
[string[]]$MultiTargets = @('all'),
50+
[Alias("mt")]
51+
[string[]]$MultiTargets = @('uwp', 'wasdk', 'wasm'), # default settings
5152

5253
[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
53-
[string[]]$ExcludeMultiTargets = @('wpf', 'linuxgtk', 'macos', 'ios', 'android'),
54+
[string[]]$ExcludeMultiTargets = @() # default settings
5455

55-
[ValidateSet('all', 'Uwp', 'WinAppSdk', 'Wasm', 'Tests.Uwp', 'Tests.WinAppSdk')]
56-
[string[]]$Heads = @('Uwp', 'WinAppSdk', 'Wasm'),
56+
[ValidateSet('all', 'Uwp', 'Wasdk', 'Wasm', 'Tests.Uwp', 'Tests.Wasdk')]
57+
[string[]]$Heads = @('Uwp', 'Wasdk', 'Wasm'),
5758

58-
[ValidateSet('Uwp', 'WinAppSdk', 'Wasm', 'Tests.Uwp', 'Tests.WinAppSdk')]
59+
[ValidateSet('Uwp', 'Wasdk', 'Wasm', 'Tests.Uwp', 'Tests.Wasdk')]
5960
[string[]]$ExcludeHeads,
6061

6162
[Alias("bl")]
6263
[switch]$EnableBinLogs,
6364

65+
[Alias("blo")]
6466
[string]$BinlogOutput,
6567

68+
[Alias("p")]
6669
[hashtable]$AdditionalProperties,
6770

71+
[Alias("winui")]
6872
[int]$WinUIMajorVersion = 2,
6973

74+
[Alias("c")]
7075
[string[]]$Components = @("all"),
7176

7277
[string[]]$ExcludeComponents,
@@ -112,7 +117,7 @@ if ($Components -notcontains 'Converters') {
112117
& $PSScriptRoot\MultiTarget\GenerateAllProjectReferences.ps1 -MultiTarget $MultiTargets -Components $Components
113118

114119
if ($Heads -eq 'all') {
115-
$Heads = @('Uwp', 'WinAppSdk', 'Wasm', 'Tests.Uwp', 'Tests.WinAppSdk')
120+
$Heads = @('Uwp', 'Wasdk', 'Wasm', 'Tests.Uwp', 'Tests.Wasdk')
116121
}
117122

118123
function Invoke-MSBuildWithBinlog {

GenerateAllSolution.ps1

Lines changed: 89 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,73 @@
11
<#
22
.SYNOPSIS
33
Generates the solution file comprising of platform heads for samples, individual component projects, and tests.
4+
45
.DESCRIPTION
56
Used mostly for CI building of everything and testing end-to-end scenarios involving the full
67
sample app experience.
78
89
Otherwise it is recommended to focus on an individual component's solution instead.
9-
.PARAMETER IncludeHeads
10-
List of TFM based projects to include. This can be 'all', 'uwp', or 'winappsdk'.
1110
12-
Defaults to 'all' for local-use.
11+
.PARAMETER MultiTargets
12+
Specifies the MultiTarget TFM(s) to include for building the components. The default value is 'all'.
13+
14+
.PARAMETER ExcludeMultiTargets
15+
Specifies the MultiTarget TFM(s) to exclude for building the components. The default value excludes targets that require additional tooling or workloads to build. Run uno-check to install the required workloads.
16+
17+
.PARAMETER Components
18+
The names of the components to generate project and solution references for. Defaults to all components.
19+
20+
.PARAMETER ExcludeComponents
21+
The names of the components to exclude when generating solution and project references. Defaults to none.
22+
23+
.PARAMETER WinUIMajorVersion
24+
Specifies the WinUI major version to use when building an Uno head. Also decides the package id and dependency variant. The default value is '2'.
25+
1326
.PARAMETER UseDiagnostics
1427
Add extra diagnostic output to running slngen, such as a binlog, etc...
28+
1529
.EXAMPLE
16-
C:\PS> .\GenerateAllSolution -IncludeHeads winappsdk
30+
C:\PS> .\GenerateAllSolution -MultiTargets wasdk
1731
Build a solution that doesn't contain UWP projects.
32+
1833
.NOTES
1934
Author: Windows Community Toolkit Labs Team
2035
Date: April 27, 2022
2136
#>
2237
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',
38+
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android')]
39+
[Alias("mt")]
40+
[string[]]$MultiTargets = @('uwp', 'wasm', 'wasdk'),
41+
42+
[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
43+
[string[]]$ExcludeMultiTargets = @(), # default settings
44+
45+
[Alias("c")]
46+
[string[]]$Components = @('all'),
47+
48+
[Alias("winui")]
49+
[int]$WinUIMajorVersion = 2,
50+
51+
[string[]]$ExcludeComponents,
2652

27-
[Parameter(HelpMessage = "Add extra diagnostic output to slngen generator.")]
2853
[switch]$UseDiagnostics = $false
2954
)
3055

56+
if ($MultiTargets.Contains('all')) {
57+
$MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android')
58+
}
59+
60+
if ($null -eq $ExcludeMultiTargets)
61+
{
62+
$ExcludeMultiTargets = @()
63+
}
64+
65+
$MultiTargets = $MultiTargets | Where-Object { $_ -notin $ExcludeMultiTargets }
66+
3167
# Generate required props for "All" solution.
32-
& ./tooling/MultiTarget/GenerateAllProjectReferences.ps1
68+
& ./tooling/MultiTarget/GenerateAllProjectReferences.ps1 -MultiTargets $MultiTargets -Components $Components -ExcludeComponents $ExcludeComponents
69+
& ./tooling/MultiTarget/UseTargetFrameworks.ps1 -MultiTargets $MultiTargets
70+
& ./tooling/MultiTarget/UseUnoWinUI.ps1 $WinUIMajorVersion
3371

3472
# Set up constant values
3573
$generatedSolutionFilePath = 'CommunityToolkit.AllComponents.sln'
@@ -55,30 +93,58 @@ $projects = [System.Collections.ArrayList]::new()
5593
# Common/Dependencies for shared infrastructure
5694
[void]$projects.Add(".\tooling\CommunityToolkit*\*.*proj")
5795

58-
# App Head and Test Head
59-
if ($IncludeHeads -ne 'winappsdk')
60-
{
61-
[void]$projects.Add(".\tooling\ProjectHeads\AllComponents\**\*.Uwp.csproj")
96+
# Deployable sample gallery heads
97+
# TODO: this handles separate project heads, but won't directly handle the unified Skia head from Uno.
98+
# Once we have that, just do a transform on the csproj filename inside this loop to decide the same csproj for those separate MultiTargets.
99+
foreach ($multitarget in $MultiTargets) {
100+
# capitalize first letter, avoid case sensitivity issues on linux
101+
$csprojFileNamePartForMultiTarget = $multitarget.substring(0,1).ToUpper() + $multitarget.Substring(1).ToLower()
102+
103+
$path = ".\tooling\ProjectHeads\AllComponents\**\*.$csprojFileNamePartForMultiTarget.csproj";
104+
105+
if (Test-Path $path) {
106+
[void]$projects.Add($path)
107+
}
108+
else {
109+
Write-Warning "No project head could be found at $path for MultiTarget $multitarget. Skipping."
110+
}
62111
}
63112

64-
if ($IncludeHeads -ne 'uwp')
65-
{
66-
[void]$projects.Add(".\tooling\ProjectHeads\AllComponents\**\*.WinAppSdk.csproj")
113+
# Individual projects
114+
if ($Components -eq @('all')) {
115+
$Components = @('**')
67116
}
68117

69-
[void]$projects.Add(".\tooling\ProjectHeads\AllComponents\**\*.Wasm.csproj")
70-
71-
# Individual projects
72-
[void]$projects.Add(".\components\**\src\*.csproj")
73-
[void]$projects.Add(".\components\**\samples\*.Samples.csproj")
74-
[void]$projects.Add(".\components\**\tests\*.Tests\*.shproj")
118+
foreach ($componentName in $Components) {
119+
if ($ExcludeComponents -contains $componentName) {
120+
continue;
121+
}
122+
123+
foreach ($componentPath in Get-Item "$PSScriptRoot/../components/$componentName/") {
124+
$multiTargetPrefs = & $PSScriptRoot\MultiTarget\Get-MultiTargets.ps1 -component $($componentPath.BaseName)
125+
126+
$shouldReferenceInSolution = $multiTargetPrefs.Where({ $MultiTargets.Contains($_) }).Count -gt 0
127+
128+
if ($shouldReferenceInSolution) {
129+
Write-Output "Add component $componentPath to solution";
130+
131+
[void]$projects.Add(".\components\$($componentPath.BaseName)\src\*.csproj")
132+
[void]$projects.Add(".\components\$($componentPath.BaseName)\samples\*.Samples.csproj")
133+
[void]$projects.Add(".\components\$($componentPath.BaseName)\tests\*.Tests\*.shproj")
134+
} else {
135+
Write-Warning "Component $($componentPath.BaseName) doesn't MultiTarget any of $MultiTargets and won't be added to the solution.";
136+
}
137+
}
138+
}
75139

76140
if ($UseDiagnostics.IsPresent)
77141
{
78142
$sdkoptions = "-d"
79143
$diagnostics = @(
80144
'-bl:slngen.binlog'
81-
'--consolelogger:ShowEventId;Summary;Verbosity=Detailed'
145+
# Console logger + binlog causes exception and failure
146+
# Track https://github.com/microsoft/slngen/issues/451
147+
#'--consolelogger:ShowEventId;Summary;Verbosity=Detailed'
82148
)
83149
}
84150
else

MultiTarget/GenerateAllProjectReferences.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ Param (
33
[string]$projectPropsOutputDir = "$PSScriptRoot/Generated",
44

55
[Parameter(HelpMessage = "Only projects that support these targets will have references generated for use by deployable heads.")]
6-
[string[]]$MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard"),
6+
[Alias("mt")]
7+
[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
8+
[string[]]$MultiTargets = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard"),
79

810
[Parameter(HelpMessage = "The names of the components to generate references for. Defaults to all components.")]
911
[string[]]$Components = @("all"),
@@ -45,11 +47,11 @@ foreach ($componentName in $Components) {
4547
# Generate <ProjectReference>s for sample project
4648
# Use source project MultiTarget as first fallback.
4749
if ($null -ne $componentSampleCsproj -and (Test-Path $componentSampleCsproj)) {
48-
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $componentSampleCsproj -outputPath "$projectPropsOutputDir/$($componentSampleCsproj.BaseName).props" -MultiTarget $MultiTarget
50+
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $componentSampleCsproj -outputPath "$projectPropsOutputDir/$($componentSampleCsproj.BaseName).props" -MultiTargets $MultiTargets
4951
}
5052

5153
# Generate <ProjectReference>s for src project
52-
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $componentSourceCsproj -outputPath "$projectPropsOutputDir/$($componentSourceCsproj.BaseName).props" -MultiTarget $MultiTarget
54+
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $componentSourceCsproj -outputPath "$projectPropsOutputDir/$($componentSourceCsproj.BaseName).props" -MultiTargets $MultiTargets
5355
}
5456
}
5557

MultiTarget/GenerateMultiTargetAwareProjectReferenceProps.ps1

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Param (
1616

1717
[Parameter(HelpMessage = "Only projects that support these targets will have references generated for use by deployable heads.")]
1818
[ValidateSet("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard")]
19-
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard")
19+
[Alias("mt")]
20+
[string[]] $MultiTargets = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard")
2021
)
2122

2223
$templateContents = Get-Content -Path $templatePath;
@@ -40,35 +41,44 @@ $templateContents = $templateContents -replace [regex]::escape($projectRootPlace
4041
$componentPath = Get-Item "$projectPath/../../"
4142

4243
# Load multitarget preferences for component
43-
$multiTargets = & $PSScriptRoot\Get-MultiTargets.ps1 -component $($componentPath.BaseName)
44+
$multiTargetPrefs = & $PSScriptRoot\Get-MultiTargets.ps1 -component $($componentPath.BaseName)
4445

45-
if ($null -eq $multiTargets) {
46+
if ($null -eq $multiTargetPrefs) {
4647
Write-Error "Couldn't get MultiTarget property for $componentPath";
4748
exit(-1);
4849
}
4950

50-
# Ensure multiTargets is not empty
51-
if ($multiTargets.Length -eq 0) {
51+
# Ensure multiTargetPrefs is not empty
52+
if ($multiTargetPrefs.Length -eq 0) {
5253
Write-Error "MultiTarget property is empty for $projectPath";
5354
exit(-1);
5455
}
5556

56-
$templateContents = $templateContents -replace [regex]::escape("[IntendedTargets]"), $multiTargets;
57+
$templateContents = $templateContents -replace [regex]::escape("[IntendedTargets]"), $multiTargetPrefs;
5758

5859
function ShouldMultiTarget([string] $target) {
59-
return ($multiTargets.Contains($target) -and $MultiTarget.Contains($target)).ToString().ToLower()
60+
return ($multiTargetPrefs.Contains($target) -and $MultiTargets.Contains($target))
6061
}
6162

62-
Write-Host "Generating project references for $([System.IO.Path]::GetFileNameWithoutExtension($csprojFileName)): $($multiTargets -Join ', ')"
63-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasm]"), "'$(ShouldMultiTarget "wasm")'";
64-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetUwp]"), "'$(ShouldMultiTarget "uwp")'";
65-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasdk]"), "'$(ShouldMultiTarget "wasdk")'";
66-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWpf]"), "'$(ShouldMultiTarget "wpf")'";
67-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetLinuxGtk]"), "'$(ShouldMultiTarget "linuxgtk")'";
68-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetMacOS]"), "'$(ShouldMultiTarget "macos")'";
69-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetiOS]"), "'$(ShouldMultiTarget "ios")'";
70-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetDroid]"), "'$(ShouldMultiTarget "droid")'";
71-
$templateContents = $templateContents -replace [regex]::escape("[CanTargetNetstandard]"), "'$(ShouldMultiTarget "netstandard")'";
63+
function ShouldMultiTargetMsBuildValue([string] $target) {
64+
return $(ShouldMultiTarget $target).ToString().ToLower()
65+
}
66+
67+
$targeted = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard").Where({ ShouldMultiTarget $_ })
68+
69+
if ($targeted.Count -gt 0) {
70+
Write-Host "Generating project references for $([System.IO.Path]::GetFileNameWithoutExtension($csprojFileName)): $($targeted -Join ', ')"
71+
}
72+
73+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasm]"), "'$(ShouldMultiTargetMsBuildValue "wasm")'";
74+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetUwp]"), "'$(ShouldMultiTargetMsBuildValue "uwp")'";
75+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWasdk]"), "'$(ShouldMultiTargetMsBuildValue "wasdk")'";
76+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetWpf]"), "'$(ShouldMultiTargetMsBuildValue "wpf")'";
77+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetLinuxGtk]"), "'$(ShouldMultiTargetMsBuildValue "linuxgtk")'";
78+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetMacOS]"), "'$(ShouldMultiTargetMsBuildValue "macos")'";
79+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetiOS]"), "'$(ShouldMultiTargetMsBuildValue "ios")'";
80+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetDroid]"), "'$(ShouldMultiTargetMsBuildValue "android")'";
81+
$templateContents = $templateContents -replace [regex]::escape("[CanTargetNetstandard]"), "'$(ShouldMultiTargetMsBuildValue "netstandard")'";
7282

7383
# Save to disk
7484
Set-Content -Path $outputPath -Value $templateContents;

0 commit comments

Comments
 (0)