[runtime] Fix off by one with stacktrace rethrow
[mono-project.git] / msvc / winsetup.bat
blobaf5330e9fd0b31f42e873edb45259e2bd6443618
1 @ECHO off
2 SetLocal
4 SET CONFIG_H="%~dp0..\config.h"
5 SET CYG_CONFIG_H="%~dp0..\cygconfig.h"
6 SET WIN_CONFIG_H="%~dp0..\winconfig.h"
7 SET CONFIGURE_AC="%~dp0..\configure.ac"
8 SET VERSION_H="%~dp0..\mono\mini\version.h"
10 ECHO Setting up Mono configuration headers...
12 :: generate unique temp file path
13 uuidgen 2>nul || goto no_uuidgen
14 for /f %%a in ('uuidgen') do set monotemp=%%a
15 goto :got_temp
17 :no_uuidgen
18 :: Random isn't very random or unique. %time% and %date% is not random but fairly unique.
19 set monotemp=%~n0%random%%time%%date%
21 :got_temp
22 :: Remove special characters.
23 set monotemp=%monotemp:-=%
24 set monotemp=%monotemp:\=%
25 set monotemp=%monotemp:/=%
26 set monotemp=%monotemp::=%
27 set monotemp=%monotemp: =%
28 set monotemp=%monotemp:.=%
29 set monotemp=%temp%\monotemp%monotemp%
30 mkdir "%monotemp%\.." 2>nul
31 set monotemp="%monotemp%"
32 echo %monotemp%
34 REM Backup existing config.h into cygconfig.h if its not already replaced.
35 findstr /i /r /c:"#include *\"cygconfig.h\"" %config_h% >nul || copy /y %config_h% %cyg_config_h%
37 :: Extract MONO_VERSION from configure.ac.
38 for /f "delims=[] tokens=2" %%a in ('findstr /b /c:"AC_INIT(mono, [" %CONFIGURE_AC%') do (
39         set MONO_VERSION=%%a
42 :: Split MONO_VERSION into three parts.
43 for /f "delims=. tokens=1-3" %%a in ('echo %MONO_VERSION%') do (
44         set MONO_VERSION_MAJOR=%%a
45         set MONO_VERSION_MINOR=%%b
46         set MONO_VERSION_PATCH=%%c
48 :: configure.ac hardcodes this.
49 set MONO_VERSION_PATCH=00
51 :: Extract MONO_CORLIB_VERSION from configure.ac.
52 for /f "tokens=*" %%a in ('findstr /b /c:MONO_CORLIB_VERSION= %CONFIGURE_AC%') do set %%a
54 :: Pad out version pieces to 2 characters with zeros on left.
55 if "%MONO_VERSION_MAJOR:~1%" == "" set MONO_VERSION_MAJOR=0%MONO_VERSION_MAJOR%
56 if "%MONO_VERSION_MINOR:~1%" == "" set MONO_VERSION_MINOR=0%MONO_VERSION_MINOR%
58 :: Remove every define VERSION from config.h and add what we want.
59 findstr /v /b /i /c:"#define PACKAGE_VERSION " /c:"#define VERSION " /c:"#define MONO_CORLIB_VERSION " %win_config_h% > %monotemp%
60 echo #define PACKAGE_VERSION "%MONO_VERSION%" >> %monotemp%
61 echo #define VERSION "%MONO_VERSION%" >> %monotemp%
62 echo #define MONO_CORLIB_VERSION "%MONO_CORLIB_VERSION%" >> %monotemp%
64 :: If the file is different, replace it.
65 fc %monotemp% %config_h% >nul || move /y %monotemp% %config_h%
66 del %monotemp% 2>nul
68 echo #define FULL_VERSION "Visual Studio built mono" > %monotemp%
69 fc %monotemp% %version_h% || move /y %monotemp% %version_h%
70 del %monotemp% 2>nul
72 :: Log environment variables that start "mono".
73 set MONO
75 ECHO Successfully setup Mono configuration headers.
76 EXIT /b 0