Leaked source code of windows server 2003
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.

2119 lines
66 KiB

  1. @echo off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  5. REM -------------------------------------------------------------------------------------------
  6. REM Template for the postbuild scripts:
  7. REM SD Location: %sdxroot%\tools\postbuildscripts
  8. REM
  9. REM (1) Code section description:
  10. REM PreMain - Developer adaptable code. Use this model and add your script params
  11. REM Main - Developer code section. This is where your work gets done.
  12. REM PostMain - Logging support code. No changes should be made here.
  13. REM
  14. REM (2) GetParams.pm - Usage
  15. REM run perl.exe GetParams.pm /? for complete usage
  16. REM
  17. REM (3) Reserved Variables -
  18. REM lang - The specified language. Defaults to USA.
  19. REM logfile - The path and filename of the logs file.
  20. REM logfile_bak - The path and filename of the logfile.
  21. REM errfile - The path and filename of the error file.
  22. REM tmpfile - The path and filename of the temp file.
  23. REM errors - The scripts errorlevel.
  24. REM script_name - The script name.
  25. REM script_args - The arguments passed to the script.
  26. REM CMD_LINE - The script name plus arguments passed to the script.
  27. REM _NTPostBld - Abstracts the language from the files path that
  28. REM postbuild operates on.
  29. REM
  30. REM (4) Reserved Subs -
  31. REM Usage - Use this sub to discribe the scripts usage.
  32. REM ValidateParams - Use this sub to verify the parameters passed to the script.
  33. REM
  34. REM
  35. REM (8) Do not turn echo off, copy the 3 lines from the beginning of the template
  36. REM instead.
  37. REM
  38. REM (9) Use setlocal/endlocal as in this template.
  39. REM
  40. REM (10)Have your changes reviewed by a member of the US build team (ntbusa) and
  41. REM by a member of the international build team (ntbintl).
  42. REM
  43. REM -------------------------------------------------------------------------------------------
  44. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  45. REM Begin PreProcessing Section - Adapt this section but do not remove support
  46. REM scripts or reorder section.
  47. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  48. :PreMain
  49. REM
  50. REM Define SCRIPT_NAME. Used by the logging scripts.
  51. REM Define CMD_LINE. Used by the logging scripts.
  52. REM Define SCRIPT_ARGS. Used by the logging scripts.
  53. REM
  54. for %%i in (%0) do set SCRIPT_NAME=%%~ni.cmd
  55. set CMD_LINE=%script_name% %*
  56. set SCRIPT_ARGS=%*
  57. REM
  58. REM Parse the command line arguments - Add your scripts command line arguments
  59. REM as indicated by brackets.
  60. REM For complete usage run: perl.exe GetParams.pm /?
  61. REM
  62. for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  63. REM call :GetParams -n <add required prams> -o l:<add optional params> -p "lang <add variable names>" %SCRIPT_ARGS%
  64. call :GetParams -o "l:cmt" -p "lang cleanbuild mungepublics runalways" %SCRIPT_ARGS%
  65. if errorlevel 1 goto :End
  66. REM
  67. REM Set up the local enviroment extensions.
  68. REM
  69. call :LocalEnvEx -i
  70. if errorlevel 1 goto :End
  71. REM
  72. REM Validate the command line parameters.
  73. REM
  74. call :ValidateParams
  75. if errorlevel 1 goto :End
  76. REM
  77. REM Execute Main
  78. REM
  79. call :Main
  80. :End_PreMain
  81. goto PostMain
  82. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  83. REM Begin Main code section
  84. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  85. REM (5) Call other executables or command scripts by using:
  86. REM call ExecuteCmd.cmd "<command>"
  87. REM Check for errors by using:
  88. REM if errorlevel 1 ...
  89. REM Note that the executable/script you're calling with ExecuteCmd must return a
  90. REM non-zero value on errors to make the error checking mechanism work.
  91. REM
  92. REM Example
  93. REM call ExecuteCmd.cmd "xcopy /f foo1 foo2"
  94. REM if errorlevel 1 (
  95. REM set errors=%errorlevel%
  96. REM goto end
  97. REM )
  98. REM
  99. REM (6) Log non-error information by using:
  100. REM call logmsg.cmd "<log message>"
  101. REM and log error information by using:
  102. REM call errmsg.cmd "<error message>"
  103. REM
  104. REM (7) Exit from the option routines with
  105. REM set errors=%errorlevel%
  106. REM goto end
  107. REM if errors found during execution and with
  108. REM goto end
  109. REM otherwise.
  110. :Main
  111. REM Main code section
  112. REM <Start your script's code here>
  113. REM
  114. REM Only official build machines need to run this script
  115. REM
  116. set langroot=%_NTPostBld%\symbolcd\%lang%
  117. set symbolcd.txt=%_NTPostBld%\symbolcd\%lang%\symbolcd.txt
  118. set ml=perl %RazzleToolPath%\makelist.pl
  119. REM
  120. REM Munge the public symbol files. We put selected type info in some of the public
  121. REM pdb files so that retail customers can run more debugger commands. Only usa builds
  122. REM have symbols. This needs to be done on all machines that have the symbols, not
  123. REM just the official build machines.
  124. REM
  125. if defined MungePublics (
  126. call :MungePublics
  127. if defined ThereWereErrors goto End_Main
  128. goto end
  129. )
  130. REM Copy in the debugger files
  131. if not exist %_NTPostBld%\dbg\released mkdir %_NTPostBld%\dbg\released
  132. if not exist %_NTPostBld%\dbg\released (
  133. call errmsg.cmd "Cannot create the %_NTPostBld%\dbg\released directory"
  134. call errmsg.cmd "Warning -- the winnt32 #BVT switch won't work."
  135. goto EndCopyDbg2
  136. )
  137. REM Delete this in case the copy from the network failed the first time.
  138. if exist %_NTPostBld%\dbg\released\ntsd.exe del /q %_NTPostBld%\dbg\released\ntsd.exe
  139. ping dbg > nul
  140. if %ERRORLEVEL% == 0 (
  141. if exist \\dbg\privates\stress\uncompressed\%_BuildArch% (
  142. xcopy /secdy \\dbg\privates\stress\uncompressed\%_BuildArch% %_NTPostBld%\dbg\released
  143. goto EndCopyDbg
  144. )
  145. )
  146. ping ntstress > nul
  147. if %ERRORLEVEL% == 0 (
  148. if exist \\ntstress\debuggers\uncompressed\%_BuildArch% (
  149. xcopy /secdy \\ntstress\debuggers\uncompressed\%_BuildArch% %_NTPostBld%\dbg\released
  150. goto EndCopyDbg
  151. )
  152. )
  153. :EndCopyDbg
  154. if not exist %_NTPostBld%\dbg\released\ntsd.exe (
  155. REM Make sure that ntsd.exe is there if the copies failed, so that the #BVT switch won't fail
  156. copy %_NTPostBld%\ntsd.exe %_NTPostBld%\dbg\released\ntsd.exe
  157. if not exist %_NTPostBld%\dbg\released\ntsd.exe (
  158. call errmsg.cmd "Copying the debugger files to %_NTPostBld%\dbg\released failed."
  159. call errmsg.cmd "and copy %_NTPostBld%\ntsd.exe %_NTPostBld%\dbg\released\ntsd.exe failed."
  160. call errmsg.cmd "Warning -- the winnt32 #BVT switch won't work."
  161. )
  162. )
  163. :EndCopyDbg2
  164. REM
  165. REM Coverage builds do not have stripped public symbols
  166. REM so don't check if they are stripped when building the symbolCD
  167. REM
  168. set PUB_SYM_FLAG=/p
  169. if defined _COVERAGE_BUILD (
  170. call logmsg.cmd "Coverage build ... turning off public symbol checking"
  171. set PUB_SYM_FLAG=
  172. )
  173. REM
  174. REM Symbolcd.cmd keeps breaking due to coverage changes
  175. REM and I don't catch them in time because I never build as offical build machine
  176. REM so lets pretend if this test flag is set
  177. REM
  178. if defined _COVERAGE_BUILD_TEST (
  179. call logmsg.cmd "Coverage build test ... treating as offical build machine"
  180. set RunAlways=1
  181. )
  182. if /i "%lang%" EQU "usa" (
  183. call :MungePublics
  184. if defined ThereWereErrors goto End_Main
  185. )
  186. if not defined RunAlways (
  187. if not defined OFFICIAL_BUILD_MACHINE (
  188. if /i not "!__BUILDMACHINE__!" == "LB6RI" (
  189. call logmsg.cmd "OFFICIAL_BUILD_MACHINE is not defined ... script is exiting"
  190. goto end
  191. )
  192. )
  193. )
  194. if /i "!Comp!" == "No" (
  195. call logmsg.cmd "Compression disabled ... script is exiting"
  196. goto end
  197. )
  198. if /i "%lang%" == "psu" (
  199. call logmsg.cmd "PSEUDOLOC build ... script is exiting"
  200. goto end
  201. )
  202. if /i "%lang%" == "FE" (
  203. call logmsg.cmd "FE PSEUDOLOC build ... script is exiting"
  204. goto end
  205. )
  206. if /i "%lang%" == "mir" (
  207. call logmsg.cmd "Mirrored build ... script is exiting"
  208. goto end
  209. )
  210. if /i "%lang%" NEQ "usa" goto SymLists
  211. REM Fix the localized eula for international builds
  212. REM If dbg_x86.msi and/or dbg_ia64.msi is not a retail build, then we
  213. REM don't localize the eula. Sometimes this will be commented out.
  214. set MyPath=%_NTPostBld%\symbolcd\cd\tools
  215. set X86Eula=%_NTPostBld%\symbolcd\dbgeula\retail\eula.rtf
  216. set IA64Eula=%_NTPostBld%\symbolcd\dbgeula\beta\eula.rtf
  217. if /i "%lang%" NEQ "usa" (
  218. REM call dbgeula -m %MyPath%\dbg_x86.msi -e %X86Eula% -b %lang%
  219. REM call dbgeula -m %MyPath%\dbg_ia64.msi -e %IA64Eula% -b %lang%
  220. )
  221. :Symbad
  222. REM Skip this for now
  223. goto EndSymbad
  224. REM ********************************************************************
  225. REM Owner: Barb Kess
  226. REM
  227. REM This script finds out which files in symbad.txt are either not found
  228. REM or pass symbol checking.
  229. REM
  230. REM It creates a new symbad.txt based on this build machine.
  231. REM To check in a new symbad.txt, take the union of symbad.txt.new on all
  232. REM build machines.
  233. REM
  234. REM ********************************************************************
  235. set SymDir=%_NTPostBld%\symbad
  236. set NewSymbad=%SymDir%\symbad.txt.new
  237. set SymchkLog=%SymDir%\symchk.log
  238. if EXIST %NewSymbad% goto EndSymbad
  239. if EXIST %SymDir% rd /s /q %SymDir%
  240. md %SymDir%
  241. REM Find out which files pass
  242. for /f "tokens=1* delims= ; " %%a in (%RazzleToolPath%\symbad.txt) do (
  243. if exist %_NTPostBld%\%%a (
  244. symchk.exe /t %PUB_SYM_FLAG% %_NTPostBld%\%%a /s %_NTPostBld%\symbols\retail>>%SymchkLog%
  245. if !ERRORLEVEL! EQU 1 (
  246. echo %%a ; %%b>>%NewSymbad%
  247. )
  248. )
  249. )
  250. REM Add the international files back in
  251. findstr /i "INTL" %RazzleToolPath%\symbad.txt>> %SymDir%\symbad.txt.new
  252. REM Add back files that error during a clean build
  253. REM This happens because they have a private placefil.txt that
  254. REM binplaces them to "retail". These are files not in the product
  255. findstr /i "clean" %RazzleToolPath%\symbad.txt>> %SymDir%\symbad.txt.new
  256. call logmsg "New symbad.txt = %SymDir%\symbad.txt.new"
  257. :EndSymbad
  258. REM *********************************************************************
  259. REM Create the lists for the symbol cabs and do symbol checking
  260. REM
  261. REM *********************************************************************
  262. :SymLists
  263. REM Now, create the symbol cabs
  264. REM Add any cab generation processing here.
  265. REM If myerrors, goto end
  266. REM ThereWereSymchkErrors is a special variable to determine if there were
  267. REM symbol checking errors. If it is "yes", then mail gets sent, but
  268. REM postbuild does not record the errors --- then BVT's will continue.
  269. set ThereWereErrors=no
  270. set ThereWereSymchkErrors=no
  271. set langroot=%_NTPostBld%\symbolcd\%lang%
  272. set SymCabName=symbols
  273. set build_bindiff=%_NTPostBld%\build_logs\bindiff.txt
  274. REM
  275. REM Decide which build we are working on
  276. REM debug vs. retail and i386 vs. amd64 vs. ia64
  277. REM
  278. set SUBDIR=
  279. if /i "%_BuildArch%" == "x86" (
  280. if /i "%lang%" == "NEC_98" (
  281. set SUBDIR=NEC98
  282. ) else (
  283. set SUBDIR=i386
  284. )
  285. )
  286. if /i "%_BuildArch%" == "amd64" (
  287. set SUBDIR=amd64
  288. )
  289. if /i "%_BuildArch%" == "ia64" (
  290. set SUBDIR=ia64
  291. )
  292. if "%SUBDIR%" == "" (
  293. call errmsg "Environment variables _BuildArch is not recognized"
  294. goto end
  295. )
  296. if /i "%_BuildType%" == "chk" (
  297. set FRECHK=Debug
  298. ) else (
  299. set FRECHK=Retail
  300. )
  301. REM
  302. REM symbad.txt - don't write errors to the error log
  303. REM for files in symbad.txt
  304. REM
  305. set symbad.txt=%RazzleToolPath%\symbad.txt
  306. REM
  307. REM symlist.txt - list of all files that we should
  308. REM check symbols for
  309. REM
  310. set symlist.txt=%langroot%\symlist.txt
  311. REM
  312. REM symbolcd.txt - list of all the files to put into
  313. REM symbol cabs. This is the result of running
  314. REM symchk on symlist.txt.
  315. REM
  316. set symbolcd.txt=%langroot%\symbolcd.txt
  317. REM
  318. REM symbolcd.tmp - used when generating the right path
  319. REM information for symbols in alternate project targets
  320. REM
  321. set symbolcd.tmp=%langroot%\symbolcd.tmp
  322. REM
  323. REM symerror.log - files that had errors when symchk
  324. REM was run on symlist.txt
  325. REM
  326. REM symerror.txt - the text file of errors that gets sent
  327. REM to a mail alias
  328. set symerror.txt=%langroot%\symerror.txt
  329. set symerror.log=%langroot%\symerror.log
  330. set symerror.winnt32.log=%langroot%\symerror.winnt32.log
  331. REM
  332. REM cabgenerr.log - error file when generating cabs
  333. REM
  334. set cabgenerr.log=%langroot%\cabgenerr.log
  335. REM
  336. REM exclude.txt - files that are not to be shipped
  337. REM
  338. set exclude.txt=%langroot%\exclude.txt
  339. REM
  340. REM symmake - program that creates the makefile and
  341. REM ddfs for cab creation
  342. REM
  343. set symmake=symmake.exe
  344. REM
  345. REM DDFDir - directory that contains the makefile and
  346. REM ddfs for cab creation
  347. REM
  348. set DDFDir=%langroot%\ddf
  349. set USDDFDir=%_NTPostBld%\symbolCD\usa\ddf
  350. REM
  351. REM Perl script that takes union and intersection of lists
  352. REM
  353. set MakeList=%RazzleToolPath%\makelist.pl
  354. REM
  355. REM Perl
  356. REM
  357. set perl=perl.exe
  358. REM
  359. REM SYMCD - root of the symbol CD. Everything under here
  360. REM will appear as is on the symbol CD.
  361. REM
  362. set SYMCD=%_NTPostBld%\symbolCD\CD
  363. REM
  364. REM InfDestDir - final destination directory for the infs
  365. REM and the final cab
  366. REM
  367. set InfDestDir=%SYMCD%\Symbols\%SUBDIR%\%FRECHK%
  368. REM
  369. REM CabDestDir - directory where the individual cabs are
  370. REM placed before they get merged into one cab
  371. REM
  372. set CabDestDir=%langroot%\cabs
  373. REM
  374. REM RedistDir has cabs that are on the CD, but are not
  375. REM installed
  376. REM
  377. set RedistDir=%_NTPostBld%\symbolCD\redist
  378. REM
  379. REM If we want to do a clean build, erase %symcabname%.inf
  380. REM
  381. if exist %symerror.txt% (
  382. set cleanbuild=1
  383. call logmsg "There were errors previously -- will do cleanbuild"
  384. )
  385. if not exist %build_bindiff% (
  386. set cleanbuild=1
  387. call logmsg "%build_bindiff% does not exist -- will do cleanbuild"
  388. )
  389. if not exist %InfDestDir%\%SymCabName%.inf (
  390. set cleanbuild=1
  391. call logmsg "%InfDestDir%\%SymCabName%.inf does not exist -- will do cleanbuild"
  392. )
  393. if not exist %InfDestDir%\%SymCabName%.cat (
  394. set cleanbuild=1
  395. call logmsg "%InfDestDir%\%SymCabName%.cat does not exist -- will do cleanbuild"
  396. )
  397. if defined cleanbuild (
  398. del /q %InfDestDir%\%SymCabName%.inf >nul 2>nul
  399. del /q %InfDestDir%\%SymCabName%.cat >nul 2>nul
  400. del /q %InfDestDir%\%SymCabName%.cab >nul 2>nul
  401. )
  402. REM
  403. REM Make sure that buildname.txt is copied to the root of the CD
  404. REM
  405. call logmsg "Copying %_NTPostBld%\build_logs\buildname.txt to %InfDestDir%"
  406. if not exist %InfDestDir% md %InfDestDir%
  407. copy %_NTPostBld%\build_logs\buildname.txt %InfDestDir%\buildname.txt
  408. if not exist %InfDestDir%\buildname.txt (
  409. call errmsg "Could not copy %_NTPostbld%\build_logs\buildname.txt to %InfDestDir%\buildname.txt"
  410. )
  411. REM
  412. REM If this is incremental, only create the cabs
  413. REM
  414. if /i "%lang%" == "usa" (
  415. if not defined cleanbuild (
  416. call logmsg "Running in incremental mode"
  417. goto CreateCatalog
  418. )
  419. ) else (
  420. REM localized builds can skip the cab generation
  421. if exist %build_bindiff% (
  422. goto EndSymbolCD
  423. )
  424. )
  425. REM
  426. REM Otherwise, do a clean build of everything
  427. REM
  428. REM Delete the %langroot% directory
  429. call :ReMD %langroot%
  430. call :ReMD %langroot%.bak
  431. call :ReMD %DDFDir%\temp
  432. if /i "%lang%" NEQ "usa" goto CreateFileList
  433. REM Make the necessary directories
  434. if not exist %InfDestDir% md %InfDestDir%
  435. call :ReMD %DDFDir%\..\ddf.bak
  436. call :ReMD %CabDestDir%
  437. REM
  438. REM Create the exclude list. Right now exclusion list consists of the
  439. REM list of symbol files we are not supposed to ship. Symbad.txt is not
  440. REM included in the exclusion list because symbad.txt might not be up to
  441. REM data and some of the files in symbad could have correct symbols. We
  442. REM want to get as many symbols as possible, as long as they pass symbol
  443. REM checking.
  444. REM
  445. :CreateExcludeList
  446. copy %RazzleToolPath%\symdontship.txt %exclude.txt%
  447. REM
  448. REM Copy below files to release share, so test team does not need to enlist
  449. REM the razzle environment to make testsymbol.cmd could run
  450. REM
  451. copy %RazzleToolPath%\symdontship.txt %langroot%\symdontship.txt
  452. copy %RazzleToolPath%\symbad.txt %langroot%\symbad.txt
  453. copy %RazzleToolPath%\symbolswithtypes.txt %langroot%\symbolswithtypes.txt
  454. REM
  455. REM Create the list of files. This is the list of retail files that
  456. REM we will attempt to find symbols for.
  457. REM
  458. :CreateFileList
  459. call logmsg.cmd "Creating the list of files to check symbols for"
  460. REM Get the list of subdirectories that have dosnet and excdosnet in them.
  461. REM And, make it compliant with the international builds.
  462. REM Set the first one to be workstation, which is the current directory
  463. set inflist= .
  464. perl %RazzleToolPath%\cksku.pm -t:per -l:%lang%
  465. if %errorlevel% EQU 0 set inflist=%inflist% perinf
  466. perl %RazzleToolPath%\cksku.pm -t:bla -l:%lang%
  467. if %errorlevel% EQU 0 set inflist=%inflist% blainf
  468. perl %RazzleToolPath%\cksku.pm -t:sbs -l:%lang%
  469. if %errorlevel% EQU 0 set inflist=%inflist% sbsinf
  470. perl %RazzleToolPath%\cksku.pm -t:srv -l:%lang%
  471. if %errorlevel% EQU 0 set inflist=%inflist% srvinf
  472. perl %RazzleToolPath%\cksku.pm -t:ads -l:%lang%
  473. if %errorlevel% EQU 0 set inflist=%inflist% entinf
  474. perl %RazzleToolPath%\cksku.pm -t:dtc -l:%lang%
  475. if %errorlevel% EQU 0 set inflist=%inflist% dtcinf
  476. REM Take the union of dosnet.inf and excdosnet.inf for all subdirectories
  477. for %%a in (%inflist%) do (
  478. if /i EXIST %_NTPostBld%\%%a (
  479. %perl% %MakeList% -n %_NTPostBld%\%%a\dosnet.inf -o %DDFDir%\temp\dosnet.lst
  480. %perl% %MakeList% -q %_NTPostBld%\%%a\excdosnt.inf -o %DDFDir%\temp\drivers.lst
  481. %perl% %MakeList% -u %DDFDir%\temp\drivers.lst %DDFDir%\temp\dosnet.lst -o %DDFDir%\temp\%%a.lst
  482. if NOT exist %DDFDir%\temp\all.lst (
  483. copy %DDFDir%\temp\%%a.lst %DDFDir%\temp\all.lst
  484. ) else (
  485. %perl% %MakeList% -u %DDFDir%\temp\all.lst %DDFDir%\temp\%%a.lst -o %DDFDir%\temp\all.lst
  486. )
  487. )
  488. )
  489. REM People who own cabs have supplied lists of the files in the cabs
  490. REM These lists are in the directory symbolcd\cablists
  491. REM Add them to the end of the list we just created
  492. call logmsg.cmd "Adding the files that are in cabs"
  493. if EXIST %_NTPostBld%\symbolcd\cablists (
  494. dir /a-d /b %_NTPostBld%\symbolcd\cablists > %DDFDir%\temp\cablists.lst
  495. )
  496. if EXIST %DDFDir%\temp\cablists.lst (
  497. for /f %%a in (%DDFDir%\temp\cablists.lst) do (
  498. type %_NTPostBld%\symbolcd\cablists\%%a >> %DDFDir%\temp\all.lst
  499. )
  500. )
  501. REM
  502. REM Find out which of these files are in %_NTPostBld%
  503. REM Put the output in %symlist.txt%
  504. REM
  505. call logmsg.cmd "Computing which files are in %_NTPostBld%"
  506. for /f %%b in (%DDFDir%\temp\all.lst) do (
  507. if /i EXIST %_NTPostBld%\%%b (
  508. echo %_NTPostBld%\%%b >> %DDFDir%\temp\all2.lst
  509. )
  510. )
  511. sort %DDFDir%\temp\all2.lst > %symlist.txt%
  512. call logmsg.cmd "Finished creating %symlist.txt%"
  513. :EndSymLists
  514. :SymbolCheck
  515. REM
  516. REM Create the list of files to copy onto the symbolcd.
  517. REM Result is %symbolcd.txt%
  518. REM
  519. REM /c output list of symbols. THis is used as input to symmake for
  520. REM creating the makefile and ddfs.
  521. REM /l input list of files to find symbols for
  522. REM %_NTPostBld% - directory where files in %symlist.txt% are located
  523. REM /s symbol search path
  524. REM /e don't look for symbols for these files (i.e., files we should not
  525. REM ship symbols for
  526. REM /x Don't write errors for these files to the error log
  527. REM %symerror.log% Errors during symbol checking --- these should be
  528. REM examined because the errors are genuine.
  529. REM
  530. REM Delete the error file that gets sent to people
  531. if exist %symerror.txt% del /q %symerror.txt%
  532. if /i "%lang%" == "usa" (
  533. call logmsg.cmd "Examining file headers to compute the list of symbol files ..."
  534. symchk.exe /t %PUB_SYM_FLAG% /c %symbolcd.txt% /l %symlist.txt% /s %_NTPostBld%\symbols\retail /e %exclude.txt% /x %symbad.txt% > %symerror.log%
  535. ) else (
  536. REM localized builds just need to add the binaries
  537. if exist %symbolcd.txt% del /q %symbolcd.txt%
  538. for /f %%a in (%symlist.txt%) do (
  539. echo %%a,,%%a, >> %symbolcd.txt%
  540. )
  541. )
  542. :winnt32
  543. REM
  544. REM Recursively add files in the winnt32 subdirectory
  545. REM
  546. REM Don't use a list, just go through the subdirectories
  547. REM
  548. call logmsg.cmd "Adding files in the winnt32 subdirectory"
  549. if /i "%lang%" == "usa" (
  550. copy %exclude.txt% %exclude.txt%.winnt32
  551. @echo winntbbu.dll>>%exclude.txt%.winnt32
  552. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt% %_NTPostBld%\winnt32\* /s %_NTPostBld%\symbols\winnt32 /x %symbad.txt% /e %exclude.txt%.winnt32 > %symerror.winnt32.log%
  553. ) else (
  554. for /f %%a in ('dir /s /b %_NTPostBld%\winnt32\*') do (
  555. echo %%a,,%%a, >> %symbolcd.txt%
  556. )
  557. )
  558. REM don't log these -- there are a log of errors
  559. REM call :LogSymbolErrors %symerror.winnt32.log%
  560. call logmsg.cmd "Adding *.sym files in the %_NTPostBld%\system32 directory"
  561. dir /b %_NTPostBld%\system32\*.sym > %DDFDir%\temp\symfiles.txt
  562. for /f %%a in (%DDFDir%\temp\symfiles.txt) do (
  563. echo %_NTPostBld%\system32\%%a,%%a,system32\%%a,16bit>> %symbolcd.txt%
  564. )
  565. REM
  566. REM Also add files in the wow6432 directory
  567. REM Wow6432 should only exist on x86fre and x86chk
  568. REM
  569. if exist %_NTPostBld%\wow6432 (
  570. if /i "%lang%" == "usa" (
  571. call logmsg.cmd "Adding files in the %_NTPostBld%\wow6432 directory"
  572. symchk.exe /t %PUB_SYM_FLAG% /c %symbolcd.tmp% %_NTPostBld%\wow6432\* /s %_NTPostBld%\wow6432\symbols\retail /x %symbad.txt% >> %symerror.log%
  573. REM add wow6432 before the symbols directory and also before the install directory
  574. for /f "tokens=1,2,3,4 delims=," %%a in (%symbolcd.tmp%) do (
  575. echo %%a,%%b,wow6432\%%c,wow6432\%%d>> %symbolcd.txt%
  576. )
  577. ) else (
  578. for /f %%a in ('dir /b %_NTPostBld%\wow6432') do (
  579. echo %_NTPostBld%\wow6432\%%a,,%_NTPostBld%\wow6432\%%a, >> %symbolcd.txt%
  580. )
  581. )
  582. )
  583. REM
  584. REM Add the lang directory
  585. REM
  586. if exist %_NTPostBld%\lang (
  587. call logmsg.cmd "Adding the lang symbols"
  588. if /i "%lang%" == "usa" (
  589. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt% %_NTPostBld%\lang\* /s %_NTPostBld%\symbols\lang /x %symbad.txt% /e %exclude.txt% >> %symerror.log%
  590. ) else (
  591. for /f %%a in ('dir /s /b %_NTPostBld%\lang') do (
  592. echo %%a,,%%a, >> %symbolcd.txt%
  593. )
  594. )
  595. )
  596. REM
  597. REM Add the netfx directory
  598. REM
  599. if exist %_NTPostBld%\netfx (
  600. call logmsg.cmd "Adding the netfx symbols"
  601. if /i "%lang%" == "usa" (
  602. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt% %_NTPostBld%\netfx\* /s %_NTPostBld%\symbols\netfx /x %symbad.txt% /e %exclude.txt% >> %symerror.log%
  603. ) else (
  604. for /f %%a in ('dir /s /b %_NTPostBld%\netfx') do (
  605. echo %%a,,%%a, >> %symbolcd.txt%
  606. )
  607. )
  608. )
  609. REM
  610. REM Add the adprep directory
  611. REM
  612. if exist %_NTPostBld%\adprep (
  613. call logmsg.cmd "Adding the adprep symbols"
  614. if /i "%lang%" == "usa" (
  615. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt% %_NTPostBld%\adprep\* /s %_NTPostBld%\symbols\adprep /x %symbad.txt% /e %exclude.txt% >> %symerror.log%
  616. ) else (
  617. for /f %%a in ('dir /s /b %_NTPostBld%\adprep') do (
  618. echo %%a,,%%a, >> %symbolcd.txt%
  619. )
  620. )
  621. )
  622. REM
  623. REM Add the faxclients directory
  624. REM
  625. if exist %_NTPostBld%\faxclients (
  626. call logmsg.cmd "Adding the faxclients symbols"
  627. if /i "%lang%" == "usa" (
  628. symchk.exe /t %PUB_SYM_FLAG% /c %symbolcd.txt% %_NTPostBld%\faxclients\* /s %_NTPostBld%\symbols\faxclients /x %symbad.txt% /e %exclude.txt% >> %symerror.log%
  629. ) else (
  630. for /f %%a in ('dir /a-d /b %_NTPostBld%\faxclients') do (
  631. echo %_NTPostBld%\faxclients\%%a,,%_NTPostBld%\faxclients\%%a, >> %symbolcd.txt%
  632. )
  633. )
  634. )
  635. if exist %_NTPostBld%\faxclients\win9x (
  636. call logmsg.cmd "Adding the faxclients win9x symbols"
  637. if /i "%lang%" == "usa" (
  638. symchk.exe /t %PUB_SYM_FLAG% /c %symbolcd.txt% %_NTPostBld%\faxclients\win9x\* /s %_NTPostBld%\symbols\faxclients /x %symbad.txt% /e %exclude.txt% >> %symerror.log%
  639. ) else (
  640. for /f %%a in ('dir /a-d /b %_NTPostBld%\faxclients\win9x') do (
  641. echo %_NTPostBld%\faxclients\win9x\%%a,,%_NTPostBld%\faxclients\win9x\%%a, >> %symbolcd.txt%
  642. )
  643. )
  644. )
  645. REM
  646. REM Add the vsssrv directory
  647. REM
  648. if exist %_NTPostBld%\vsssrv (
  649. call logmsg.cmd "Adding the vsssrv symbols"
  650. if /i "%lang%" == "usa" (
  651. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt% %_NTPostBld%\vsssrv\* /s %_NTPostBld%\symbols\vsssrv /x %symbad.txt% /e %exclude.txt% >> %_NTPostBld%\vsserror.log
  652. ) else (
  653. for /f %%a in ('dir /s /b %_NTPostBld%\vsssrv') do (
  654. echo %%a,,%%a, >> %symbolcd.txt%
  655. )
  656. )
  657. )
  658. REM
  659. REM Add the wms directory
  660. REM
  661. if exist %symerror.log%.wms del %symerror.log%.wms >nul
  662. if exist %_NTPostBld%\wms (
  663. call logmsg.cmd "Adding the wms symbols"
  664. if /i "%lang%" == "usa" (
  665. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt% %_NTPostBld%\wms\* /s %_NTPostBld%\symbols\wms /x %symbad.txt% /e %exclude.txt% >> %symerror.log%.wms
  666. ) else (
  667. for /f %%a in ('dir /s /b %_NTPostBld%\wms') do (
  668. echo %%a,,%%a, >> %symbolcd.txt%
  669. )
  670. )
  671. )
  672. REM
  673. REM Look for language's symbols
  674. REM
  675. REM
  676. if exist %symerror.log%.languages del %symerror.log%.languages>nul
  677. if /i "%lang%" EQU "usa" (
  678. for /f "tokens=1 eol=;" %%f in (%RazzleToolPath%\codes.txt) do (
  679. if exist %_NTPostBld%\%%f (
  680. if exist %symbolcd.txt%.%%f del %symbolcd.txt%.%%f>nul
  681. call logmsg.cmd "Add the %%f symbols"
  682. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt%.%%f %_NTPostBld%\%%f\* /s %_NTPostBld%\%%f\symbols\retail /x %symbad.txt% /e %exclude.txt% >> %symerror.log%.languages
  683. for /f "tokens=1,2,3,4 delims=," %%m in (%symbolcd.txt%.%%f) do (
  684. @echo %%m,%%n,%%f\%%o,%%f\%%p>>%symbolcd.txt%
  685. )
  686. )
  687. )
  688. )
  689. REM
  690. REM Look for FE symbols
  691. REM
  692. REM
  693. if /i "%lang%" EQU "usa" (
  694. for %%f in (FE) do (
  695. if exist %_NTPostBld%\%%f (
  696. if exist %symbolcd.txt%.%%f del %symbolcd.txt%.%%f>nul
  697. call logmsg.cmd "Add the %%f symbols"
  698. symchk.exe /t %PUB_SYM_FLAG% /r /c %symbolcd.txt%.%%f %_NTPostBld%\%%f\* /s %_NTPostBld%\%%f\symbols\retail /x %symbad.txt% /e %exclude.txt% >> %symerror.log%.languages
  699. for /f "tokens=1,2,3,4 delims=," %%m in (%symbolcd.txt%.%%f) do (
  700. @echo %%m,%%n,%%f\%%o,%%f\%%p>>%symbolcd.txt%
  701. )
  702. )
  703. )
  704. )
  705. if /i "%lang%" NEQ "usa" (
  706. call logmsg.cmd "Finished creating %symbolcd.txt%"
  707. goto EndSymbolCD
  708. )
  709. call :LogSymbolErrors %symerror.log%
  710. call :ReportSymchkErrors
  711. call :ReportSymbolDuplicatesAndFlatInstalledPath
  712. call logmsg.cmd "Finished creating %symbolcd.txt%"
  713. :CreateMakefile
  714. REM
  715. REM We don't need a real symbol CD cab for coverage builds
  716. REM so lets save time/space and not make one
  717. REM
  718. if defined _COVERAGE_BUILD (
  719. call logmsg.cmd "Coverage build ... skipping making the cab file"
  720. goto :Symsrv
  721. )
  722. REM
  723. REM /i symbol inf that lists the symbol files to be cabbed
  724. REM /o directory to place the DDF files and the makefile
  725. REM /s Number of files to put into a cab
  726. REM /m Tell inf that all cabs will be merged into %SymCabName%.inf
  727. REM
  728. REM
  729. REM Create the makefile and all the DDF's
  730. REM This also creates
  731. REM %DDFDir%\symcabs.txt - a list of all the cabs
  732. REM
  733. call logmsg.cmd "Creating the makefile and the DDF's for creating the cabs"
  734. REM
  735. REM This is the symmake command to use if we are planning to merge all the cabs into one
  736. REM
  737. %symmake% /m /c %SymCabName% /i %symbolcd.txt% /o %DDFDir% /s 800 /t %_NTPostBld% /x %CabDestDir% /y %InfDestDir%
  738. REM
  739. REM Create the catalog
  740. REM
  741. REM
  742. REM Put the name of the catalog file into the header
  743. REM Symmake already output %SymCabName%.CDF
  744. REM
  745. :CreateCatalog
  746. REM
  747. REM Incremental catalog
  748. REM
  749. if not exist %InfDestDir%\%SymCabName%.CAT goto CleanCatalog
  750. REM This echo's the files that need to be readded to
  751. REM %SymCabName%.CDF.update
  752. REM
  753. if exist %DDFDir%\%SymCabName%.update del /f /q %DDFDir%\%SymCabName%.update
  754. nmake /f %DDFDir%\%SymCabName%.CDF.makefile
  755. if not exist %DDFDir%\%SymCabName%.update (
  756. call logmsg "%InfDestDir%\%SymCabName%.CAT is up-to-date"
  757. goto CreateCabs
  758. )
  759. REM Now, add each file to the catalog
  760. for /f %%a in (%DDFDir%\%SymCabName%.update) do (
  761. call updcat %InfDestDir%\%SymCabName%.CAT -a %%a >nul 2>nul
  762. call logmsg "%%a successfully added to %InfDestDir%\%SymCabName%.CAT
  763. )
  764. call logmsg "%InfDestDir%\%SymCabName%.CAT needs to be resigned"
  765. )
  766. goto CreateCabs
  767. REM
  768. REM Clean Catalog generation
  769. REM
  770. :CleanCatalog
  771. call logmsg.cmd "Creating header for %SymCabName%.CDF"
  772. %perl% %MakeList% -h %SymCabName% -o %DDFDir%\%SymCabName%.CDF > nul 2>&1
  773. call logmsg.cmd "Adding files to %SymCabName%.CDF"
  774. echo ^<HASH^>%InfDestDir%\%SymCabName%.inf=%InfDestDir%\%SymCabName%.inf>> %DDFDir%\%SymCabName%.CDF
  775. type %DDFDir%\%SymCabName%.CDF.noheader >> %DDFDir%\%SymCabName%.CDF
  776. call logmsg.cmd "Creating %InfDestDir%\%SymCabName%.CAT"
  777. start "PB_SymCabGen %SymCabName%.CAT" /MIN cmd /c "%RazzleToolPath%\Postbuildscripts\SymCabGen.cmd -f:%SymCabName% -s:%DDFDir% -t:CAT -d:%InfDestDir%"
  778. :CreateCabs
  779. if NOT EXIST %DDFDir%\cabs md %DDFDir%\cabs
  780. if /i EXIST %DDFDir%\temp\*.txt del /f /q %DDFDir%\temp\*.txt
  781. for /F "tokens=1" %%a in (%DDFDir%\symcabs.txt) do (
  782. sleep 1
  783. call logmsg.cmd "%RazzleToolPath%\PostBuildScripts\SymCabGen.cmd -f:%%a -s:%DDFDir% -t:CAB -d:%CabDestDir%"
  784. start "PB_SymCabGen %%a" /MIN cmd /c "%RazzleToolPath%\PostBuildScripts\SymCabGen.cmd -f:%%a -s:%DDFDir% -t:CAB -d:%CabDestDir%"
  785. )
  786. call logmsg.cmd "Waiting for symbol cabs to finish"
  787. :wait
  788. sleep 5
  789. if EXIST %DDFDir%\temp\*.txt goto wait
  790. :Verify
  791. REM
  792. REM Verify that the Catalog is there
  793. REM
  794. if not exist %InfDestDir%\%SymCabName%.CAT (
  795. REM call errmsg.cmd "%InfDestDir%\%SymCabName%.CAT did not get created"
  796. )
  797. REM
  798. REM Verify that all the cabs are there
  799. REM
  800. if /i EXIST %DDFDir%\temp\*.txt del /f /q %DDFDir%\temp\*.txt
  801. set AllCreated=TRUE
  802. call logmsg.cmd "Verifying that all the cabs got created"
  803. for /F "tokens=1" %%a in (%DDFDir%\symcabs.txt) do (
  804. if NOT EXIST %CabDestDir%\%%a (
  805. set AllCreated=FALSE
  806. call logmsg.cmd "%CabDestDir%\%%a didn't get created ... Trying again"
  807. sleep 1
  808. start "PB_SymCabGen %%a" /MIN cmd /c "%_NTPostBld%\SymbolCD\SymCabGen.cmd -f:%%a -d:%CabDestDir%"
  809. )
  810. )
  811. if /i "%AllCreated%" == "TRUE" goto Final
  812. REM
  813. REM Wait for cabs to finish
  814. REM
  815. call logmsg.cmd "Trying again for symbol cabs to finish"
  816. :wait2
  817. sleep 5
  818. if EXIST %DDFDir%\temp\*.txt goto wait2
  819. REM
  820. REM This time print an error message if the cabs do not exist
  821. REM
  822. :FinalVerify
  823. call logmsg.cmd "Verifying that all the cabs got created"
  824. set AllCreated=TRUE
  825. if /i EXIST %cabgenerr.log% del /f /q %cabgenerr.log%
  826. for /F "tokens=1" %%a in (%DDFDir%\symcabs.txt) do (
  827. if /i NOT EXIST %CabDestDir%\%%a (
  828. set AllCreated=FALSE
  829. echo %CabDestDir%\%%a was not created >> %cabgenerr.log%
  830. call errmsg.cmd "%CabDestDir%\%%a was not created"
  831. )
  832. )
  833. if /i EXIST %cabgenerr.log% (
  834. goto end
  835. )
  836. :Final
  837. REM
  838. REM Combine all the cabs into one cab
  839. REM
  840. set first=yes
  841. for /F "tokens=1" %%a in (%DDFDir%\symcabs.txt) do (
  842. REM Make a copy of it
  843. REM copy %CabDestDir%\%%a %InfDestDir%\%%a
  844. if "!first!" == "yes" (
  845. set MergeCommand=load %CabDestDir%\%%a
  846. set first=no
  847. ) else (
  848. set MergeCommand=!MergeCommand! load %CabDestDir%\%%a merge
  849. )
  850. )
  851. set MergeCommand=%MergeCommand% save %InfDestDir%\%SymCabName%.cab
  852. call logmsg.cmd "Merging cabs into %InfDestDir%\%SymCabName%.cab"
  853. cabbench.exe %MergeCommand%
  854. REM
  855. REM Copy the ADC no-install cab
  856. REM
  857. :CopyRedist
  858. if EXIST %RedistDir%\*.cab (
  859. call logmsg.cmd "Copying cabs from %RedistDir% to %InfDestDir%"
  860. copy %RedistDir%\*.cab %InfDestDir%
  861. )
  862. :SignFiles
  863. call logmsg.cmd "Test signing files on CD"
  864. for %%b in (retail debug) do (
  865. REM symbolsx.exe gets checked in as signed, so it is no longer
  866. REM test signed.
  867. if exist %SYMCD%\Symbols\i386\%%b\%SymCabName%.CAT (
  868. call logmsg "Signing %SYMCD%\Symbols\i386\%%b\%SymCabName%.CAT"
  869. call ntsign.cmd %SYMCD%\Symbols\i386\%%b\%SymCabName%.CAT
  870. )
  871. if exist %SYMCD%\Symbols\amd64\%%b\%SymCabName%.CAT (
  872. call logmsg "Signing %SYMCD%\Symbols\amd64\%%b\%SymCabName%.CAT"
  873. call ntsign.cmd %SYMCD%\Symbols\amd64\%%b\%SymCabName%.CAT
  874. )
  875. if exist %SYMCD%\Symbols\ia64\%%b\%SymCabName%.CAT (
  876. call logmsg "Signing %SYMCD%\Symbols\ia64\%%b\%SymCabName%.CAT"
  877. call ntsign.cmd %SYMCD%\Symbols\ia64\%%b\%SymCabName%.CAT
  878. )
  879. )
  880. call logmsg "Finished with the symbolcd!!"
  881. :EndSymbolCD
  882. :Symsrv
  883. REM *********************************************************************
  884. REM Now examine the files in symbols.pri to build a symbol server index
  885. REM file.
  886. REM *********************************************************************
  887. :StartSymsrv
  888. call logmsg "Creating the index files for the symbol server"
  889. :SymsrvSetForkedDirs
  890. set new_fork=
  891. REM International builds and forked builds want to only index the
  892. REM difference between the original usa build.
  893. REm Determine if this is one of those cases. Also, handle the case
  894. REM where international inherits a forked build.
  895. REM SymsrvDir where the current symsrv directory is
  896. REM SymsrvDir_1 where the original US symsrv directory is
  897. REM SymsrvDir_2 where the US symsrv directory is that has the
  898. REM incremental changes from the fork.
  899. set SymsrvDir=%_NTPostBld%\symsrv\%lang%
  900. set SymsrvDir_1=%_NTTREE%\symsrv\usa.1
  901. set SymsrvDir_2=%_NTTREE%\symsrv\usa
  902. set SymsrvMakefile=%_NTPostBld%\symsrv\%lang%\makefile
  903. set SymsrvLatest=%_NTPostBld%\symsrv\%lang%\latest.txt
  904. REM
  905. REM coverage builds are not incremental builds, so
  906. REM wipe out any previous symsrv stuff
  907. REM
  908. if defined _COVERAGE_BUILD (
  909. call logmsg.cmd "Coverage build ... wiping out pre-existing symsrv dir"
  910. rd /s /q %_NTPostBld%\symsrv
  911. )
  912. if /i "%lang%" NEQ "usa" (
  913. if not exist %SymsrvDir_2% (
  914. call errmsg.cmd "The USA symsrv directory does not exist - %SymsrvDir_2%"
  915. goto End_Main
  916. )
  917. call logmsg "Will not re-index what's in %SymsrvDir_2%"
  918. if exist %SymsrvDir_1% (
  919. call logmsg "US build was a forked build - will not re-index what's in %SymsrvDir_1%"
  920. )
  921. )
  922. :EndSymsrvSetForkedDirs
  923. set st=%SymsrvDir%\temp
  924. if NOT exist %SymsrvDir% md %SymsrvDir%
  925. if NOT exist %SymsrvDir%\temp md %SymsrvDir%\temp
  926. set SymsrvLogDir=%SymsrvDir%\Logs
  927. if NOT exist %SymsrvLogDir% md %SymsrvLogDir%
  928. REM Requests are generated by this script
  929. REM The release script moves the requests to working before
  930. REM it copies the file to the server
  931. REM The release script moves the working to finished when the request is done
  932. if not exist %SymsrvDir%\add_requests md %SymsrvDir%\add_requests
  933. if not exist %SymsrvDir%\add_finished md %SymsrvDir%\add_finished
  934. if not exist %SymsrvDir%\del_requests md %SymsrvDir%\del_requests
  935. REM Each request has a count associated with it in case someone
  936. REM tries to run postbuild a bunch of times. If the previous
  937. REM postbuild got indexed on the symbols server, it will be sitting
  938. REM in add_finished and the count will get incremented.
  939. if not exist %SymsrvDir%\count (
  940. echo ^1>%SymsrvDir%\count
  941. )
  942. for /f "tokens=1 delims=" %%a in (%SymsrvDir%\count) do (
  943. set /a count=%%a
  944. )
  945. if defined new_fork (
  946. call logmsg "Incrementing count for new forked build"
  947. set /a count=!count!+1
  948. echo !count!>%SymsrvDir%\count
  949. )
  950. for /f "tokens=1 delims=" %%a in ( '%RazzleToolPath%\postbuildscripts\buildname build_name' ) do (
  951. set BuildName=%%a
  952. )
  953. set IndexFile=%BuildName%.%lang%
  954. REM
  955. REM coverage builds need a different index file name
  956. REM so they don't collide with any other build
  957. REM
  958. if defined _COVERAGE_BUILD (
  959. set IndexFile=%BuildName%.cov
  960. )
  961. REM See if this count has already been put in add_finished
  962. REM Nothing should exist in add_working
  963. dir /b %SymsrvDir%\add_finished\%IndexFile%.!count!.* >NUL 2>NUL
  964. if !ERRORLEVEL! EQU 0 (
  965. goto NewCount
  966. )
  967. goto CreateIndices
  968. :NewCount
  969. set /a count=!count!+1
  970. echo !count!>%SymsrvDir%\count
  971. :CreateIndices
  972. set IndexFile=%IndexFile%.!count!
  973. set SymsrvLog=%IndexFile%.log
  974. call logmsg.cmd "Index file name is %IndexFile%"
  975. REM ********************************************
  976. REM Incremental Symsrv
  977. REM
  978. REM Decide if this is an incremental build
  979. REM Get set up for incremental symbol indexing
  980. REM ********************************************
  981. set st=%SymsrvDir%\temp
  982. set bindiff=%SymsrvDir%\mybindiff.txt
  983. set ml=perl %RazzleToolPath%\makelist.pl
  984. if exist %bindiff% del /f /q %bindiff%
  985. if defined cleanbuild (
  986. call logmsg "Cleanbuild is defined -- will create full indexes"
  987. goto CreateFullIndex
  988. )
  989. REM Now, use the makefile to create a list of what's has changed.
  990. call logmsg "Creating %bindiff%"
  991. nmake /f %SymsrvMakefile% %SymsrvLatest% >nul
  992. set /a BinDiffCount=0
  993. if exist %bindiff% (
  994. for /f %%a in (%bindiff%) do (
  995. set /a BinDiffCount=!BinDiffCount! + 1
  996. if !BinDiffCount! GEQ 50 goto CreateFullIndex
  997. )
  998. ) else (
  999. goto CreateFullIndex
  1000. )
  1001. call logmsg "Creating incremental symbol server index lists"
  1002. REM Save bindiff.txt so we can see what happened
  1003. call logmsg "saving bindiff.txt in %st%\bindiff.!count!"
  1004. copy %bindiff% %st%\bindiff.!count!
  1005. REM Decide if anything is even relevant
  1006. REM Put the files that need to be updated into %IncrementalList%
  1007. for %%a in ( bin pri pub ) do (
  1008. if exist %st%\%IndexFile%.inc.%%a del /f /q %st%\%IndexFile%.inc.%%a
  1009. if exist %st%\%IndexFile%.inc.%%a.tmp del /f /q %st%\%IndexFile%.inc.%%a.tmp
  1010. if exist %st%\%IndexFile%.inc.%%a.keep del /f /q %st%\%IndexFile%.inc.%%a.keep
  1011. if exist %st%\%IndexFile%.%%a.remove del /f /q %st%\%IndexFile%.%%a.remove
  1012. if exist %st%\%IndexFile%.%%a.tmp2 del /f /q %st%\%IndexFile%.%%a.tmp2
  1013. )
  1014. REM See which directory each file is in to determine if it goes into the pri, pub, or bin file
  1015. REM Symstore does not append, so append each log file manually.
  1016. call logmsg.cmd "Creating indexes for the files in %bindiff% ..."
  1017. for /f %%a in ( %bindiff% ) do (
  1018. echo %%a | findstr /ic:"%_NTPostBld%\symbols.pri" >nul 2>nul
  1019. if !ERRORLEVEL! EQU 0 (
  1020. call logmsg "Adding %%a to pri file"
  1021. symstore.exe add /a /p /f %%a /g %_NTPostBld%\symbols.pri /x %st%\%IndexFile%.inc.pri > nul
  1022. ) else (
  1023. echo %%a | findstr /ic:"%_NTPostBld%\symbols" >nul 2>nul
  1024. if !ERRORLEVEL! EQU 0 (
  1025. call logmsg "Adding %%a to pub file"
  1026. symstore.exe add /a /p /f %%a /g %_NTPostBld%\symbols /x %st%\%IndexFile%.inc.pub >nul
  1027. ) else (
  1028. call logmsg "Adding %%a to bin file"
  1029. symstore.exe add /a /p /f %%a /g %_NTPostBld% /x %st%\%IndexFile%.inc.bin >nul
  1030. )
  1031. )
  1032. )
  1033. if /i "%lang%" NEQ "usa" goto EndSymsrvIncrementalDiff
  1034. REM
  1035. REM Munge the lists to decide which symbols to pull from symbols and
  1036. REM which to pull from symbols.pri
  1037. REM Subtract the pri list from the public list
  1038. REM
  1039. if not exist %st%\%IndexFile%.inc.pub goto EndSymsrvIncrementalDiff
  1040. if not exist %st%\%IndexFile%.inc.pri goto EndSymsrvIncrementalDiff
  1041. call logmsg "Removing %IndexFile%.pri entries from %IndexFile%.pub ..."
  1042. %ml% -d %st%\%IndexFile%.inc.pub %st%\%IndexFile%.inc.pri -o %st%\%IndexFile%.inc.pub.tmp
  1043. copy %st%\%IndexFile%.inc.pub.tmp %st%\%IndexFile%.inc.pub
  1044. del %st%\%IndexFile%.inc.pub.tmp
  1045. for %%a in (%st%\%IndexFile%.inc.pub) do (
  1046. if %%~za EQU 0 (
  1047. del /f /q %%a
  1048. call logmsg.cmd "There are no public symbols to index"
  1049. )
  1050. )
  1051. :EndSymsrvIncrementalDiff
  1052. REM Now, figure out which ones to keep. Only keep the ones that are actually in the
  1053. REM product and being put into the symbol cabs. This is why we look at symbolcd.txt.
  1054. REM
  1055. set symbolcd.txt=%langroot%\symbolcd.txt
  1056. call logmsg.cmd "Verifying new indexes with files listed in %symbolcd.txt% ..."
  1057. for %%a in ( bin pri pub ) do (
  1058. if exist %st%\%IndexFile%.inc.%%a (
  1059. for /f "tokens=1* delims=," %%b in ( %st%\%IndexFile%.inc.%%a ) do (
  1060. REM Only keep the ones that are in %symbolcd.txt%.
  1061. REM then add it to what we are indexing
  1062. if "%%a" == "bin" (
  1063. findstr /ilc:"%_NTPostBld%\%%b" %symbolcd.txt% >NUL
  1064. if !ERRORLEVEL! EQU 0 (
  1065. call logmsg.cmd "Keeping %%b in bin file"
  1066. echo %%b,%%c>>%st%\%IndexFile%.inc.%%a.keep
  1067. )
  1068. )
  1069. REM If its in symbols.pri and its public counterpart
  1070. REM is in symbolcd.txt go ahead and index it.
  1071. if "%%a" == "pri" (
  1072. findstr /ilc:"%%b" %symbolcd.txt% >NUL
  1073. if !ERRORLEVEL! EQU 0 (
  1074. call logmsg.cmd "Keeping %%b in pri file"
  1075. echo %%b,%%c>>%st%\%IndexFile%.inc.%%a.keep
  1076. )
  1077. )
  1078. if "%%a" == "pub" (
  1079. findstr /ilc:"%%b" %symbolcd.txt% >NUL
  1080. if !ERRORLEVEL! EQU 0 (
  1081. call logmsg.cmd "Keeping %%b in pub file"
  1082. echo %%b,%%c>>%st%\%IndexFile%.inc.%%a.keep
  1083. )
  1084. )
  1085. )
  1086. )
  1087. )
  1088. REM Now what's left is to replace the old entries with the new entries
  1089. REM If there is no file in add_requests, copy the file with the latest date
  1090. REM from add_finished. If there is a file in add_requests, then use that as
  1091. REM the starting point.
  1092. for %%a in ( bin pri pub ) do (
  1093. if exist %st%\%IndexFile%.inc.%%a.keep (
  1094. call logmsg.cmd "Creating the new %%a file ..."
  1095. if not exist %SymsrvDir%\add_requests\%IndexFile%.%%a (
  1096. set LatestFile=
  1097. for /f %%b in ('dir /b /od %SymsrvDir%\add_finished\*.%%a') do (
  1098. set LatestFile=%%b
  1099. )
  1100. if defined LatestFile (
  1101. call logmsg "Starting with %SymsrvDir%\add_finished\!LatestFile! "
  1102. copy /y %SymsrvDir%\add_finished\!LatestFile! %st%\%IndexFile%.%%a.tmp >nul
  1103. ) else (
  1104. call logmsg "No previous file to update in add_requests or add_finished"
  1105. )
  1106. ) else (
  1107. call logmsg "Starting with %SymsrvDir%\add_requests\%IndexFile%.%%a "
  1108. copy /y %SymsrvDir%\add_requests\%IndexFile%.%%a %st%\%IndexFile%.%%a.tmp >nul
  1109. )
  1110. REM What we need to do next is take out the old entry and replace it with the new one
  1111. REM For example, if we rebuild advapi32.dll, we don't need to index the advapi32.dll with the
  1112. REM old timestamp.
  1113. REM First, make a file with entries for everything that needs to be removed
  1114. if exist %st%\%IndexFile%.%%a.tmp (
  1115. call logmsg "Removing old files from previous list ..."
  1116. for /f "tokens=1* delims=," %%c in (%st%\%IndexFile%.inc.%%a.keep) do (
  1117. REM Find its corresponding entry in the old list and add it to
  1118. REM the list of things to remove
  1119. findstr /ilc:"%%c" %st%\%IndexFile%.%%a.tmp >>%st%\%IndexFile%.%%a.remove
  1120. if !ERRORLEVEL! EQU 0 (
  1121. call logmsg "Remove %%c"
  1122. )
  1123. )
  1124. REM Now, remove it by subtracting it from the index file
  1125. if exist %st%\%IndexFile%.%%a.remove (
  1126. for %%b in ( %st%\%IndexFile%.%%a.remove ) do (
  1127. if %%~zb GTR 0 (
  1128. %ml% -d %st%\%IndexFile%.%%a.tmp %st%\%IndexFile%.%%a.remove -o %st%\%IndexFile%.%%a.tmp2
  1129. ) else (
  1130. copy %st%\%IndexFile%.%%a.tmp %st%\%IndexFile%.%%a.tmp2 >nul
  1131. )
  1132. )
  1133. ) else (
  1134. copy %st%\%IndexFile%.%%a.tmp %st%\%IndexFile%.%%a.tmp2 >nul
  1135. )
  1136. )
  1137. REM Put the keep stuff at the end
  1138. call logmsg "Add new files we are going to keep"
  1139. type %st%\%IndexFile%.inc.%%a.keep >> %st%\%IndexFile%.%%a.tmp2
  1140. sort %st%\%IndexFile%.%%a.tmp2 > %SymsrvDir%\add_requests\%IndexFile%.%%a
  1141. call GenSSIFile.cmd -i %SymsrvDir%\add_requests\%IndexFile%.%%a -o %SymsrvDir%\add_requests\%IndexFile%_%%a -l %lang%
  1142. call logmsg.cmd "Update finished for %SymsrvDir%\add_requests\%IndexFile%.%%a"
  1143. ) else (
  1144. call logmsg.cmd "There are no new %%a files to index"
  1145. )
  1146. )
  1147. goto EndSymsrv
  1148. REM *******************************************************************
  1149. REM Full indexing for symbol server
  1150. REM
  1151. REM International builds will always subtract what is already indexed by
  1152. REM the US build.
  1153. REM
  1154. REM ********************************************************************
  1155. :CreateFullIndex
  1156. call logmsg "Creating full symbol server index lists"
  1157. REM Delete initial files
  1158. for %%a in ( bin pri pub ) do (
  1159. if exist %SymsrvDir%\add_requests\%IndexFile%.%%a del /f /q %SymsrvDir%\add_requests\%IndexFile%.%%a
  1160. if exist %SymsrvDir%\temp\%IndexFile%.%%a del /f /q %SymsrvDir%\temp\%IndexFile%.%%a
  1161. )
  1162. REM
  1163. REM Use symbolcd.txt as a list of what to index
  1164. REM
  1165. :IndexSymbolcdFiles
  1166. call logmsg "Creating %SymsrvDir%\add_requests\%IndexFile%.bin"
  1167. set ShareDir=%_NTPostBld%
  1168. set IndexDir=%_NTPostBld%
  1169. if not exist %symbolcd.txt% (
  1170. call errmsg.cmd "%symbolcd.txt% does not exist"
  1171. goto end
  1172. )
  1173. if /i "%lang%" == "usa" (
  1174. set LastBinaryFileSpec=
  1175. for /f "tokens=1,3 delims=," %%b in (%symbolcd.txt%) do (
  1176. REM store the binaries and symbols via symstore to .bin, .pri, .pub file
  1177. call :StoreSymbol %%b %%c
  1178. )
  1179. ) else (
  1180. for /f "tokens=1 delims=," %%b in (%symbolcd.txt%) do (
  1181. REM store the binaries and symbols via symstore to .bin, .pri, .pub file
  1182. call :SymStoreRoutine %%b %ShareDir% bin
  1183. )
  1184. )
  1185. REM Store the binaries and private symbols for files that we don't ship publicly on
  1186. REM the symbol server.
  1187. if /i "%lang%" == "usa" (
  1188. call logmsg "Adding files in %RazzleToolPath%\symdontship.txt to symbol server lists"
  1189. set LastBinaryFileSpec=
  1190. for /f "tokens=1 delims= " %%b in (%RazzleToolPath%\symdontship.txt) do (
  1191. REM store the binaries and symbols via symstore to .bin, .pri, .pub file
  1192. set ext=%%~xb
  1193. set ext=!ext:~1,3!
  1194. if exist %_NTPostBld%\%%b (
  1195. if exist %_NTPostBld%\symbols\retail\!ext!\%%~nb.pdb (
  1196. call :StoreSymbol %_NTPostBld%\%%b symbols\retail\!ext!\%%~nb.pdb
  1197. )
  1198. )
  1199. )
  1200. ) else (
  1201. for /f "tokens=1 delims= " %%b in (%RazzleToolPath%\symdontship.txt) do (
  1202. REM store the binaries and symbols via symstore to .bin, .pri, .pub file
  1203. call :SymStoreRoutine %_NTPostBld%\%%b %ShareDir% bin
  1204. )
  1205. )
  1206. if exist %ShareDir%\symbols.pri\instmsi\dll\msi_l.pdb (
  1207. call :SymStoreRoutine %ShareDir%\symbols.pri\instmsi\dll\msi_l.pdb %ShareDir%\symbols.pri pri
  1208. )
  1209. REM Now, use these to create a makefile for incremental builds
  1210. :CreateSymsrvMakefile
  1211. if exist %SymsrvMakefile% del /f /q %SymsrvMakefile%
  1212. echotime /n "%SymsrvLatest%: " >> %SymsrvMakefile%
  1213. for %%a in ( bin pri pub ) do (
  1214. if exist %SymsrvDir%\temp\%IndexFile%.%%a (
  1215. copy %SymsrvDir%\temp\%IndexFile%.%%a %SymsrvDir%\add_requests\%IndexFile%.%%a>nul 2>nul
  1216. REM generate the ssi file for the .pri, .bin and .pub
  1217. call GenSSIFile.cmd -i %SymsrvDir%\add_requests\%IndexFile%.%%a -o %SymsrvDir%\add_requests\%IndexFile%_%%a -l %lang%
  1218. )
  1219. if exist %SymsrvDir%\add_requests\%IndexFile%.%%a (
  1220. for /f "tokens=1 delims=," %%b in ( %SymsrvDir%\add_requests\%IndexFile%.%%a ) do (
  1221. echotime /N " \\" >> %SymsrvMakefile%
  1222. if /i "%%a" == "bin" (
  1223. echotime /N /n " %_NTPOSTBLD%\%%b">> %SymsrvMakefile%
  1224. )
  1225. if /i "%%a" == "pri" (
  1226. echotime /N /n " %_NTPOSTBLD%\symbols.pri\%%b">> %SymsrvMakefile%
  1227. )
  1228. if /i "%%a" == "pub" (
  1229. echotime /N /n " %_NTPOSTBLD%\symbols\%%b">> %SymsrvMakefile%
  1230. )
  1231. )
  1232. ) else (
  1233. call logmsg "%SymsrvDir%\add_requests\%IndexFile%.%%a does not exist"
  1234. )
  1235. )
  1236. echo.>> %SymsrvMakefile%
  1237. setlocal DISABLEDELAYEDEXPANSION
  1238. echo !echo $?^>^> %bindiff%>> %SymsrvMakefile%
  1239. setlocal ENABLEDELAYEDEXPANSION
  1240. REM if this is a usa forked build, subtract the original symbols that are already
  1241. REM indexed.
  1242. if /i "%lang%" == "usa" (
  1243. if not exist !SymsrvDir_1! (
  1244. REM This is a US build and it is not forked
  1245. goto EndSymsrv
  1246. )
  1247. REM Subtract previous indexes for the US build and only index
  1248. REM the changes in the fork
  1249. call logmsg "Removing files already indexed on symbol server"
  1250. for %%b in ( bin pri pub ) do (
  1251. if exist %SymsrvDir%\add_requests\%IndexFile%.%%b (
  1252. set us_file=
  1253. for /f %%c in ('dir /b /od %SymsrvDir_1%\add_finished\*.%%b') do (
  1254. set us_file=%SymsrvDir_1%\add_finished\%%c
  1255. )
  1256. if defined us_file (
  1257. call logmsg "Removing !us_file! from %SymsrvDir%\add_requests\%IndexFile%.%%b"
  1258. copy %SymsrvDir%\add_requests\%IndexFile%.%%b %st%\%IndexFile%.%%b.full
  1259. del /f /q %SymsrvDir%\add_requests\%IndexFile%.%%b
  1260. %ml% -d %st%\%IndexFile%.%%b.full !us_file! -o %st%\%IndexFile%.%%b.full.unsorted
  1261. sort %st%\%IndexFile%.%%b.full.unsorted > %SymsrvDir%\add_requests\%IndexFile%.%%b
  1262. ) else (
  1263. call logmsg "Nothing to subtract from %SymsrvDir%\add_requests\%IndexFile%.%%b"
  1264. )
  1265. @echo call GenSSIFile.cmd -i %SymsrvDir%\add_requests\%IndexFile%.%%b -o %SymsrvDir%\add_requests\Windows_%IndexFile%_%%b.ssi -l %lang%
  1266. call GenSSIFile.cmd -i %SymsrvDir%\add_requests\%IndexFile%.%%b -o %SymsrvDir%\add_requests\Windows_%IndexFile%_%%b.ssi -l %lang%
  1267. ) else (
  1268. call logmsg "%SymsrvDir%\add_requests\%IndexFile%.%%b does not exist -- no need to subtract"
  1269. )
  1270. )
  1271. )
  1272. :EndSymsrvDir_usa
  1273. REM For international builds, subtract what's already been indexed by the US build
  1274. :SymsrvDir_Intl
  1275. if /i "%lang%" NEQ "usa" (
  1276. call logmsg "Subtracting the US lists from the %lang% lists"
  1277. for %%b in ( bin ) do (
  1278. if exist %SymsrvDir%\add_requests\%IndexFile%.%%b (
  1279. REM Subtract files from the original USA dir and from the fork -
  1280. REM if they exist
  1281. for %%c in ( %SymsrvDir_1% %SymsrvDir_2% ) do (
  1282. REM Get the most recent US file that was indexed. If there was a fork
  1283. REM get the one that was indexed before the fork.
  1284. set us_file=
  1285. if /i "%%b" == "bin" (
  1286. if exist %%c\add_finished\*.%%b (
  1287. for /f %%d in ('dir /b /od %%c\add_finished\*.%%b') do (
  1288. set us_file=%%c\add_finished\%%d
  1289. )
  1290. )
  1291. ) else (
  1292. if exist %st%\us_pri_pub.txt (
  1293. set us_file=%st%\us_pri_pub.txt
  1294. )
  1295. )
  1296. if defined us_file (
  1297. call logmsg "Removing !us_file! from %SymsrvDir%\add_requests\%IndexFile%.%%b"
  1298. %ml% -d %SymsrvDir%\add_requests\%IndexFile%.%%b !us_file! -o %st%\%IndexFile%.%%b.tmp
  1299. sort %st%\%IndexFile%.%%b.tmp > %SymsrvDir%\add_requests\%IndexFile%.%%b
  1300. )
  1301. )
  1302. @echo call GenSSIFile -i %SymsrvDir%\add_requests\%IndexFile%.%%b -o %SymsrvDir%\add_requests\Windows_%IndexFile%_%%b.ssi -l %lang%
  1303. call GenSSIFile -i %SymsrvDir%\add_requests\%IndexFile%.%%b -o %SymsrvDir%\add_requests\Windows_%IndexFile%_%%b.ssi -l %lang%
  1304. ) else (
  1305. call logmsg "%SymsrvDir%\add_requests\%IndexFile%.%%b does not exist -- no need to subtract"
  1306. )
  1307. )
  1308. )
  1309. :EndSymsrvDir_intl
  1310. REM Now, make sure that none of them are 0
  1311. for %%a in ( bin pri pub ) do (
  1312. if exist %SymsrvDir%\add_requests\%IndexFile%.%%a (
  1313. for %%b in ( %SymsrvDir%\add_requests\%IndexFile%.%%a ) do (
  1314. if %%~zb EQU 0 (
  1315. call logmsg "Deleting 0 length file - %SymsrvDir%\add_requests\%IndexFile%.%%a"
  1316. del /f /q %SymsrvDir%\add_requests\%IndexFile%.%%a
  1317. )
  1318. )
  1319. )
  1320. )
  1321. :EndSymsrv
  1322. REM Create the latest.txt file
  1323. echo Don't delete this >> %SymsrvLatest%
  1324. REM
  1325. REM Check for errors
  1326. REM
  1327. if "%ThereWereErrors%" == "yes" goto end
  1328. goto end
  1329. REM
  1330. REM Report the symbol checking errors
  1331. REM
  1332. :ReportSymchkErrors
  1333. if "%ThereWereSymchkErrors%" == "no" goto EndReportSymchkErrors
  1334. if exist %symerror.txt% (
  1335. for /f "tokens=1 delims=" %%a in (%symerror.txt%) do (
  1336. call errmsg.cmd "%%a"
  1337. )
  1338. )
  1339. :EndReportSymchkErrors
  1340. goto :EOF
  1341. REM
  1342. REM Report the duplicate symbols and regenerate the symbolcd.txt without the duplicates
  1343. REM
  1344. :ReportSymbolDuplicatesAndFlatInstalledPath
  1345. if exist %symerror.log%.duplicates del %symerror.log%.duplicates>nul
  1346. call logmsg "Finding any duplicates in symbolcd.txt"
  1347. copy %symbolcd.txt% %symbolcd.txt%.backup
  1348. if errorlevel 1 (
  1349. call errmsg.cmd "Copy %symbolcd.txt% to %symbolcd.txt%.backup failed"
  1350. goto :EndReportSymbolDuplicatesAndFlatInstalledPath
  1351. )
  1352. REM
  1353. REM Remove the symbolcd.txt, because we will generate a new one
  1354. REM
  1355. del %symbolcd.txt%
  1356. if errorlevel 1 (
  1357. call errmsg.cmd "Delete %symbolcd.txt% failed"
  1358. goto :EndReportSymbolDuplicatesAndFlatInstalledPath
  1359. )
  1360. REM
  1361. REM Regenerate the symbolcd.txt by remove duplicates and flat installed path
  1362. REM Check duplicate : check the file if exist in the new symbolcd.txt
  1363. REM Flat installed path : %%~ni (ex. winnt32\dll => dll
  1364. REM
  1365. for /f "tokens=1,2,3,4 delims=," %%f in (%symbolcd.txt%.backup) do (
  1366. set duplicate_counter=0
  1367. findstr /ilc:"%%~nxf,%%g" %symbolcd.txt%>nul 2>nul
  1368. set StoreIt=!errorlevel!
  1369. set /A StoreIt+=0
  1370. if !StoreIt! equ 0 (
  1371. REM skip the duplicate record for FE symbols
  1372. findstr /ilc:"%%f,%%g" %symbolcd.txt%>nul 2>nul
  1373. if errorlevel 1 (
  1374. REM if it does not reference the same pdb, give an error
  1375. REM othewise, store this duplicate to symbolcd.txt (such as comctl32.dll)
  1376. set StoreIt=1
  1377. findstr /ilc:"%%h" %symbolcd.txt% >nul 2>nul
  1378. if errorlevel 1 (
  1379. REM call errmsg.cmd "%%f has the same symbol file %%g with other binaries"
  1380. @echo %%f>>%symerror.log%.duplicates
  1381. set StoreIt=0
  1382. )
  1383. )
  1384. )
  1385. if !StoreIt! neq 0 (
  1386. @echo %%f,%%g,%%h,%%~ni>>%symbolcd.txt%
  1387. )
  1388. )
  1389. :EndReportSymbolDuplicatesAndFlatInstalledPath
  1390. goto :EOF
  1391. :MungePublics
  1392. rem Munge publics breaks when coverage builds are made
  1393. rem since we don't really care about creating a symbol cd
  1394. rem for coverage builds, let skip this part
  1395. if defined _COVERAGE_BUILD (
  1396. call logmsg.cmd "Coverage build ... skipping MungePublics"
  1397. goto :EndMungePublics
  1398. )
  1399. set ThereWereErrors=
  1400. call logmsg "Adding type info to some public pdb files for debugging"
  1401. REM Save the values of CL, LINK, ML because they differ for VC6 and VC7
  1402. if /i "%_BuildArch%" == "x86" (
  1403. set CL_Save=%_CL_%
  1404. set LINK_Save=%_LINK_%
  1405. set ML_Save=%_ML_%
  1406. )
  1407. if exist %_NTPostBld%\pp\* (
  1408. for /f %%a in ('dir /b /ad %_NTPostBld%\pp') do (
  1409. set ext=%%a
  1410. set ext=!ext:~-3!
  1411. set file=%%a
  1412. set file=!file:~0,-4!
  1413. if "!file!.!ext!" NEQ "%%a" (
  1414. call errmsg "%_NTPostBld%\pp\!file!.!ext! name has wrong format"
  1415. goto MungePublicsError
  1416. )
  1417. if exist %_NTPostBld%\symbols\retail\!ext!\!file!.pdb (
  1418. call logmsg "Working on !file!.!ext!"
  1419. REM See if we need to do anything, or if the symbol file has already been updated
  1420. REM If the symbol file passes symbol checking, with types present then don't update it.
  1421. set update=yes
  1422. symchk /t /o %_NTPostBld%\%%a /s %_NTPostBld%\symbols\retail | findstr /ilc:"FAILED files = 0" >nul 2>nul
  1423. if !ERRORLEVEL! == 0 (
  1424. call logmsg "Skipping !file!.!ext! because it's public pdb already has type info in it."
  1425. ) else (
  1426. if not exist %_NTPostBld%\pp\%%a\original (
  1427. mkdir %_NTPostBld%\pp\%%a\original
  1428. )
  1429. if not exist %_NTPostBld%\pp\%%a\updated (
  1430. mkdir %_NTPostBld%\pp\%%a\updated
  1431. )
  1432. REM See if the pdb, if it exists, in original matches the exe in binaries
  1433. symchk /t %_NTPostBld%\%%a /s %_NTPostBld%\pp\%%a\original %PUB_SYM_FLAG% | findstr /ilc:"FAILED files = 0" >nul 2>nul
  1434. if !ERRORLEVEL! == 1 (
  1435. REM It doesn't match
  1436. call logmsg "Saving a copy of !file!.pdb to %_NTPostBld%\pp\%%a\original"
  1437. copy /y %_NTPostBld%\symbols\retail\!ext!\!file!.pdb %_NTPostBld%\pp\%%a\original >nul 2>nul
  1438. )
  1439. REM Verify that the pdb is good
  1440. symchk /t %PUB_SYM_FLAG% %_NTPostBld%\%%a /s %_NTPostBld%\pp\%%a\original | findstr /ilc:"FAILED files = 0" >nul 2>nul
  1441. if !ERRORLEVEL! == 1 (
  1442. call errmsg "Cannot copy the correct pdb file to %_NTPostBld%\pp\%%a\original"
  1443. goto MungePublicsError
  1444. )
  1445. if exist %_NTPostBld%\pp\%%a\*.* (
  1446. if exist %_NTPostBld%\pp\%%a\updated\!file!.pdb del /q %_NTPostBld%\pp\%%a\updated\!file!.pdb
  1447. copy /y %_NTPostBld%\pp\%%a\original\!file!.pdb %_NTPostBld%\pp\%%a\updated >nul 2>nul
  1448. if not exist %_NTPostBld%\pp\%%a\updated\!file!.pdb (
  1449. call errmsg "Copy failed for %_NTPostBld%\pp\%%a\original\!file!.pdb to %_NTPostBld%\pp\%%a\updated"
  1450. goto MungePublicsError
  1451. )
  1452. call logmsg "Pushing type info into the stripped !file!.pdb"
  1453. if exist %_NTPostBld%\pp\%%a\!file!.c (
  1454. set c_ext=c
  1455. ) else (
  1456. set c_ext=cpp
  1457. )
  1458. if /i "%_BuildArch%" == "x86" (
  1459. pdbdump %_NTPostBld%\pp\%%a\updated\!file!.pdb hdr | findstr /i 0000-0000-0000-000000000000 > nul
  1460. if !ERRORLEVEL! == 0 (
  1461. call logmsg "This is a vc6 pdb"
  1462. set _CL_=%CL_Save%
  1463. set _ML_=%ML_Save%
  1464. set _LINK_=%LINK_Save%
  1465. ) else (
  1466. call logmsg "This is a vc7 pdb"
  1467. set _CL_=
  1468. set _ML_=
  1469. set _LINK_=
  1470. )
  1471. )
  1472. cl /nologo /Zi /Gz /c %_NTPostBld%\pp\%%a\!file!.!c_ext! /Fd%_NTPostBld%\pp\%%a\updated\!file!.pdb /Fo%_NTPostBld%\pp\%%a\updated\!file!.obj
  1473. if !ERRORLEVEL! NEQ 0 (
  1474. call errmsg "cl /Zi /c %_NTPostBld%\pp\%%a\!file!.!c_ext! /Fd%_NTPostBld%\pp\%%a\updated\!file!.pdb had errors"
  1475. goto MungePublicsError
  1476. )
  1477. symchk /t /o %_NTPostBld%\%%a /s %_NTPostBld%\pp\%%a\updated | findstr /ilc:"FAILED files = 0" >nul 2>nul
  1478. if !ERRORLEVEL! == 1 (
  1479. call errmsg "The munged %_NTPostBld%\pp\%%a\updated\!file!.pdb doesn't match %_NTPostBld%\%%a"
  1480. goto MungePublicsError
  1481. )
  1482. del /q %_NTPostBld%\symbols\retail\!ext!\!file!.pdb
  1483. call logmsg "Copying %_NTPostBld%\pp\%%a\updated\!file!.pdb to %_NTPostBld%\symbols\retail\!ext!"
  1484. copy /y %_NTPostBld%\pp\%%a\updated\!file!.pdb %_NTPostBld%\symbols\retail\!ext! >nul 2>nul
  1485. REM Verify that this pdb got copied
  1486. symchk /t %PUB_SYM_FLAG% /o %_NTPostBld%\%%a /s %_NTPostBld%\pp\%%a\updated | findstr /ilc:"FAILED files = 0" >nul 2>nul
  1487. if !ERRORLEVEL! == 1 (
  1488. REM Try copying the original back
  1489. copy /y %_NTPostBld%\pp\%%a\original\!file!.pdb %_NTPostBld%\symbols\retail\!ext! >nul 2>nul
  1490. call errmsg "The munged %_NTPostBld%\pp\%%a\updated\!file!.pdb didn't get copied to %_NTPostBld%\symbols\retail\!ext!"
  1491. call logmsg "Copying the original pdb back to %_NTPostBld%\symbols\retail\!ext!"
  1492. copy /y %_NTPostBld%\pp\%%a\original\!file!.pdb %_NTPostBld%\symbols\retail\!ext! >nul 2>nul
  1493. if not exist %_NTPostBld%\symbols\retail\!ext!\!file!.pdb (
  1494. call errmsg "Cannot get %%a symbols copied back to %_NTPostBld%\symbols\retail\!ext!"
  1495. goto MungePublicsError
  1496. )
  1497. goto MungePublicsError
  1498. )
  1499. )
  1500. )
  1501. ) else (
  1502. call logmsg "Skipping !file!.!ext! because %_NTPostBld%\symbols\retail\!ext!\!file!.pdb does not exist."
  1503. )
  1504. )
  1505. )
  1506. if /i "%_BuildArch%" == "x86" (
  1507. set _CL_=%CL_Save%
  1508. set _ML_=%ML_Save%
  1509. set _LINK_=%LINK_Save%
  1510. )
  1511. :EndMungePublics
  1512. goto :EOF
  1513. :MungePublicsError
  1514. set ThereWereErrors=TRUE
  1515. goto :EOF
  1516. REM *********************************************************************
  1517. REM StoreSymbol(BinaryFileSpec, PublicSymbolFileSpec)
  1518. REM
  1519. REM Call symstore to create the symbol link to .bin .pri and .pub
  1520. REM
  1521. REM *********************************************************************
  1522. :StoreSymbol
  1523. set BinaryFileSpec=%1
  1524. set PublicSymbolFileSpec=%2
  1525. set PrivateSymbolFileSpec=%PublicSymbolFileSpec:symbols=symbols.pri%
  1526. if /i "%LastBinaryFileSpec%" neq "%BinaryFileSpec%" (
  1527. call :SymStoreRoutine %BinaryFileSpec% %ShareDir% bin
  1528. set LastBinaryFileSpec=%BinaryFileSpec%
  1529. )
  1530. REM Skip to store symbol file if symbol file name is equal to binary file name.
  1531. REM It is for 16bit binaries.
  1532. if /i "%BinaryFileSpec%" EQU "%ShareDir%\%PublicSymbolFileSpec%" (
  1533. goto :EOF
  1534. )
  1535. REM Store Rule
  1536. REM 1. If private Symbol exist, store private symbol (in .pri)
  1537. REM 2. If not under symbols.pri or symbols folder, store the file thru %ShareDir% (in .bin)
  1538. if exist "%ShareDir%\%PrivateSymbolFileSpec%" (
  1539. if /i "%PrivateSymbolFileSpec:~0,12%" EQU "symbols.pri\" (
  1540. call :SymStoreRoutine %ShareDir%\%PrivateSymbolFileSpec% %ShareDir%\symbols.pri pri
  1541. goto :EOF
  1542. )
  1543. call :SymStoreRoutine %ShareDir%\%PrivateSymbolFileSpec% %ShareDir% bin
  1544. goto :EOF
  1545. )
  1546. if exist "%ShareDir%\%PublicSymbolFileSpec%" (
  1547. if /i "%PublicSymbolFileSpec:~0,8%" EQU "symbols\" (
  1548. call :SymStoreRoutine %ShareDir%\%PublicSymbolFileSpec% %ShareDir%\symbols pub
  1549. goto :EOF
  1550. )
  1551. call :SymStoreRoutine %ShareDir%\%PublicSymbolFileSpec% %ShareDir% bin
  1552. goto :EOF
  1553. )
  1554. REM If we can not find the symbol file, we should repro the error
  1555. call errmsg.cmd "Can not find symbol file %ShareDir%\%PublicSymbolFileSpec%"
  1556. :EndStoreSymbol
  1557. goto :EOF
  1558. REM *********************************************************************
  1559. REM SymStoreRoutine(FileSpec, ShareDirLoc, StoreType)
  1560. REM
  1561. REM Call symstore for sending the vary part
  1562. REM
  1563. REM *********************************************************************
  1564. :SymStoreRoutine
  1565. set FileSpec=%1
  1566. set ShareDirLoc=%2
  1567. set StoreType=%3
  1568. symstore.exe add /a %RecursiveSymStore% /p /f %FileSpec% /g %ShareDirLoc% /x %SymsrvDir%\temp\%IndexFile%.!StoreType! >> %SymsrvDir%\temp\symstore.err
  1569. if errorlevel 1 (
  1570. call errmsg.cmd "SymStore Error - symstore.exe add /a %RecursiveSymStore% /p /f %FileSpec% /g %ShareDirLoc% /x %SymsrvDir%\temp\%IndexFile%.!StoreType!
  1571. )
  1572. :EndSymStoreRoutine
  1573. goto :EOF
  1574. REM *********************************************************************
  1575. REM ReMD(Path)
  1576. REM
  1577. REM Remove directory and create a new one
  1578. REM
  1579. REM *********************************************************************
  1580. :ReMD
  1581. call logmsg.cmd "Remove and Create directory %1"
  1582. set ReMDPath=%1
  1583. if exist %ReMDPath% (
  1584. rd %ReMDPath% /s /q
  1585. )
  1586. MD %ReMDPath%
  1587. if errorlevel 1 (
  1588. call errmsg.cmd "Cannot create %ReMDPath% correctly."
  1589. )
  1590. goto :EOF
  1591. REM This puts the symbol errors in the symbol error log into the error file
  1592. REM for congeal scripts. %1 is the symbol error log that is passed in.
  1593. REM If there are errors, the script should continue on and finish, but know
  1594. REM later that there were errors, so that it can goto end when the script
  1595. REM is done. That's the purpose of having the ThereWereSymchkErrors variable.
  1596. goto end
  1597. :LogSymbolErrors
  1598. for /f "tokens=1,2* delims= " %%f in (%1) do (
  1599. if /i not "%%g" == "FAILED" (
  1600. if /i not "%%g" == "PASSED" (
  1601. if /i not "%%g" == "IGNORED" (
  1602. echotime "%%f %%g %%h" >>%symerror.txt%
  1603. set ThereWereSymchkErrors=yes
  1604. )))
  1605. )
  1606. goto :EOF
  1607. :ValidateParams
  1608. REM
  1609. REM Validate the option given as parameter.
  1610. REM
  1611. goto end
  1612. :Usage
  1613. REM Usage of the script
  1614. REM If errors, goto end
  1615. echo Usage: %script_name% [-l lang][-c][-m][-t][-?]
  1616. echo -l lang 2-3 letter language identifier
  1617. echo -c do a clean build
  1618. echo -m munge the public symbol files and then quit
  1619. echo -t test even though this isn't an official build machine
  1620. echo -? Displays usage
  1621. set ERRORS=1
  1622. goto end
  1623. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  1624. REM End Main code section
  1625. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  1626. :End_Main
  1627. goto PostMain
  1628. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  1629. REM Support Subs - Do not touch this section!
  1630. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  1631. :GetParams
  1632. REM
  1633. REM Parse the command line arguments
  1634. REM
  1635. set ERRORS=0
  1636. for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  1637. pushd %RazzleToolPath%\PostBuildScripts
  1638. set ERRORS=0
  1639. for /f "tokens=1 delims=;" %%c in ('perl.exe GetParams.pm %*') do (
  1640. set commandline=%%c
  1641. set commandtest=!commandline:~0,3!
  1642. if /i "!commandtest!" neq "set" (
  1643. if /i "!commandtest!" neq "ech" (
  1644. echo %%c
  1645. ) else (
  1646. %%c
  1647. )
  1648. ) else (
  1649. %%c
  1650. )
  1651. )
  1652. if "%errorlevel%" neq "0" (
  1653. set ERRORS=%errorlevel%
  1654. goto end
  1655. )
  1656. popd
  1657. goto end
  1658. :LocalEnvEx
  1659. REM
  1660. REM Manage local script environment extensions
  1661. REM
  1662. pushd %RazzleToolPath%\PostBuildScripts
  1663. for /f "tokens=1 delims=;" %%c in ('perl.exe LocalEnvEx.pm %1') do (
  1664. set commandline=%%c
  1665. set commandtest=!commandline:~0,3!
  1666. if /i "!commandtest!" neq "set" (
  1667. if /i "!commandtest!" neq "ech" (
  1668. echo %%c
  1669. ) else (
  1670. %%c
  1671. )
  1672. ) else (
  1673. %%c
  1674. )
  1675. )
  1676. if "%errorlevel%" neq "0" (
  1677. set errors=%errorlevel%
  1678. goto end
  1679. )
  1680. popd
  1681. goto end
  1682. :end
  1683. seterror.exe "%errors%"& goto :EOF
  1684. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  1685. REM Begin PostProcessing - Do not touch this section!
  1686. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  1687. :PostMain
  1688. REM
  1689. REM End the local environment extensions.
  1690. REM
  1691. call :LocalEnvEx -e
  1692. REM
  1693. REM Check for errors
  1694. REM
  1695. endlocal& seterror.exe "%errors%"