?? ddkbuild.cmd
字號(hào):
@echo off
@set VERSION=V7.3
@set OSR_DEBUG=off
@if "%OS%"=="Windows_NT" goto :Prerequisites
@echo This script requires Windows NT 4.0 or later to run properly!
goto :EOF
:Prerequisites
:: Check whether FINDSTR is available. It's used to show warnings etc.
findstr /? > NUL 2>&1 || echo "FINDSTR is a prerequisite but wasn't found!" && goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: $Id: ddkbuild.cmd 27 2008-09-06 12:02:06Z oliver $
::
:: This software is supplied for instructional purposes only.
::
:: OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty
:: for this software. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY
:: OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
:: THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR
:: PURPOSE. THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS
:: WITH YOU. OSR's entire liability and your exclusive remedy shall not
:: exceed the price paid for this material. In no event shall OSR or its
:: suppliers be liable for any damages whatsoever (including, without
:: limitation, damages for loss of business profit, business interruption,
:: loss of business information, or any other pecuniary loss) arising out
:: of the use or inability to use this software, even if OSR has been
:: advised of the possibility of such damages. Because some states/
:: jurisdictions do not allow the exclusion or limitation of liability for
:: consequential or incidental damages, the above limitation may not apply
:: to you.
::
:: OSR Open Systems Resources, Inc.
:: 105 Route 101A Suite 19
:: Amherst, NH 03031 (603) 595-6500 FAX: (603) 595-6503
:: report bugs to <bugs@osr.com>
:: alternatively report them via <http://assarbad.net/contact/>
::
::
:: MODULE:
::
:: ddkbuild.cmd
::
:: ABSTRACT:
::
:: This script allows drivers to be built with Visual Studio 2002 through
:: Visual Studio 2008 and possibly future versions. It will also work fine
:: from the command line.
:: If you are interested in a project wizard that makes use of this script,
:: try DDKWizard from <http://ddkwizard.assarbad.net>.
::
:: AUTHOR(S):
::
:: - OSR Open Systems Resources, Inc.
:: - Oliver Schneider (ddkwizard.assarbad.net)
::
:: REQUIREMENTS:
::
:: Environment variables that must be set.
:: %NT4BASE% - Set this up for "-NT4" builds (legacy, support not tested)
:: %W2KBASE% - Set this up for "-W2K*" builds (legacy, support not tested)
:: %WXPBASE% - Set this up for "-WXP*" builds
:: %WNETBASE% - Set this up for "-WNET*" builds
:: %WLHBASE% - Set this up for "-WLH*" builds
:: %WDF_ROOT% - Must be set if attempting to do a WDF Build.
::
:: Examples:
:: NT4BASE : could be "D:\NT4DDK"
:: W2KBASE : could be "D:\Nt50DDK"
:: WXPBASE : could be "D:\WINDDK\2600"
:: WNETBASE: could be "D:\WINDDK\3790.1830" or "C:\WINDDK\3790"
::
:: COMMAND FORMAT:
::
:: Run the script without any parameters to get the whole help content!
:: Note: "-WDF" has been tested with the 01.00.5054 version of the framework
::
:: RETURN CODES AND THEIR MEANING:
::
:: 001 == Unknown build type. Check the <platform> parameter
:: 002 == No WDF_ROOT given using WDF build type.
:: 003 == The DDK-specific base directory variable (NT4BASE, W2KBASE, WXPBASE,
:: WNETBASE) is not set at all and could not be auto-detected!
:: 004 == BASEDIR variable is empty. Check to see that the DDK-specific
:: variable is set correctly (i.e. NT4BASE, W2KBASE, WXPBASE, WNETBASE)
:: 005 == No mode (checked/free) was given. Check the respective parameter!
:: 006 == No DIR or SOURCES file found in the given target directory.
:: 007 == No target directory given.
:: 008 == Given target directory does not exist.
:: 009 == The SETENV script failed.
::
:: Note: If %OSR_ERRCODE% and %ERRORLEVEL% are equal, the return code stems
:: from one of the tools being called during the build process.
::
:: BROWSE FILES:
::
:: This procedure supports the building of BROWSE files to be used by
:: Visual Studio 6 and by Visual Studio.NET However, the BSCfiles created
:: by bscmake for the two are not compatible. When this command procedure
:: runs, it selects the first bscmake.exe found in the path. So, make sure
:: that the correct bscmake.exe is in the path ...
::
:: Note that if using Visual Studio.NET the .BSC must be added to the project
:: in order for the project to be browsed.
:: Another alternative is the VS addon named "Visual Assist X" which will
:: parse the header files - no more need for browse files.
::
:: COMPILERS:
::
:: If you are building NT4 you should really be using the VC6 compiler.
:: Later versions of the DDK now contain the compiler and the linker. This
:: procedure should use the correct compiler.
::
:: GENERAL COMMENTS:
::
:: This procedure has been cleaned up to be modular and easy to understand.
::
:: As of the Server 2003 SP1 DDK DDKBUILD now clears the NO_BROWSE_FILE and
:: NO_BINPLACE environment variables so that users can use these features.
::
:: Starting with the Vista WDK, the output in the respective tool window
:: in VS is in Unicode by default. This garbles the output from DDKBUILD
:: and we therefore clear the environment variable VS_UNICODE_OUTPUT.
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: / MAIN function of the script
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:MAIN
:: Building "stack frame"
setlocal ENABLEEXTENSIONS & pushd .
:: Check whether the REG utility is available
reg /? > NUL 2>&1 && set OSR_REGAVAILABLE=1
:: This is set by client-side keyword substitution
set SVN_REVISION=$Revision: 27 $
:: Extract the revision number from the revision keyword
set SVN_REVISION=%SVN_REVISION:~0,-2%
set SVN_REVISION=%SVN_REVISION:~11%
:: This is set by client-side keyword substitution
set SVN_REVDATE=$Date: 2008-09-06 12:02:06 +0000 (Sat, 06 Sep 2008) $
:: Extract the date from the Date keyword
set SVN_REVDATE=%SVN_REVDATE:~7,10%
set VERSION=%VERSION%/r%SVN_REVISION%
:: Init some special variables
set OSR_VERSTR=OSR DDKBUILD.CMD %VERSION% (%SVN_REVDATE%) - OSR, Open Systems Resources, Inc.
set OSR_PREBUILD_SCRIPT=ddkprebld.cmd
set OSR_POSTBUILD_SCRIPT=ddkpostbld.cmd
set OSR_SETENV_SCRIPT=ddkbldenv.cmd
set OSR_ECHO=@echo DDKBLD:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set error messages
:: Possible codes: 1
set ERR_UnknownBuildType=Unknown type of build. Please recheck parameters.
:: Possible codes: 2
set ERR_NoWdfRoot=WDF_ROOT is not defined, are you using 00.01.5054 or later?
:: Possible codes: 3
set ERR_BaseDirNotSet=To build using type %%OSR_TARGET%% you need to set the %%%%%%BASEDIRVAR%%%%%% environment variable to point to the %%BASEDIROS%% DDK base directory!
:: Possible codes: 4
set ERR_NoBASEDIR=NT4BASE, W2KBASE, WXPBASE and/or WNETBASE environment variable(s) not set. Environment variable(s) must be set by user according to DDK version(s) installed.
:: Possible codes: 5
set ERR_BadMode=^<build type^> must be 'checked', 'free', 'chk' or 'fre' (case-insensitive).
:: Possible codes: 6
set ERR_NoTarget=Target directory must contain a SOURCES or DIRS file.
:: Possible codes: 7, 8
set ERR_NoDir=The ^<directory^> parameter must be a valid directory.
:: Possible codes: 9
set ERR_SetEnvFailed=The SETENV script failed.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Clear the error code variable
set OSR_ERRCODE=0
set prefast_build=0
:: Turn on tracing, use %OSR_TRACE% instead of ECHO
if /i "%OSR_DEBUG%" == "on" (set OSR_TRACE=%OSR_ECHO% [TRACE]) else (set OSR_TRACE=rem)
:: Turn on echoing of current line if %OSR_DEBUG% is set to "on"
@echo %OSR_DEBUG%
:: Output version string
@echo %OSR_VERSTR%
%OSR_TRACE% ^(Current module: ^"%~f0^"^)
@echo.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set the target platform variable
set OSR_TARGET=%~1
:: Remove any dashes in the variable
if not "%OSR_TARGET%" == "" set OSR_TARGET=%OSR_TARGET:-=%
:: Show help if the target parameter is empty after removal of the dashes
if "%OSR_TARGET%" == "" goto :USAGE
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: In the build directory check for this script and call it if it exists.
:: This allows to override any global system variable setting, if desired.
if not "%3" == "" call :GetCustomEnvironment "%~f3"
if not "%OSR_ERRCODE%" == "0" goto :USAGE
:: Additional error handling for better usability
:: These subroutines will also attempt to locate the requested DDK!!!
set OSR_ERRCODE=3
%OSR_TRACE% Checking whether the environment variable for the build type was set
:: Calling as a subroutine has 2 advantages:
:: 1. the script does not quit if the label was not found
:: 2. we return to the line after the call and can check variables there
call :%OSR_TARGET%Check > NUL 2>&1
:: If the BASEDIROS/BASEDIRVAR variable is not defined, it means the subroutine did not exist!
if not DEFINED BASEDIROS call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (BASEDIROS)" & goto :USAGE
if not DEFINED BASEDIRVAR call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (BASEDIRVAR)" & goto :USAGE
if not "%OSR_ERRCODE%" == "0" call :ShowErrorMsg %OSR_ERRCODE% "%ERR_BaseDirNotSet%" & goto :USAGE
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set BASEDIR=%%%BASEDIRVAR%%%
call :ResolveVar BASEDIR
call :MakeShort BASEDIR "%BASEDIR%"
:: Check for existing %BASEDIR%
if "%BASEDIR%" == "" call :ShowErrorMsg 4 "%ERR_NoBASEDIR%" & goto :USAGE
set PATH=%BASEDIR%\bin;%PATH%
%OSR_TRACE% Now jump to the initialization of the commandline
:: Calling as a subroutine has 2 advantages:
:: 1. the script does not quit if the label was not found
:: 2. we return to the line after the call and can check variables there
call :%OSR_TARGET%Build
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%OSR_TRACE% We returned from the variable initialization
if not DEFINED OSR_CMDLINE call :ShowErrorMsg 1 "%ERR_UnknownBuildType% (OSR_CMDLINE)" & goto :USAGE
%OSR_TRACE% Hurrah, all the variables have been initialized, continuing
:: Proceed with common build steps
goto :CommonBuild
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Check whether the parameter makes sense and try to
:: correct it if possible
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: These labels are for compatibility with the respective
:: modes supported by another flavor of DDKBUILD.
:WLH64Check
:WLHA64Check
:WLHXP64Check
:WLHNET64Check
:WLHNETA64Check
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:WLHCheck
:WLHX64Check
:WLHI64Check
:WLHNETX64Check
:WLHNETI64Check
:WLHXPCheck
:WLH2KCheck
:WLHNETCheck
set BASEDIROS=Windows Vista/Windows 2008 Server
set BASEDIRVAR=WLHBASE
:: Compatibility between BUILD and VS ... prevent pipes from being used
%OSR_ECHO% Clearing %%VS_UNICODE_OUTPUT%% ...
set VS_UNICODE_OUTPUT=
:: Return to caller if the BASEDIR is already defined (either customized or global)
if DEFINED %BASEDIRVAR% goto :CommonCheckNoErrorWithReturn
call :DetectBaseDirTemp "6001.18000 6000"
if DEFINED BASEDIRTEMP if exist "%BASEDIRTEMP%" goto :CommonCheckSetVarWithReturn
goto :CommonCheckErrorNotSupportedWithReturn
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: These labels are for compatibility with the respective
:: modes supported by another flavor of DDKBUILD.
:WNETW2KCheck
:WNETA64Check
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:WNET2KCheck
:WNETXPCheck
:WNETXP64Check
:WNET64Check
:WNETI64Check
:WNETAMD64Check
:WNETX64Check
:WNETCheck
set BASEDIROS=Windows 2003 Server
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -