Merge pull request #5714 from alexischr/update_bockbuild
[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                 $mono_corlib_version = (Select-String -InputObject $_.InputObject -pattern '#define MONO_CORLIB_VERSION')
40                 if ($mono_version -eq $null -And $mono_corlib_version -eq $null) {
41                         Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced."
42                         exit 1;
43                 }
44     }
45 }
46
47 if ($mono_config_ac -ne $null -And $mono_config_ac -ne "") {
48
49         $mono_version_ac = (Select-String -path $mono_config_ac -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value
50         $mono_version = (Select-String -path $mono_config -pattern '#define VERSION \"(.*)\"').Matches[0].Groups[1].Value
51
52         if($mono_version_ac -ne $mono_version)
53         {
54                 Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced."
55                 exit 1;
56         }
57 }
58
59 exit 0;