Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Commit f773f40

Browse files
authored
Link against core PDBs when building interop DLL (#208)
This change enables linking the interop DLL Microsoft.MixedReality.WebRTC.Native.dll with the PDBs from the core webrtc.lib and, on UWP platform, the UWP wrappers from Org.WebRtc.WrapperGlue.lib, to enable a better debugging experience for users. Given the large size of PDBs for each build variant (~400 MB and more), this changes uses some Universal Packages to store the PDBs in some private Artifacts feed on Azure DevOps when compiling webrtc.lib, and restore them when compiling Microsoft.MixedReality.WebRTC.Native.dll, as the frequency of the former is much lower than the frequency of the latter, and the former build is generally shared by multiple branches of the latter (e.g. master and release/1.0 at the moment). Additionally, because Azure build agents have a limit of 10GB per build, this change generates on-the-fly a custom packages.config for the current build triple (config-platform-arch) which allows restoring only the necessary core NuGet packages (containing webrtc.lib). This has the extra advantage of reducing the time needed to restore all platform packages: previously 4 on Desktop and 13 on UWP, now only 1 on Desktop and 3 on UWP. The .vcxproj is also modified on-the-fly and in-place to import only the restored packages. Note that those steps are executed via PowerShell scripts during the build and not stored in the committed .vcxproj/packages.config files because it is uncertain whether the Visual Studio IDE would understand platform- and config-dependent NuGet restore, which are rather unusual and only required because we are hitting the NuGet file size limit on nuget.org, therefore the files shipped on GitHub are left untouched with the full set of NuGet packages for all config/arch per platform, to avoid missing any NuGet restore which would prevent the user from compiling the solution.
1 parent 5a1e8d2 commit f773f40

13 files changed

+484
-36
lines changed

libs/Microsoft.MixedReality.WebRTC.Native/src/uwp/Microsoft.MixedReality.WebRTC.Native.UWP.vcxproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
<PropertyGroup Condition="'$(PlatformTarget)' == 'ARM'">
9292
<UnityPluginDirectory>$(ProjectDir)..\..\..\\Microsoft.MixedReality.WebRTC.Unity\Assets\Plugins\WSA\ARM</UnityPluginDirectory>
9393
</PropertyGroup>
94+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
95+
<LinkIncremental>true</LinkIncremental>
96+
</PropertyGroup>
97+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
98+
<LinkIncremental>false</LinkIncremental>
99+
</PropertyGroup>
94100
<ItemGroup>
95101
<NativeUnityPluginSourceFiles Include="$(OutDir)\Microsoft.MixedReality.WebRTC.Native.dll;$(OutDir)\Microsoft.MixedReality.WebRTC.Native.pdb" />
96102
</ItemGroup>
@@ -114,6 +120,28 @@
114120
<AdditionalDependencies>Ole32.lib;Evr.lib;mf.lib;mfuuid.lib;mfplat.lib;webrtc.lib;WindowsApp.lib;Org.WebRtc.WrapperGlue.lib;%(AdditionalDependencies)</AdditionalDependencies>
115121
<ModuleDefinitionFile>..\exports.def</ModuleDefinitionFile>
116122
<AdditionalLibraryDirectories>$(WebRTCCoreRepoPath)webrtc\xplatform\webrtc\OUTPUT\webrtc\winuwp\$(PlatformTarget)\$(Configuration);$(WebRTCCoreRepoPath)webrtc\windows\projects\msvc\Org.WebRtc.WrapperGlue.Universal\Build\Output\Org.WebRtc.WrapperGlue\$(Configuration)\$(PlatformTarget);$(WebRTCCoreRepoPath)webrtc\windows\projects\msvc\Org.WebRtc.Universal\Build\Output\Org.WebRtc\$(Configuration)\$(PlatformTarget);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
123+
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
124+
</Link>
125+
</ItemDefinitionGroup>
126+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
127+
<ClCompile>
128+
<Optimization>Disabled</Optimization>
129+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
130+
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
131+
</ClCompile>
132+
</ItemDefinitionGroup>
133+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
134+
<ClCompile>
135+
<Optimization>MaxSpeed</Optimization>
136+
<FunctionLevelLinking>true</FunctionLevelLinking>
137+
<IntrinsicFunctions>true</IntrinsicFunctions>
138+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
139+
<ConformanceMode>true</ConformanceMode>
140+
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
141+
</ClCompile>
142+
<Link>
143+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
144+
<OptimizeReferences>true</OptimizeReferences>
117145
</Link>
118146
</ItemDefinitionGroup>
119147
<ItemGroup>

libs/Microsoft.MixedReality.WebRTC.Native/src/uwp/Microsoft.MixedReality.WebRTC.Native.UWP.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<ClInclude Include="../interop/interop_api.h">
2626
<Filter>interop</Filter>
2727
</ClInclude>
28-
<ClInclude Include="../data_channel.h">
28+
<ClInclude Include="../../include/data_channel.h">
2929
<Filter>media</Filter>
3030
</ClInclude>
3131
<ClInclude Include="../../include/str.h" />

libs/Microsoft.MixedReality.WebRTC.Native/src/win32/Microsoft.MixedReality.WebRTC.Native.Win32.vcxproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<ModuleDefinitionFile>..\exports.def</ModuleDefinitionFile>
9797
<AdditionalDependencies>strmiids.lib;Msdmo.lib;dmoguids.lib;wmcodecdspuuid.lib;Secur32.lib;winmm.lib;Ole32.lib;Evr.lib;mfreadwrite.lib;mf.lib;mfuuid.lib;mfplat.lib;mfplay.lib;webrtc.lib;%(AdditionalDependencies)</AdditionalDependencies>
9898
<AdditionalLibraryDirectories>$(WebRTCCoreRepoPath)webrtc\xplatform\webrtc\OUTPUT\webrtc\win\$(PlatformTarget)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
99+
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
99100
</Link>
100101
</ItemDefinitionGroup>
101102
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
@@ -104,9 +105,6 @@
104105
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
105106
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
106107
</ClCompile>
107-
<Link>
108-
<GenerateDebugInformation>true</GenerateDebugInformation>
109-
</Link>
110108
</ItemDefinitionGroup>
111109
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
112110
<ClCompile>

libs/Microsoft.MixedReality.WebRTC.Native/src/win32/Microsoft.MixedReality.WebRTC.Native.Win32.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<ClInclude Include="../interop/interop_api.h">
2626
<Filter>interop</Filter>
2727
</ClInclude>
28-
<ClInclude Include="../data_channel.h">
28+
<ClInclude Include="../../include/data_channel.h">
2929
<Filter>media</Filter>
3030
</ClInclude>
3131
<ClInclude Include="../../include/str.h" />

tools/ci/computePdbPackageVars.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Compute the name and version of the Universal Package used for PDBs,
2+
# and populate the relevant pipeline variables.
3+
4+
# Compute package name
5+
# Note the restrictions on a Universal Package name (from error message):
6+
# Universal package names must be one or more lowercase alphanumeric
7+
# segments separated by a dash, dot or underscore. The package name
8+
# must be under 256 characters.
9+
if (!$env:BUILDTRIPLE)
10+
{
11+
$err = "Invalid build triple '$env:BUILDTRIPLE'"
12+
Write-Error $err
13+
Write-Host "##vso[task.complete result=Failed;]$err"
14+
exit 1
15+
}
16+
$PackageName = "mr-webrtc-core_pdbs_$env:BUILDTRIPLE".ToLowerInvariant()
17+
if ($PackageName.Length -ge 256) {
18+
$err = "Package name too long: '$PackageName'"
19+
Write-Error $err
20+
Write-Host "##vso[task.complete result=Failed;]$err"
21+
exit 1
22+
}
23+
Write-Host "PDB package name : $PackageName"
24+
Write-Host "##vso[task.setvariable variable=MRWebRTC_PdbPackageName]$PackageName"
25+
26+
# Compute version if needed, or check existing version
27+
if ($env:WRITE_VERSION -eq 'true')
28+
{
29+
# Compute package version based on build variables
30+
if ($env:MRWEBRTC_PDBPACKAGEVERSION)
31+
{
32+
# Normally this should compute $(MRWebRTC_PdbPackageVersion) based on the build's version
33+
# and optional release tag and build number. But the variable has also been already assigned
34+
# in the build pipelines variables, which generally indicates a misconfigured pipeline.
35+
$err = "Pipeline variable MRWebRTC_PdbPackageVersion is already set : '$env:MRWEBRTC_PDBPACKAGEVERSION'."
36+
Write-Error $err
37+
Write-Host "##vso[task.complete result=Failed;]$err"
38+
exit 1
39+
}
40+
if (!$env:MRWEBRTCVERSION)
41+
{
42+
$err = "Invalid build version '$env:MRWEBRTCVERSION'"
43+
Write-Error $err
44+
Write-Host "##vso[task.complete result=Failed;]$err"
45+
exit 1
46+
}
47+
if ($env:MRWEBRTCRELEASETAG)
48+
{
49+
$PackageVersion = "$env:MRWEBRTCVERSION-$env:MRWEBRTCRELEASETAG"
50+
}
51+
else
52+
{
53+
$PackageVersion = "$env:MRWEBRTCVERSION"
54+
}
55+
if ($env:MRWEBRTCWITHBUILDNUMBER -eq "true")
56+
{
57+
$PackageVersion = "$PackageVersion-$env:BUILD_BUILDNUMBER"
58+
}
59+
Write-Host "PDB package version (generated) : $PackageVersion"
60+
Write-Host "##vso[task.setvariable variable=MRWebRTC_PdbPackageVersion]$PackageVersion"
61+
}
62+
else
63+
{
64+
# Read and check version from pipeline variables, but do not modify
65+
if (!$env:MRWEBRTC_PDBPACKAGEVERSION)
66+
{
67+
$err = "Invalid PDB package version '$env:MRWEBRTC_PDBPACKAGEVERSION'"
68+
Write-Error $err
69+
Write-Host "##vso[task.complete result=Failed;]$err"
70+
exit 1
71+
}
72+
Write-Host "PDB package version (from pipeline) : $env:MRWEBRTC_PDBPACKAGEVERSION"
73+
}

tools/ci/copyPdbsForBuilding.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copy all PDBs from their packaging folder back next to webrtc.lib
2+
# Note that this is not their original location, but this is where
3+
# the linker currently looks for them.
4+
5+
param(
6+
[string]$SourcePath,
7+
[string]$OutputPath
8+
)
9+
10+
# Move all PDBs
11+
Write-Host "Moving PDBs..."
12+
mkdir -Force $OutputPath | out-null
13+
Move-Item -Path $(Join-Path $SourcePath "*") -Destination $OutputPath -Include "*.pdb"
14+
15+
# List content of output folder
16+
Write-Host "Content of output folder $OutputPath"
17+
foreach ($f in $(Get-ChildItem -Path $OutputPath -Recurse))
18+
{
19+
Write-Host $f.FullName
20+
}

tools/ci/copyPdbsForPackaging.ps1

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copy all PDBs into a single folder for packaging as Universal Package
2+
3+
param(
4+
[string]$CorePath,
5+
[string]$WrapperPath,
6+
[string]$WrapperGluePath,
7+
[string]$OutputPath,
8+
[ValidateSet('Debug','Release')]
9+
[string]$BuildConfig,
10+
[switch]$WithUwpWrapper
11+
)
12+
13+
# Copied from https://github.com/microsoft/MixedReality-Sharing/blob/master/tools/ci/utils.ps1
14+
function Ensure-Empty($DirectoryPath) {
15+
mkdir -Force "$DirectoryPath" | out-null
16+
Remove-Item "$DirectoryPath\*" -Force -Recurse
17+
}
18+
19+
# Ensure the output path exists and is empty
20+
Ensure-Empty $OutputPath
21+
22+
# Copy core PDBs
23+
Write-Host "Copying PDBs for core webrtc.lib..."
24+
Copy-Item -Path $(Join-Path $CorePath "*") -Destination $OutputPath -Include "*.pdb"
25+
26+
if ($WithUwpWrapper)
27+
{
28+
# Copy wrapper PDB (Org.WebRtc.pdb)
29+
Write-Host "Copying PDB for Org.WebRtc.dll..."
30+
Copy-Item -Path $(Join-Path $WrapperPath "Org.WebRtc.pdb") -Destination $OutputPath
31+
32+
# Copy wrapper glue PDB (Org.WebRtc.WrapperGlue.pdb)
33+
# In Release there is no PDB; the project does not specify /DEBUG so defaults to Debug-only PDBs.
34+
if ($BuildConfig -eq "Release") {
35+
Write-Host "Skipping PDB for Org.WebRtc.WrapperGlue.lib (not generated in Release)"
36+
} else {
37+
Write-Host "Copying PDB for Org.WebRtc.WrapperGlue.lib..."
38+
Copy-Item -Path $(Join-Path $WrapperGluePath "Org.WebRtc.WrapperGlue.pdb") -Destination $OutputPath
39+
}
40+
}
41+
42+
# List content of output folder
43+
Write-Host "Content of output folder $OutputPath"
44+
foreach ($f in $(Get-ChildItem -Path $OutputPath -Recurse))
45+
{
46+
Write-Host $f.FullName
47+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Generate a custom packages.config to restore only the necessary Core
2+
# NuGet packages for the given build triple, to save on disk space
3+
4+
param(
5+
[ValidateSet('Win32','UWP')]
6+
[string]$BuildPlatform,
7+
[ValidateSet('x86','x64','ARM')]
8+
[string]$BuildArch,
9+
[ValidateSet('Debug','Release')]
10+
[string]$BuildConfig,
11+
[string]$InputFile,
12+
[string]$OutputFile
13+
)
14+
15+
Write-Host "Generating packages.config for build triple $BuildPlatform-$BuildArch-$BuildConfig..."
16+
17+
$reader = [System.IO.File]::OpenText($InputFile)
18+
$content = ""
19+
try {
20+
for() {
21+
$line = $reader.ReadLine()
22+
if ($line -eq $null) { break }
23+
# Check if the package is arch/config dependent.
24+
# Note that this will *not* match the generic UWP package containing the generated headers,
25+
# "Microsoft.MixedReality.WebRTC.Native.Core.UWP" (without '.' after 'UWP'), which should
26+
# always be restored on all UWP variants independent of the arch/config.
27+
if ($line -match "Microsoft\.MixedReality\.WebRTC\.Native\.Core\.(Desktop|UWP|WinRT)\.")
28+
{
29+
# Once the package is known to be config/arch-dependent, validate that this is the
30+
# correct arch and config for the current build.
31+
if ($line -match "Microsoft\.MixedReality\.WebRTC\.Native\.Core\.(Desktop|UWP|WinRT)\.$BuildArch\.$BuildConfig")
32+
{
33+
$linePlatform = $Matches.1 # Desktop|UWP|WinRT
34+
if ((($linePlatform -eq 'Desktop') -and ($BuildPlatform -eq 'Win32')) -or (($linePlatform -ne 'Desktop') -and ($BuildPlatform -eq 'UWP')))
35+
{
36+
# Copy line for matching build triple as is
37+
$content += $line + "`n";
38+
}
39+
else
40+
{
41+
# Discard line - mismatching platform
42+
}
43+
}
44+
else
45+
{
46+
# Discard line - mismatching arch/config
47+
}
48+
}
49+
else
50+
{
51+
# Copy any other line as is, including "Microsoft.MixedReality.WebRTC.Native.Core.UWP"
52+
$content += $line + "`n";
53+
}
54+
}
55+
}
56+
finally {
57+
$reader.Close()
58+
}
59+
Write-Output $content | Set-Content -Path $OutputFile -Encoding UTF8
60+
61+
Write-Host "== $OutputFile ======================================="
62+
Get-Content -Encoding UTF8 -Path "$OutputFile"
63+
Write-Host "=========================================================="
64+
65+
# Write the filename of the new packages.config file to $(PackagesConfigFile) for later use
66+
Write-Host "##vso[task.setvariable variable=PackagesConfigFile]$OutputFile"

tools/ci/modifyCppProject.ps1

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Modify the .vcxproj project file to only import the NuGet packages for
2+
# the current build triple, which are the only ones restored.
3+
4+
param(
5+
[ValidateSet('Win32','UWP')]
6+
[string]$BuildPlatform,
7+
[ValidateSet('x86','x64','ARM')]
8+
[string]$BuildArch,
9+
[ValidateSet('Debug','Release')]
10+
[string]$BuildConfig,
11+
[string]$ProjectFile
12+
)
13+
14+
Write-Host "Modifying .vcxproj for build triple $BuildPlatform-$BuildArch-$BuildConfig..."
15+
16+
$reader = [System.IO.File]::OpenText($ProjectFile)
17+
$content = ""
18+
try {
19+
for() {
20+
$line = $reader.ReadLine()
21+
if ($line -eq $null) { break }
22+
if ($line -match "Import Project=")
23+
{
24+
if ($line -match "packages\\Microsoft\.MixedReality\.WebRTC\.Native\.Core\.(Desktop|UWP|WinRT)\.(x86|x64|ARM)\.(Debug|Release)")
25+
{
26+
$linePlatform = $Matches.1 # Desktop|UWP|WinRT
27+
$lineArch = $Matches.2 # x86|x64|ARM
28+
$lineConfig = $Matches.3 #Debug|Release
29+
$matchPlatform = (($linePlatform -eq 'Desktop') -and ($BuildPlatform -eq 'Win32')) -or (($linePlatform -ne 'Desktop') -and ($BuildPlatform -eq 'UWP'))
30+
$matchArch = ($lineArch -eq $BuildArch)
31+
$matchConfig = ($lineConfig -eq $BuildConfig)
32+
if ($matchPlatform -and $matchArch -and $matchConfig)
33+
{
34+
# Copy line for matching build triple as is
35+
$content += $line + "`n";
36+
}
37+
else
38+
{
39+
# Discard line - mismatching platform or arch or config
40+
}
41+
}
42+
else
43+
{
44+
# Copy any other line as is
45+
$content += $line + "`n";
46+
}
47+
}
48+
elseif ($line -match "Error Condition=")
49+
{
50+
if ($line -match "packages\\Microsoft\.MixedReality\.WebRTC\.Native\.Core\.(Desktop|UWP|WinRT)\.(x86|x64|ARM)\.(Debug|Release)")
51+
{
52+
$linePlatform = $Matches.1 # Desktop|UWP|WinRT
53+
$lineArch = $Matches.2 # x86|x64|ARM
54+
$lineConfig = $Matches.3 #Debug|Release
55+
$matchPlatform = (($linePlatform -eq 'Desktop') -and ($BuildPlatform -eq 'Win32')) -or (($linePlatform -ne 'Desktop') -and ($BuildPlatform -eq 'UWP'))
56+
$matchArch = ($lineArch -eq $BuildArch)
57+
$matchConfig = ($lineConfig -eq $BuildConfig)
58+
if ($matchPlatform -and $matchArch -and $matchConfig)
59+
{
60+
# Copy line for matching build triple as is
61+
$content += $line + "`n";
62+
}
63+
else
64+
{
65+
# Discard line - mismatching platform or arch or config
66+
}
67+
}
68+
else
69+
{
70+
# Copy any other line as is
71+
$content += $line + "`n";
72+
}
73+
}
74+
else
75+
{
76+
# Copy any other line as is
77+
$content += $line + "`n";
78+
}
79+
}
80+
}
81+
finally {
82+
$reader.Close()
83+
}
84+
Write-Output $content | Set-Content -Path $ProjectFile -Encoding UTF8
85+
86+
Write-Host "== $ProjectFile ======================================="
87+
Get-Content -Encoding UTF8 -Path "$ProjectFile"
88+
Write-Host "=========================================================="

tools/ci/release-core-nosign.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ pr: none
1414
# Give a unique name to the build each time it runs
1515
name: $(Date:yyyyMMdd)-$(Rev:r)
1616

17-
variables:
18-
# Version string is "$(MRWebRTCVersion)-$(MRWebRTCReleaseTag)-$(Build.BuildId)"
19-
MRWebRTCVersion: 0.0.1 # Major.Minor.Patch
20-
MRWebRTCReleaseTag: 'alpha' # Optional, without '-'
21-
2217
stages:
2318

2419
# Compile all platform/architecture/config variants as separate jobs

0 commit comments

Comments
 (0)