Merge pull request #2972 from lateralusX/jlorenss/vs2015-upgrade
[mono.git] / msvc / compare-config-files.ps1
1 ##############################################################################
2 ##
3 ## compare-config-files
4 ##
5 ##############################################################################
6
7 <#
8
9 .SYNOPSIS
10
11 Compares mono build configuration files detecting incompatible changes.
12
13 #>
14
15 param(
16     ## winconfig header file.
17     $mono_winconfig,
18
19     ## config header file.
20     $mono_config,
21
22         ## The master configuration file, optional.
23         $mono_config_ac
24 )
25
26 ## Get the content from each config file
27 $mono_winconfig_content = Get-Content $mono_winconfig
28 $mono_config_content = Get-Content $mono_config
29
30 ## Compare config files.
31 $comparedLines = Compare-Object $mono_winconfig_content $mono_config_content -IncludeEqual | Sort-Object { $_.InputObject.ReadCount }
32
33 $comparedLines | foreach {
34
35     if($_.SideIndicator -ne "==")
36     {
37                 ##Look for diffs.
38                 $mono_version = (Select-String -InputObject $_.InputObject -pattern '#define VERSION \"(.*)\"')
39                 if ($mono_version -eq $null) {
40                         Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced."
41                         exit 1;
42                 }
43     }
44 }
45
46 if ($mono_config_ac -ne $null -And $mono_config_ac -ne "") {
47
48         $mono_version_ac = (Select-String -path $mono_config_ac -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value
49         $mono_version = (Select-String -path $mono_config -pattern '#define VERSION \"(.*)\"').Matches[0].Groups[1].Value
50
51         if($mono_version_ac -ne $mono_version)
52         {
53                 Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced."
54                 exit 1;
55         }
56 }
57
58 exit 0;