diff options
author | Jay Krell <jay.krell@cornell.edu> | 2018-06-14 17:07:45 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-06-14 17:07:45 +0300 |
commit | 15a40b60b9911916be97d110ffa1d5ef56b42ace (patch) | |
tree | d591b52786cce84e08517cd3e6c50f69e294b66a /msvc | |
parent | 927ae9570216b7fa21d7bc1900d2b1751f20b4f3 (diff) |
Replace powershell in winsetup.bat with pure batch script (#9093)
This reduces our dependency on powershell.
Diffstat (limited to 'msvc')
-rw-r--r-- | msvc/backup-config-files.ps1 | 32 | ||||
-rw-r--r-- | msvc/compare-config-content.ps1 | 51 | ||||
-rw-r--r-- | msvc/compare-config-files.ps1 | 59 | ||||
-rwxr-xr-x | msvc/winsetup.bat | 87 |
4 files changed, 66 insertions, 163 deletions
diff --git a/msvc/backup-config-files.ps1 b/msvc/backup-config-files.ps1 deleted file mode 100644 index 691968ec307..00000000000 --- a/msvc/backup-config-files.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -############################################################################## -## -## backup-config-files -## -############################################################################## - -<# - -.SYNOPSIS - -Backup mono build configuration files, if needed. - -#> - -param( - - ## config header file. - $mono_config, - - ## cygconfig header file. - $mono_cygconfig -) - -$include_cygconfig = Get-Content $mono_config | Select-String -pattern '#include[ ]*\"cygconfig.h\"[ ]*' -if($include_cygconfig -eq $null) -{ - ## Backup mono_config into mono_cygconfig, overweiring any existing file. - Write-Host "Backup " $mono_config " -> " $mono_cygconfig - Copy-Item $mono_config $mono_cygconfig -Force -} - -exit 0; diff --git a/msvc/compare-config-content.ps1 b/msvc/compare-config-content.ps1 deleted file mode 100644 index 0ed84ba3a05..00000000000 --- a/msvc/compare-config-content.ps1 +++ /dev/null @@ -1,51 +0,0 @@ -############################################################################## -## -## compare-config-content -## -############################################################################## - -<# - -.SYNOPSIS - -Compares mono build configuration content detecting diff's. - -#> - -param( - ## first config source to compare. - $mono_config_source1, - - ## second config source to compare. - $mono_config_source2 -) - -if ((Test-Path -isvalid $mono_config_source1) -And (Test-Path $mono_config_source1)) -{ - $mono_config_source1_content = Get-Content $mono_config_source1 -} -else -{ - $mono_config_source1_content = $mono_config_source1 -} - -if ((Test-Path -isvalid $mono_config_source2) -And (Test-Path $mono_config_source2)) -{ - $mono_config_source2_content = Get-Content $mono_config_source2 -} -else -{ - $mono_config_source2_content = $mono_config_source2 -} - -## Compare content. -$comparedLines = Compare-Object $mono_config_source1_content $mono_config_source2_content -IncludeEqual | Sort-Object { $_.InputObject.ReadCount } -$comparedLines | foreach { - if($_.SideIndicator -ne "==") - { - Write-Host "Changes detected." - exit 1; - } -} - -exit 0;
\ No newline at end of file diff --git a/msvc/compare-config-files.ps1 b/msvc/compare-config-files.ps1 deleted file mode 100644 index 72667c0324b..00000000000 --- a/msvc/compare-config-files.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -############################################################################## -## -## compare-config-files -## -############################################################################## - -<# - -.SYNOPSIS - -Compares mono build configuration files detecting incompatible changes. - -#> - -param( - ## winconfig header file. - $mono_winconfig, - - ## config header file. - $mono_config, - - ## The master configuration file, optional. - $mono_config_ac -) - -## Get the content from each config file -$mono_winconfig_content = Get-Content $mono_winconfig -$mono_config_content = Get-Content $mono_config - -## Compare config files. -$comparedLines = Compare-Object $mono_winconfig_content $mono_config_content -IncludeEqual | Sort-Object { $_.InputObject.ReadCount } - -$comparedLines | foreach { - - if($_.SideIndicator -ne "==") - { - ##Look for diffs. - $mono_version = (Select-String -InputObject $_.InputObject -pattern '#define VERSION \"(.*)\"') - $mono_corlib_version = (Select-String -InputObject $_.InputObject -pattern '#define MONO_CORLIB_VERSION') - if ($mono_version -eq $null -And $mono_corlib_version -eq $null) { - Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced." - exit 1; - } - } -} - -if ($mono_config_ac -ne $null -And $mono_config_ac -ne "") { - - $mono_version_ac = (Select-String -path $mono_config_ac -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value - $mono_version = (Select-String -path $mono_config -pattern '#define VERSION \"(.*)\"').Matches[0].Groups[1].Value - - if($mono_version_ac -ne $mono_version) - { - Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced." - exit 1; - } -} - -exit 0; diff --git a/msvc/winsetup.bat b/msvc/winsetup.bat index a8359cd4cad..6013e17da09 100755 --- a/msvc/winsetup.bat +++ b/msvc/winsetup.bat @@ -1,35 +1,80 @@ -@ECHO off - -SET CONFIG_H=..\config.h -SET CYG_CONFIG_H=..\cygconfig.h -SET WIN_CONFIG_H=..\winconfig.h -SET CONFIGURE_AC=..\configure.ac -SET VERSION_H=..\mono\mini\version.h +SetLocal +SET CONFIG_H="%~dp0..\config.h" +SET CYG_CONFIG_H="%~dp0..\cygconfig.h" +SET WIN_CONFIG_H="%~dp0..\winconfig.h" +SET CONFIGURE_AC="%~dp0..\configure.ac" +SET VERSION_H="%~dp0..\mono\mini\version.h" ECHO Setting up Mono configuration headers... +:: generate unique temp file path +uuidgen 2>nul || goto no_uuidgen +for /f %%a in ('uuidgen') do set monotemp=%%a +goto :got_temp + +:no_uuidgen +:: Random isn't very random or unique. %time% and %date% is not random but fairly unique. +set monotemp=%~n0%random%%time%%date% + +:got_temp +:: Remove special characters. +set monotemp=%monotemp:-=% +set monotemp=%monotemp:\=% +set monotemp=%monotemp:/=% +set monotemp=%monotemp::=% +set monotemp=%monotemp: =% +set monotemp=%monotemp:.=% +set monotemp=%temp%\monotemp%monotemp% +mkdir "%monotemp%\.." 2>nul +set monotemp="%monotemp%" +echo %monotemp% + REM Backup existing config.h into cygconfig.h if its not already replaced. -%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File backup-config-files.ps1 %CONFIG_H% %CYG_CONFIG_H% 2>&1 +findstr /i /r /c:"#include *\"cygconfig.h\"" %config_h% >nul || copy /y %config_h% %cyg_config_h% -%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-files.ps1 %WIN_CONFIG_H% %CONFIG_H% %CONFIGURE_AC% 2>&1 +:: Extract MONO_VERSION from configure.ac. +for /f "delims=[] tokens=2" %%a in ('findstr /b /c:"AC_INIT(mono, [" %CONFIGURE_AC%') do ( + set MONO_VERSION=%%a +) -IF NOT %ERRORLEVEL% == 0 ( - ECHO copy %WIN_CONFIG_H% %CONFIG_H% - copy %WIN_CONFIG_H% %CONFIG_H% - %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -Command "(Get-Content %CONFIG_H%) -replace '#MONO_VERSION#', (Select-String -path %CONFIGURE_AC% -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value | Set-Content %CONFIG_H%" 2>&1 - %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -Command "$mono_version=[int[]](Select-String -path %CONFIGURE_AC% -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value.Split('.'); $corlib_counter=[int](Select-String -path %CONFIGURE_AC% -pattern 'MONO_CORLIB_COUNTER=(.*)').Matches[0].Groups[1].Value; (Get-Content %CONFIG_H%) -replace '#MONO_CORLIB_VERSION#',('1{0:00}{1:00}{2:00}{3:000}' -f $mono_version[0],$mono_version[1],0,$corlib_counter) | Set-Content %CONFIG_H%" 2>&1 +:: Split MONO_VERSION into three parts. +for /f "delims=. tokens=1-3" %%a in ('echo %MONO_VERSION%') do ( + set MONO_VERSION_MAJOR=%%a + set MONO_VERSION_MINOR=%%b + set MONO_VERSION_PATCH=%%c ) +:: configure.ac hardcodes this. +set MONO_VERSION_PATCH=00 -SET VERSION_CONTENT="#define FULL_VERSION \"Visual Studio built mono\"" -%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-content.ps1 %VERSION_CONTENT% %VERSION_H% 2>&1 +:: Extract MONO_CORLIB_COUNTER from configure.ac. +for /f "tokens=*" %%a in ('findstr /b /c:MONO_CORLIB_COUNTER= %CONFIGURE_AC%') do set %%a +:: Pad out version pieces to 2 characters with zeros on left. +:: corlib_counter same but 3 characters. +if "%MONO_VERSION_MAJOR:~1%" == "" set MONO_VERSION_MAJOR=0%MONO_VERSION_MAJOR% +if "%MONO_VERSION_MINOR:~1%" == "" set MONO_VERSION_MINOR=0%MONO_VERSION_MINOR% +if "%MONO_CORLIB_COUNTER:~2%" == "" set MONO_CORLIB_COUNTER=0%MONO_CORLIB_COUNTER% +if "%MONO_CORLIB_COUNTER:~2%" == "" set MONO_CORLIB_COUNTER=0%MONO_CORLIB_COUNTER% -IF NOT %ERRORLEVEL% == 0 ( - ECHO Configure %VERSION_H% - ECHO #define FULL_VERSION "Visual Studio built mono"> %VERSION_H% -) +set MONO_CORLIB_VERSION=1%MONO_VERSION_MAJOR%%MONO_VERSION_MINOR%%MONO_VERSION_PATCH%%MONO_CORLIB_COUNTER% -ECHO Successfully setup Mono configuration headers. +:: Remove every define VERSION from config.h and add what we want. +findstr /v /b /i /c:"#define PACKAGE_VERSION " /c:"#define VERSION " /c:"#define MONO_CORLIB_VERSION " %win_config_h% > %monotemp% +echo #define PACKAGE_VERSION "%MONO_VERSION%" >> %monotemp% +echo #define VERSION "%MONO_VERSION%" >> %monotemp% +echo #define MONO_CORLIB_VERSION %MONO_CORLIB_VERSION% >> %monotemp% + +:: If the file is different, replace it. +fc %monotemp% %config_h% >nul || move /y %monotemp% %config_h% +del %monotemp% 2>nul + +echo #define FULL_VERSION "Visual Studio built mono" > %monotemp% +fc %monotemp% %version_h% || move /y %monotemp% %version_h% +del %monotemp% 2>nul +:: Log environment variables that start "mono". +set MONO + +ECHO Successfully setup Mono configuration headers. EXIT /b 0 |