Fossil

Check-in [8fab3e3f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improve error handling. Allow Visual Studio version to be manually overridden. Pass extra arguments to NMAKE. Preserve existing environment and current directory. Miscellaneous style fixes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | buildmsvc
Files: files | file ages | folders
SHA1:8fab3e3f6ccafdb31f291d8287382e5c390c19e1
User & Date: mistachkin 2013-12-17 22:10:50
Context
2013-12-17
22:33
Merge updates from trunk. Closed-Leaf check-in: 7d4f06de user: mistachkin tags: buildmsvc
22:10
Improve error handling. Allow Visual Studio version to be manually overridden. Pass extra arguments to NMAKE. Preserve existing environment and current directory. Miscellaneous style fixes. check-in: 8fab3e3f user: mistachkin tags: buildmsvc
09:25
Merge changes from trunk and update msvc_build.bat for entirely automated build using the latest MSVC version. Closed-Leaf check-in: 555c44eb user: BM tags: msvc_build
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Name change from win/msvc_build.bat to win/buildmsvc.bat.

1
2
3




4


5














6

7



8

9



10

11



12

13



14

15



16

17

18
19



















20


21























22
23


24
25
26
27
28
29



30
31




























32
33
34
35
36
37


38
39
40





















41
42





















@echo off

rem    this batch file tries to compile fossil using the latest available version




rem    of Microsoft Visual Studio that can be found on the machine.

















rem visual studio 2013

SET vsvars32="%VS120COMNTOOLS%\vsvars32.bat"



rem visual studio 2012

IF NOT EXIST %vsvars32% SET vsvars32="%VS110COMNTOOLS%\vsvars32.bat"



rem visual studio 2010

IF NOT EXIST %vsvars32% SET vsvars32="%VS100COMNTOOLS%\vsvars32.bat"



rem visual studio 2008

IF NOT EXIST %vsvars32% SET vsvars32="%VS90COMNTOOLS%\vsvars32.bat"



rem visual studio 2005

IF NOT EXIST %vsvars32% SET vsvars32="%VS80COMNTOOLS%\vsvars32.bat"



rem visual studio 2003 .NET

IF NOT EXIST %vsvars32% SET vsvars32="%VS71COMNTOOLS%\vsvars32.bat"


rem check everything is correct



















IF NOT EXIST %vsvars32% goto:bad_environment


























rem setting environment variables for building with Microsoft Visual C++
call %vsvars32%



rem making build directory
pushd "%~dp0"
cd ..
mkdir msvc_build
cd msvc_build




rem building




























nmake /f "%~dp0\Makefile.msc"

rem leaving
popd
pause
goto:eof



:bad_environment
echo "vsvars32.bat could not be found on this system."





















pause
goto:eof





















|

<
>
>
>
>
|
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
|
>
|
>
>
>
|
>
|
>
>
>
|
>
|
>
>
>
|
>
|
>
>
>
|
>
|
>

<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>
>

<
<
<
<
<
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

<
<
<
<
>
>
|
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109





110
111
112
113

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143




144
145
146


147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
@ECHO OFF


::
:: buildmsvc.bat --
::
:: This batch file attempts to compile Fossil using the latest version
:: Microsoft Visual Studio installed on this machine.
::
::

SETLOCAL

REM SET __ECHO=ECHO
REM SET __ECHO2=ECHO
IF NOT DEFINED _AECHO (SET _AECHO=REM)
IF NOT DEFINED _CECHO (SET _CECHO=REM)
IF NOT DEFINED _VECHO (SET _VECHO=REM)

REM
REM Visual Studio ????
REM
IF DEFINED VSVARS32 IF EXIST "%VSVARS32%" GOTO skip_setVisualStudio

REM
REM Visual Studio 2013
REM
SET VSVARS32=%VS120COMNTOOLS%\vsvars32.bat
IF EXIST "%VSVARS32%" GOTO skip_setVisualStudio

REM
REM Visual Studio 2012
REM
SET VSVARS32=%VS110COMNTOOLS%\vsvars32.bat
IF EXIST "%VSVARS32%" GOTO skip_setVisualStudio

REM
REM Visual Studio 2010
REM
SET VSVARS32=%VS100COMNTOOLS%\vsvars32.bat
IF EXIST "%VSVARS32%" GOTO skip_setVisualStudio

REM
REM Visual Studio 2008
REM
SET VSVARS32=%VS90COMNTOOLS%\vsvars32.bat
IF EXIST "%VSVARS32%" GOTO skip_setVisualStudio

REM
REM Visual Studio 2005
REM
SET VSVARS32=%VS80COMNTOOLS%\vsvars32.bat
IF EXIST "%VSVARS32%" GOTO skip_setVisualStudio

REM
REM Visual Studio 2003
REM
SET VSVARS32=%VS71COMNTOOLS%\vsvars32.bat
IF EXIST "%VSVARS32%" GOTO skip_setVisualStudio


REM
REM NOTE: At this point, the appropriate Visual Studio version should be
REM       selected.
REM
:skip_setVisualStudio

REM
REM NOTE: Remove any double-backslash sequences that may be present in the
REM       selected Visual Studio common tools path.  This is not strictly
REM       necessary; however, it makes reading the output easier.
REM
SET VSVARS32=%VSVARS32:\\=\%

%_VECHO% VsVars32 = '%VSVARS32%'

REM
REM NOTE: Verify that the specified Visual Studio environment batch file
REM       exists.
REM
IF NOT EXIST "%VSVARS32%" (
  ECHO Visual Studio environment batch file "%VSVARS32%" does not exist.
  GOTO errors
)

REM
REM NOTE: Setup local environment variables that point to the root directory
REM       of the Fossil source checkout and to the directory containing this
REM       build tool.
REM
SET ROOT=%~dp0\..
SET ROOT=%ROOT:\\=\%

SET TOOLS=%~dp0
SET TOOLS=%TOOLS:~0,-1%

%_VECHO% Root = '%ROOT%'
%_VECHO% Tools = '%TOOLS%'

REM
REM NOTE: After this point, a clean ERRORLEVEL is required; therefore, make
REM       sure it is reset now.
REM
CALL :fn_ResetErrorLevel

REM
REM NOTE: Attempt to call the selected batch file to setup the environment
REM       variables for building with MSVC.

REM
%__ECHO3% CALL "%VSVARS32%"






IF ERRORLEVEL 1 (
  ECHO Visual Studio environment batch file "%VSVARS32%" failed.
  GOTO errors
)


REM
REM NOTE: Attempt to create the build output directory, if necessary.
REM
IF NOT EXIST "%ROOT%\msvcbld" (
  %__ECHO% MKDIR "%ROOT%\msvcbld"

  IF ERRORLEVEL 1 (
    ECHO Could not make directory "%ROOT%\msvcbld".
    GOTO errors
  )
)

REM
REM NOTE: Attempt to change to the created build output directory so that
REM       the generated files will be placed there.
REM
%__ECHO2% PUSHD "%ROOT%\msvcbld"

IF ERRORLEVEL 1 (
  ECHO Could not change to directory "%ROOT%\msvcbld".
  GOTO errors
)

REM
REM NOTE: Attempt to execute NMAKE for the Fossil MSVC makefile, passing
REM       anything extra from our command line along (e.g. extra options).
REM
%__ECHO% nmake /f "%TOOLS%\Makefile.msc" %*





IF ERRORLEVEL 1 (
  GOTO errors
)



REM
REM NOTE: Attempt to restore the previously saved directory.
REM
%__ECHO2% POPD

IF ERRORLEVEL 1 (
  ECHO Could not restore directory.
  GOTO errors
)

GOTO no_errors

:fn_ResetErrorLevel
  VERIFY > NUL
  GOTO :EOF

:fn_SetErrorLevel
  VERIFY MAYBE 2> NUL
  GOTO :EOF

:usage

  ECHO.
  ECHO Usage: %~nx0 [...]
  ECHO.
  GOTO errors

:errors
  CALL :fn_SetErrorLevel
  ENDLOCAL
  ECHO.
  ECHO Build failure, errors were encountered.
  GOTO end_of_file

:no_errors
  CALL :fn_ResetErrorLevel
  ENDLOCAL
  ECHO.
  ECHO Build success, no errors were encountered.
  GOTO end_of_file

:end_of_file
%__ECHO% EXIT /B %ERRORLEVEL%