Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Krell <jay.krell@cornell.edu>2018-06-14 17:07:45 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2018-06-14 17:07:45 +0300
commit15a40b60b9911916be97d110ffa1d5ef56b42ace (patch)
treed591b52786cce84e08517cd3e6c50f69e294b66a /msvc/winsetup.bat
parent927ae9570216b7fa21d7bc1900d2b1751f20b4f3 (diff)
Replace powershell in winsetup.bat with pure batch script (#9093)
This reduces our dependency on powershell.
Diffstat (limited to 'msvc/winsetup.bat')
-rwxr-xr-xmsvc/winsetup.bat87
1 files changed, 66 insertions, 21 deletions
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