"Fossies" - the Fresh Open Source Software Archive

Member "src/Driver/BuildDriver.cmd" (10 Oct 2018, 4859 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) MS DOS Batch source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ::
    2 :: Derived from source code of TrueCrypt 7.1a, which is
    3 :: Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4 :: by the TrueCrypt License 3.0.
    5 ::
    6 :: Modifications and additions to the original source code (contained in this file)
    7 :: and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8 :: and are governed by the Apache License 2.0 the full text of which is
    9 :: contained in the file License.txt included in VeraCrypt binary and source
   10 :: code distribution packages.
   11 ::
   12 
   13 :: Usage: BuildDriver <-build|-rebuild|-clean> <-release|-debug> <-x86|-x64> <dir1> [dir2] ...
   14 
   15 @echo off
   16 set TC_ARG_CMD=%~1
   17 shift
   18 set TC_ARG_TYPE=%~1
   19 shift
   20 set TC_ARG_ARCH=%~1
   21 shift
   22 
   23 
   24 :: Windows Driver Kit build number
   25 
   26 set TC_WINDDK_BUILD=7600.16385.1
   27 
   28 
   29 :: Check for spaces in the current directory path
   30 
   31 cd | find " " >NUL:
   32 
   33 if %ERRORLEVEL% == 0 (
   34     echo BuildDriver.cmd: error: MS Build does not support building of projects stored in a path containing spaces. >&2
   35     exit /B 1
   36 )
   37 
   38 
   39 :: Build options
   40 
   41 set TC_C_DEFINES=-D_WIN32 -DTC_WINDOWS_DRIVER
   42 set TC_C_FLAGS=-nologo -I..
   43 set TC_C_WARNING_LEVEL=-W4
   44 set TC_C_DISABLED_WARNINGS=-wd4057 -wd4100 -wd4127 -wd4152 -wd4201 -wd4701 -wd4702 -wd4706
   45 set TC_LIBRARIAN_FLAGS=-nologo
   46 set TC_LINKER_FLAGS=-nologo
   47 set TC_TEST_SIGN=0
   48 
   49 
   50 :: Windows Driver Kit root
   51 
   52 set TC_WINDDK_ROOT=%SYSTEMDRIVE%\WinDDK\%TC_WINDDK_BUILD%
   53 if exist "%TC_WINDDK_ROOT%\bin\setenv.bat" goto ddk_found
   54 
   55 set TC_WINDDK_ROOT=%WINDDK_ROOT%\%TC_WINDDK_BUILD%
   56 if exist "%TC_WINDDK_ROOT%\bin\setenv.bat" goto ddk_found
   57 
   58 set TC_WINDDK_ROOT=%WINDDK_ROOT%
   59 if exist "%TC_WINDDK_ROOT%\bin\setenv.bat" goto ddk_found
   60 
   61 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
   62 exit /B 1
   63 
   64 :ddk_found
   65 
   66 
   67 :: CPU architecture
   68 
   69 if "%TC_ARG_ARCH%"=="-x64" (
   70     set TC_BUILD_ARCH=x64 WNET
   71     set TC_BUILD_ARCH_DIR=amd64
   72     set TC_ARCH=x64
   73     set TC_ARCH_SUFFIX=-x64
   74     set TC_C_DISABLED_WARNINGS=%TC_C_DISABLED_WARNINGS% -wd4328 -wd4366
   75     set TC_LINKER_FLAGS=%TC_LINKER_FLAGS% -LTCG
   76     if defined TC_KERNEL_TEST_CERTIFICATE_NAME set TC_TEST_SIGN=1
   77 ) else (
   78     set TC_BUILD_ARCH=WXP
   79     set TC_BUILD_ARCH_DIR=i386
   80     set TC_ARCH=x86
   81     set TC_ARCH_SUFFIX=
   82 )
   83 
   84 
   85 :: Build type
   86 
   87 if "%TC_ARG_TYPE%"=="-debug" (
   88     set TC_BUILD_TYPE=chk
   89     set TC_C_DEFINES=%TC_C_DEFINES% -DDEBUG -D_DEBUG
   90     set TC_BUILD_ALT_DIR=_driver_debug
   91     set TC_COPY_DIR="..\Debug"
   92 ) else (
   93     set TC_BUILD_TYPE=fre
   94     set TC_BUILD_ALT_DIR=_driver_release
   95     set TC_COPY_DIR="..\Release"
   96     set TC_TEST_SIGN=0
   97 )
   98 
   99 
  100 :: WDK environment
  101 
  102 pushd .
  103 call %TC_WINDDK_ROOT%\bin\setenv %TC_WINDDK_ROOT% %TC_BUILD_TYPE% %TC_BUILD_ARCH% no_oacr || exit /B %errorlevel%
  104 popd
  105 
  106 :: set path to VC++ 2010
  107 IF EXIST "%programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit)
  108 
  109 :32-Bit
  110 @set "VCPATH=%programfiles%\Microsoft Visual Studio 10.0\"
  111 GOTO CONTINUE
  112 
  113 :64-Bit
  114 @set "VCPATH=%programfiles(x86)%\Microsoft Visual Studio 10.0\"
  115 GOTO CONTINUE
  116 
  117 :CONTINUE
  118 
  119 if "%TC_ARG_ARCH%"=="-x64" (
  120     @set "PATH=%VCPATH%Common7\IDE;%VCPATH%VC\bin\amd64;%PATH%"
  121 ) else (
  122     @set "PATH=%VCPATH%Common7\IDE;%VCPATH%VC\bin;%PATH%"
  123 )
  124 
  125 :: Build
  126 
  127 if "%TC_ARG_CMD%"=="-rebuild" (set TC_BUILD_OPTS=-c -Z)
  128 
  129 pushd .
  130 :build_dirs
  131 
  132     if "%~1"=="" goto done
  133     cd /D "%~1" || exit /B %errorlevel%
  134 
  135     if "%TC_ARG_CMD%"=="-clean" (
  136         rd /s /q obj%TC_BUILD_ALT_DIR%\%TC_BUILD_ARCH_DIR% 2>NUL:
  137         rd /q obj%TC_BUILD_ALT_DIR% 2>NUL:
  138     ) else (
  139 
  140         set USER_C_FLAGS=%TC_C_FLAGS% %TC_C_DISABLED_WARNINGS% -FAcs -Fa%~1\obj%TC_BUILD_ALT_DIR%\%TC_BUILD_ARCH_DIR%\
  141         set MSC_WARNING_LEVEL=%TC_C_WARNING_LEVEL%
  142         set C_DEFINES=%TC_C_DEFINES%
  143         set RCOPTIONS=/I %MFC_INC_PATH%
  144         set LIBRARIAN_FLAGS=%TC_LIBRARIAN_FLAGS%
  145         set LINKER_FLAGS=%TC_LINKER_FLAGS%
  146         set BUILD_ALT_DIR=%TC_BUILD_ALT_DIR%
  147 
  148         build %TC_BUILD_OPTS% -w -nmake /S -nmake /C 2>build_errors.log 1>&2
  149 
  150         if errorlevel 1 (
  151             type build_errors.log
  152             type build_errors_asm.log 2>NUL:
  153             exit /B 1
  154         )
  155         del /q build_errors.log build_errors_asm.log build%BUILD_ALT_DIR%.* 2>NUL:
  156     )
  157 
  158     shift
  159 
  160 goto build_dirs
  161 :done
  162 popd
  163 
  164 
  165 if "%TC_ARG_CMD%"=="-clean" exit /B 0
  166 
  167 md "%TC_COPY_DIR%\Setup Files" >NUL: 2>NUL:
  168 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:
  169 
  170 if errorlevel 1 (
  171     echo BuildDriver.cmd: error: Cannot copy target. >&2
  172     exit /B 1
  173 )
  174 
  175 if %TC_TEST_SIGN% equ 1 (
  176     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:
  177 
  178     if errorlevel 1 (
  179         echo BuildDriver.cmd: error: Cannot test-sign target. >&2
  180         exit /B 1
  181     )
  182 )
  183 
  184 exit /B 0