blob: 54677df72a60aad81490e5447d637a3dd8c08fb8 (
plain)
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
|
::
:: Derived from source code of TrueCrypt 7.1a, which is
:: Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
:: by the TrueCrypt License 3.0.
::
:: Modifications and additions to the original source code (contained in this file)
:: and all other portions of this file are Copyright (c) 2013-2017 IDRIX
:: and are governed by the Apache License 2.0 the full text of which is
:: contained in the file License.txt included in VeraCrypt binary and source
:: code distribution packages.
::
:: Usage: BuildDriver <-build|-rebuild|-clean> <-release|-debug> <-x86|-x64> <dir1> [dir2] ...
@echo off
set TC_ARG_CMD=%~1
shift
set TC_ARG_TYPE=%~1
shift
set TC_ARG_ARCH=%~1
shift
:: Windows Driver Kit build number
set TC_WINDDK_BUILD=7600.16385.1
:: Check for spaces in the current directory path
cd | find " " >NUL:
if %ERRORLEVEL% == 0 (
echo BuildDriver.cmd: error: MS Build does not support building of projects stored in a path containing spaces. >&2
exit /B 1
)
:: Build options
set TC_C_DEFINES=-D_WIN32 -DTC_WINDOWS_DRIVER
set TC_C_FLAGS=-nologo -I..
set TC_C_WARNING_LEVEL=-W4
set TC_C_DISABLED_WARNINGS=-wd4057 -wd4100 -wd4127 -wd4152 -wd4201 -wd4701 -wd4702 -wd4706
set TC_LIBRARIAN_FLAGS=-nologo
set TC_LINKER_FLAGS=-nologo
set TC_TEST_SIGN=0
:: Windows Driver Kit root
set TC_WINDDK_ROOT=%SYSTEMDRIVE%\WinDDK\%TC_WINDDK_BUILD%
if exist "%TC_WINDDK_ROOT%\bin\setenv.bat" goto ddk_found
set TC_WINDDK_ROOT=%WINDDK_ROOT%\%TC_WINDDK_BUILD%
if exist "%TC_WINDDK_ROOT%\bin\setenv.bat" goto ddk_found
set TC_WINDDK_ROOT=%WINDDK_ROOT%
if exist "%TC_WINDDK_ROOT%\bin\setenv.bat" goto ddk_found
echo BuildDriver.cmd: error: Windows Driver Development Kit not found in the default directory. Set WINDDK_ROOT environment variable to point to your Windows DDK installation directory. >&2
exit /B 1
:ddk_found
:: CPU architecture
if "%TC_ARG_ARCH%"=="-x64" (
set TC_BUILD_ARCH=x64 WNET
set TC_BUILD_ARCH_DIR=amd64
set TC_ARCH=x64
set TC_ARCH_SUFFIX=-x64
set TC_C_DISABLED_WARNINGS=%TC_C_DISABLED_WARNINGS% -wd4328 -wd4366
set TC_LINKER_FLAGS=%TC_LINKER_FLAGS% -LTCG
if defined TC_KERNEL_TEST_CERTIFICATE_NAME set TC_TEST_SIGN=1
) else (
set TC_BUILD_ARCH=WXP
set TC_BUILD_ARCH_DIR=i386
set TC_ARCH=x86
set TC_ARCH_SUFFIX=
)
:: Build type
if "%TC_ARG_TYPE%"=="-debug" (
set TC_BUILD_TYPE=chk
set TC_C_DEFINES=%TC_C_DEFINES% -DDEBUG -D_DEBUG
set TC_BUILD_ALT_DIR=_driver_debug
set TC_COPY_DIR="..\Debug"
) else (
set TC_BUILD_TYPE=fre
set TC_BUILD_ALT_DIR=_driver_release
set TC_COPY_DIR="..\Release"
set TC_TEST_SIGN=0
)
:: WDK environment
pushd .
call %TC_WINDDK_ROOT%\bin\setenv %TC_WINDDK_ROOT% %TC_BUILD_TYPE% %TC_BUILD_ARCH% no_oacr || exit /B %errorlevel%
popd
:: set path to VC++ 2010
IF EXIST "%programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit)
:32-Bit
@set "VCPATH=%programfiles%\Microsoft Visual Studio 10.0\"
GOTO CONTINUE
:64-Bit
@set "VCPATH=%programfiles(x86)%\Microsoft Visual Studio 10.0\"
GOTO CONTINUE
:CONTINUE
if "%TC_ARG_ARCH%"=="-x64" (
@set "PATH=%VCPATH%Common7\IDE;%VCPATH%VC\bin\amd64;%PATH%"
) else (
@set "PATH=%VCPATH%Common7\IDE;%VCPATH%VC\bin;%PATH%"
)
:: Build
if "%TC_ARG_CMD%"=="-rebuild" (set TC_BUILD_OPTS=-c -Z)
pushd .
:build_dirs
if "%~1"=="" goto done
cd /D "%~1" || exit /B %errorlevel%
if "%TC_ARG_CMD%"=="-clean" (
rd /s /q obj%TC_BUILD_ALT_DIR%\%TC_BUILD_ARCH_DIR% 2>NUL:
rd /q obj%TC_BUILD_ALT_DIR% 2>NUL:
) else (
set USER_C_FLAGS=%TC_C_FLAGS% %TC_C_DISABLED_WARNINGS% -FAcs -Fa%~1\obj%TC_BUILD_ALT_DIR%\%TC_BUILD_ARCH_DIR%\
set MSC_WARNING_LEVEL=%TC_C_WARNING_LEVEL%
set C_DEFINES=%TC_C_DEFINES%
set RCOPTIONS=/I %MFC_INC_PATH%
set LIBRARIAN_FLAGS=%TC_LIBRARIAN_FLAGS%
set LINKER_FLAGS=%TC_LINKER_FLAGS%
set BUILD_ALT_DIR=%TC_BUILD_ALT_DIR%
build %TC_BUILD_OPTS% -w -nmake /S -nmake /C 2>build_errors.log 1>&2
if errorlevel 1 (
type build_errors.log
type build_errors_asm.log 2>NUL:
exit /B 1
)
del /q build_errors.log build_errors_asm.log build%BUILD_ALT_DIR%.* 2>NUL:
)
shift
goto build_dirs
:done
popd
if "%TC_ARG_CMD%"=="-clean" exit /B 0
md "%TC_COPY_DIR%\Setup Files" >NUL: 2>NUL:
copy /B /Y obj%TC_BUILD_ALT_DIR%\%TC_BUILD_ARCH_DIR%\veracrypt.sys "%TC_COPY_DIR%\Setup Files\veracrypt%TC_ARCH_SUFFIX%.sys" >NUL:
if errorlevel 1 (
echo BuildDriver.cmd: error: Cannot copy target. >&2
exit /B 1
)
if %TC_TEST_SIGN% equ 1 (
signtool sign /s "%TC_KERNEL_TEST_CERTIFICATE_STORE%" /n "%TC_KERNEL_TEST_CERTIFICATE_NAME%" "%TC_COPY_DIR%\Setup Files\veracrypt%TC_ARCH_SUFFIX%.sys" >NUL:
if errorlevel 1 (
echo BuildDriver.cmd: error: Cannot test-sign target. >&2
exit /B 1
)
)
exit /B 0
|