summaryrefslogtreecommitdiffstats
path: root/tools/libcheck.ps1
blob: 0424aee7ff05106eea2c00d0c2b7abf6285a0b50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
param(
	$OldVersion,
	$NewVersion,
	$Configuration='Debug'
)

function Usage() {
	$ScriptName = Split-Path -leaf $MyInvocation.ScriptName
	Write-Host "$ScriptName -OldVersion <tag> -NewVersion <branch>"
	exit
}

if ($Args -Contains "-?" -or !$OldVersion -or !$NewVersion -or ($OldVersion -eq $NewVersion)) {
	Usage
}

function SetupVariables() {
	$ToolsDir = Split-Path $MyInvocation.ScriptName
	$RootDir = [io.path]::getfullpath((Join-Path $ToolsDir .. -resolve))
	$BinDir = "$RootDir\bin"
	$LibCheckTmpDir = Join-Path ([IO.Path]::GetTempPath()) "LibCheck"
}

function Checkout($Version) {
	git checkout $Version
}

function Build() {
	& "$env:windir\Microsoft.NET\Framework\v3.5\msbuild.exe" "$RootDir\src\DotNetOpenAuth\DotNetOpenAuth.csproj" /p:Configuration=$Configuration /nologo /v:m
}

function Generate-Metadata($Version) {
	Push-Location $LibCheckTmpDir
	& ".\libcheck.exe" -store "DotNetOpenAuth.dll" $Version -full "$BinDir\$Configuration"
	Pop-Location
}

function Compare-Metadata() {
	Push-Location $LibCheckTmpDir
	& ".\libcheck.exe" -compare $OldVersion $NewVersion
	Pop-Location
}

function ShadowCopy-Libcheck() {
	# This function copies LibCheck from the checked out version to a temp
	# directory so that as we git checkout other versions of DotNetOpenAuth,
	# we can be sure of running one consistent version of LibCheck.
	if (Test-Path $LibCheckTmpDir) { Remove-Item -Recurse $LibCheckTmpDir }
	Copy-Item -Recurse "$ToolsDir\LibCheck" (Split-Path $LibCheckTmpDir)
	# As a side benefit, this also puts the results of running LibCheck
	# outside the git repo so it can't get checked in accidentally.
}

. SetupVariables
ShadowCopy-Libcheck
Checkout -version $OldVersion
Build
Generate-Metadata -version $OldVersion
Checkout -version $NewVersion
Build
Generate-Metadata -version $NewVersion
Compare-Metadata
Pop-Location
& "$LibCheckTmpDir\$($OldVersion)to$($NewVersion)\APIChanges$($OldVersion)to$($NewVersion).html"