Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

295 lines
8.6 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM drvcabck.cmd
  5. REM Generates drvindex.inf files for each sku
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. if defined _CPCMAGIC goto CPCBegin
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. sub Usage { print<<USAGE; exit(1) }
  20. drvcabck [-l <language>]
  21. Generates drvindex.inf files for each sku
  22. USAGE
  23. parseargs('?' => \&Usage);
  24. # *** NEXT FEW LINES ARE TEMPLATE ***
  25. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  26. __END__
  27. :CPCBegin
  28. set _CPCMAGIC=
  29. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  30. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  31. REM 1. Go to the %_nttree% (binaries) directory and link *.inf to the %_nttree%\congeal_scripts\drvgen directory
  32. REM 2. Then do the same to the product specific *.inf i.e. srvinf\*.inf entinf\*.inf etc.
  33. REM In this case link them again to %_nttree%\congeal_scripts\drvgen except we prepend the product specific tag
  34. REM i.e. srvinf\1394.inf -> srvinf1394.inf in that directory
  35. REM 3. Then run drvlist on the %_nttree%\congeal_scripts\drvgen directory (approx. 5 mins) to come out with a sorted.lst of all drivers in the infs.
  36. REM 4. Run cabcheck.exe taking as input sorted.lst and the prod specific layout.inf for each product to give you the generated prod specific drvindex.gen.
  37. REM 5. Finally generate excdosnt.inf and copy drvindex.inf to the binaries directory.
  38. REM
  39. REM Note that winnt32/winnt is not smart enough to not copy files present in the driver cab
  40. REM when processing the [Files] section. However, it will still look for files when looking at
  41. REM BootFiles or the other sections associated with boot files.
  42. REM preconditions
  43. REM 1. infs have been generated in all binaries directories (srvinf, etc.)
  44. REM BUGBUG "myarchitecture" is used inconsistantly below and should probably be removed
  45. REM cksku without -a defaults to _BuildArch
  46. REM ArchSwitch is based on _BuildArch
  47. REM Define "myarchitecture" as the architecture that we're processing.
  48. REM
  49. REM we use the %_BuildArch% variable if it's set, otherwise we fall back on
  50. REM %PROCESSOR_ARCHITECTURE%
  51. REM
  52. if not defined myarchitecture (
  53. if defined _BuildArch (
  54. set myarchitecture=%_BuildArch%
  55. ) else (
  56. set myarchitecture=%PROCESSOR_ARCHITECTURE%
  57. )
  58. )
  59. if not defined myarchitecture (
  60. call errmsg.cmd "variable myarchitecture not defined."
  61. goto end
  62. )
  63. set DrvListSwitch=-s
  64. if /i "%_BuildArch%" == "x86" (
  65. set ArchSwitch=i
  66. set DrvListSwitch=-a 0
  67. )
  68. if /i "%_BuildArch%" == "amd64" (
  69. set ArchSwitch=a
  70. set DrvListSwitch=-a 6
  71. )
  72. if /i "%_BuildArch%" == "ia64" (
  73. set ArchSwitch=m
  74. set DrvListSwitch=-a 6
  75. )
  76. if "%DrvListSwitch%" == "-s" (
  77. call errmsg.cmd Need to add DrvListSwitch for %_BuildArch%
  78. goto end
  79. )
  80. echo %myarchitecture%
  81. echo binaries = %_NTPostBld%
  82. REM Verify existence of build directory
  83. pushd .
  84. call ExecuteCmd.cmd "if not exist %_NTPostBld%\congeal_scripts\drvgen md %_NTPostBld%\congeal_scripts\drvgen"
  85. set scratchdir=%_NTPostBld%\congeal_scripts\drvgen
  86. cd /d %_NTPostBld%\congeal_scripts\drvgen
  87. cd
  88. call ExecuteCmd.cmd "if exist ** del /f /q **"
  89. if errorlevel 1 popd& goto end
  90. REM Cleanup infs in proper temp subdirectory
  91. call ExecuteCmd.cmd "if not exist %scratchdir%\%lang%\%myarchitecture% md %scratchdir%\%lang%\%myarchitecture%"
  92. if errorlevel 1 popd& goto end
  93. call ExecuteCmd.cmd "if exist %scratchdir%\%lang%\%myarchitecture%\*.inf del /q /f %scratchdir%\%lang%\%myarchitecture%\*.inf 2>nul"
  94. REM Get the product flavors (per, bla, sbs, srv, ent, dtc) for the given language.
  95. REM wks is applicable to all languages.
  96. set prods=
  97. set dirs=
  98. perl %RazzleToolPath%\cksku.pm -t:per -l:%lang%
  99. if %errorlevel% EQU 0 (
  100. set prods=%prods% per
  101. set _PER=1
  102. set dirs=%dirs% /relpath:perinf
  103. )
  104. perl %RazzleToolPath%\cksku.pm -t:bla -l:%lang%
  105. if %errorlevel% EQU 0 (
  106. set prods=%prods% bla
  107. set _BLA=1
  108. set dirs=%dirs% /relpath:blainf
  109. )
  110. perl %RazzleToolPath%\cksku.pm -t:sbs -l:%lang%
  111. if %errorlevel% EQU 0 (
  112. set prods=%prods% sbs
  113. set _SBS=1
  114. set dirs=%dirs% /relpath:sbsinf
  115. )
  116. perl %RazzleToolPath%\cksku.pm -t:srv -l:%lang%
  117. if %errorlevel% EQU 0 (
  118. set prods=%prods% srv
  119. set _SRV=1
  120. set dirs=%dirs% /relpath:srvinf
  121. )
  122. perl %RazzleToolPath%\cksku.pm -t:ads -l:%lang%
  123. if %errorlevel% EQU 0 (
  124. set prods=%prods% ent
  125. set _ENT=1
  126. set dirs=%dirs% /relpath:entinf
  127. )
  128. perl %RazzleToolPath%\cksku.pm -t:dtc -l:%lang%
  129. if %errorlevel% EQU 0 (
  130. set prods=%prods% dtc
  131. set _DTC=1
  132. set dirs=%dirs% /relpath:dtcinf
  133. )
  134. cd /d %Razzletoolpath%\postbuildscripts
  135. cd
  136. set cmdline=
  137. set cmdline=/cmd1:"drvlist.exe %DrvListSwitch% %scratchdir%\%lang%\%myarchitecture% | sort /o %scratchdir%\%lang%\%myarchitecture%\sorted.lst"
  138. set scriptcmd=
  139. set scriptcmd=%Razzletoolpath%\postbuildscripts\drvmk.pl /fl:%scratchdir%\%lang%\%myarchitecture%\inf.lst /mk:%scratchdir%\%lang%\%myarchitecture%\drvmk /path:%_NTPostBld% %dirs% %cmdline% /t:%scratchdir%\%lang%\%myarchitecture%
  140. echo %scriptcmd%
  141. perl %scriptcmd%
  142. if errorlevel 1 (
  143. call errmsg.cmd "Failed running %scriptcmd% - Run tools\postbuildscripts\drvcabck by itself to debug."
  144. popd
  145. goto end
  146. )
  147. REM Copy the files in binaries\inf to the temp location prepending a qualifier so
  148. REM we have all infs across products in one place and can run drvlist.exe collectively
  149. REM We use the earlier generated inf.lst for this
  150. for /F "eol=; tokens=1,2 delims=, " %%i in (%scratchdir%\%lang%\%myarchitecture%\inf.lst) do (
  151. copy /y %%i %scratchdir%\%lang%\%myarchitecture%\%%j
  152. if errorlevel 1 popd& goto end
  153. )
  154. REM kickoff drvlist
  155. REM Fix the registry first to speedup setupapi when running drvlist.exe (supress logging)
  156. call regini %Razzletoolpath%\postbuildscripts\setup_log.txt
  157. cd /d %scratchdir%\%lang%\%myarchitecture%
  158. if errorlevel 1 (
  159. call errmsg.cmd "Failed to cd into %scratchdir%\%lang%\%myarchitecture%"
  160. popd
  161. goto end
  162. )
  163. call logmsg.cmd /t "Starting drvlist through nmake"
  164. call ExecuteCmd.cmd "nmake -f drvmk"
  165. if errorlevel 1 (
  166. call errmsg.cmd "Failed nmake of makefile drvmk in %scratchdir%\%lang%\%myarchitecture%"
  167. popd
  168. goto end
  169. )
  170. call logmsg.cmd /t "drvlist is complete."
  171. cd /d %Razzletoolpath%\postbuildscripts
  172. cd
  173. if not exist %scratchdir%\%lang%\%myarchitecture%\sorted.lst (
  174. call errmsg.cmd /t "%scratchdir%\%lang%\%myarchitecture%\Sorted.lst not created. Drvlist failure."
  175. popd
  176. goto end
  177. )
  178. REM Call cabcheck.exe to generate the drvindex.inf that we think is right
  179. REM WKS - The workstation case
  180. call ExecuteCmd.cmd "cabcheck.exe %scratchdir%\%lang%\%myarchitecture%\layout.inf %scratchdir%\%lang%\%myarchitecture%\Sorted.lst %scratchdir%\%lang%\%myarchitecture%\drvindex.gen /%ArchSwitch%"
  181. if errorlevel 1 (
  182. call errmsg.cmd "Cabcheck.exe Failed to auto-generate the drvindex.inf file"
  183. popd
  184. goto end
  185. )
  186. REM Copy the generated files to its final location.
  187. call ExecuteCmd.cmd "copy /Y %scratchdir%\%lang%\%myarchitecture%\drvindex.gen %_NTPostBld%\drvindex.inf"
  188. if errorlevel 1 (
  189. call errmsg.cmd "Could not copy generated drvindex.inf to %_NTPostBld%"
  190. popd
  191. goto end
  192. )
  193. REM generate the appropriate excdosnt.inf
  194. call ExecuteCmd.cmd "xdosnet %_NTPostBld%\layout.inf %_NTPostBld%\drvindex.inf 1 %scratchdir%\%lang%\%myarchitecture%\foodosnt %myarchitecture% %_NTPostBld%\excdosnt.inf %_NTPostBld%\exclude.inf"
  195. REM Now do the other products - PER BLA SBS SRV ENT DTC
  196. for %%i in (%prods%) do (
  197. call ExecuteCmd.cmd "cabcheck.exe %scratchdir%\%lang%\%myarchitecture%\%%iinflayout.inf %scratchdir%\%lang%\%myarchitecture%\Sorted.lst %scratchdir%\%lang%\%myarchitecture%\%%iinfdrvindex.gen /%ArchSwitch%"
  198. if errorlevel 1 (
  199. call errmsg.cmd "Cabcheck.exe Failed to auto-generate the drvindex.inf file"
  200. popd
  201. goto end
  202. )
  203. REM Copy the generated files to its final location.
  204. call ExecuteCmd.cmd "copy /Y %scratchdir%\%lang%\%myarchitecture%\%%iinfdrvindex.gen %_NTPostBld%\%%iinf\drvindex.inf"
  205. if errorlevel 1 (
  206. call errmsg.cmd "Could not copy generated %%idrvindex.inf to %_NTPostBld%\%%iinf"
  207. popd
  208. goto end
  209. )
  210. REM generate the appropriate excdosnt.inf
  211. call ExecuteCmd.cmd "xdosnet %_NTPostBld%\%%iinf\layout.inf %_NTPostBld%\%%iinf\drvindex.inf 1 %scratchdir%\%lang%\%myarchitecture%\foodosnt %myarchitecture% %_NTPostBld%\%%iinf\excdosnt.inf %_NTPostBld%\%%iinf\exclude.inf"
  212. )
  213. cd
  214. call logmsg.cmd /t "drvindex.inf generation complete"
  215. goto end
  216. :end
  217. seterror.exe "%errors%"& goto :EOF