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.

757 lines
23 KiB

  1. @if "%_echo%"=="" echo off
  2. rem setting title based on some info
  3. @rem
  4. @rem Set some basic vars based on the path of this script
  5. @rem
  6. if "%RazzleScriptName%" == "" set RazzleScriptName=razzle
  7. if defined RazzleToolPath set RazzleAlreadyDefined=1
  8. set RazzleToolPath=%~dp0
  9. @rem Sometimes cmd leaves the trailing backslash on - remove it.
  10. if "%RazzleToolPath:~-1%" == "\" set RazzleToolPath=%RazzleToolPath:~0,-1%
  11. set _NTDRIVE=%~d0
  12. set _nttemproot=%~p0
  13. @rem Sometimes cmd leaves the trailing backslash on - remove it.
  14. if "%_nttemproot:~-1%" == "\" set _nttemproot=%_nttemproot:~0,-1%
  15. @rem Remove the trailing \tools if it exists.
  16. if /I "%_nttemproot:~-6%" == "\tools" set _nttemproot=%_nttemproot:~0,-6%
  17. set _NTROOT=%_nttemproot%
  18. set _nttemproot=
  19. @rem
  20. @rem Parse command line arguments
  21. @rem
  22. @rem
  23. @rem Please name all local variables to handle arguments "_ArgWhatever".
  24. @rem
  25. set _ArgAmd64=false
  26. set _ArgBinDir=
  27. set _ArgCheckDepots=false
  28. set _ArgChkKrnl=false
  29. set _ArgDotnet=false
  30. set _ArgEmulDir=
  31. set _ArgEmulation=false
  32. set _ArgEnigmaSigning=false
  33. set _ArgFiltDir=
  34. set _ArgFree=false
  35. set _ArgNTTest=false
  36. set _ArgNgws=false
  37. set _ArgNoBatch=false
  38. set _ArgNoBin=false
  39. set _ArgNoCert=false
  40. set _ArgNoOpt=false
  41. set _ArgNoPrefast=false
  42. set _ArgNoSDRefresh=false
  43. set _ArgNoTitle=false
  44. set _ArgNoURT=false
  45. set _ArgOfficial=false
  46. set _ArgOffline=false
  47. set _ArgPocketPC=false
  48. set _ArgRemoteServer=false
  49. set _ArgRestPath=false
  50. set _ArgSepChar=.
  51. set _ArgSvcPackDir=
  52. set _ArgTemp=
  53. set _ArgVaultSigning=false
  54. set _ArgWin64=false
  55. set _ArgWin32=false
  56. set _Arg_NTPostBld=
  57. set _Arg_Qfe=
  58. if defined RazzleAlreadyDefined echo Razzle.cmd must be run from clean cmd window&goto Usage
  59. if defined MAIN_BUILD_LAB_MACHINE (
  60. REM default to CSP signing for main build lab
  61. set _ArgVaultSigning=true
  62. )
  63. @rem The "exec" argument has special cleanup semantics
  64. set _ExecParams=false
  65. if exist %_NTDRIVE%%_NTROOT%\developer\%USERNAME%\setrazzle.cmd (
  66. call %_NTDRIVE%%_NTROOT%\developer\%USERNAME%\setrazzle.cmd
  67. )
  68. @rem RazzleArguments is set by setrazzle.cmd above
  69. if not "%RazzleArguments%" == "" (
  70. echo Default Razzle Arguments: %RazzleArguments%
  71. call :NextArg %RazzleArguments% %1 %2 %3 %4 %5 %6 %7 %8 %9
  72. goto :eof
  73. )
  74. :NextArg
  75. if "%1" == "help" goto Usage
  76. if "%1" == "-?" goto Usage
  77. if "%1" == "/?" goto Usage
  78. if "%1" == "-help" goto Usage
  79. if "%1" == "/help" goto Usage
  80. if /I "%1" == "Amd64" set _ArgAmd64=true&goto ArgOk
  81. if /I "%1" == "Binaries_dir" set _ArgBinDir=%2&shift&goto ArgOK
  82. if /I "%1" == "CheckDepots" set _ArgCheckDepots=true&goto ArgOK
  83. if /I "%1" == "ChkKernel" set _ArgChkKrnl=true&goto ArgOK
  84. if /I "%1" == "Coverage" echo coverage parameter is no longer supported&goto Usage
  85. if /I "%1" == "DotNet" set _ArgDotnet=true&goto ArgOK
  86. if /I "%1" == "Emulation" set _ArgEmulation=true&&goto ArgOk
  87. if /I "%1" == "Enigma" set _ArgEnigmaSigning=true&goto ArgOK
  88. if /I "%1" == "Exec" set _ExecParams=true&shift&goto GetStarted
  89. if /I "%1" == "Filter_dir" set _ArgFiltDir=%2&shift&goto ArgOK
  90. if /I "%1" == "Free" set _ArgFree=true&goto ArgOK
  91. if /I "%1" == "NTTest" set _ArgNTTest=true&goto ArgOK
  92. if /I "%1" == "Ngws" set _ArgNgws=true&goto ArgOK
  93. if /I "%1" == "No_batch" set _ArgNoBatch=true&goto ArgOK
  94. if /I "%1" == "No_binaries" set _ArgNoBin=true&goto ArgOK
  95. if /I "%1" == "No_certcheck" set _ArgNoCert=true&goto ArgOK
  96. if /I "%1" == "No_opt" set _ArgNoOpt=true&goto ArgOK
  97. if /I "%1" == "No_prefast" set _ArgNoPrefast=true&goto ArgOK
  98. if /I "%1" == "No_sdrefresh" set _ArgNoSDRefresh=true&goto ArgOK
  99. if /I "%1" == "No_title" set _ArgNoTitle=true&goto ArgOK
  100. if /I "%1" == "No_urt" set _ArgNoURT=true&goto ArgOK
  101. if /I "%1" == "OfficialBuild" set _ArgOfficial=true&set _ArgRestPath=true&goto ArgOK
  102. if /I "%1" == "Offline" set _ArgOffline=true&goto ArgOK
  103. if /I "%1" == "Pocketpc" set _ArgPocketPC=true&&goto ArgOk
  104. if /I "%1" == "PrimaryBuild" set _ArgOfficial=true&goto ArgOK
  105. if /I "%1" == "RemoteServer" set _ArgRemoteServer=true&goto ArgOK
  106. if /I "%1" == "Restricted_path" set _ArgRestPath=true&goto ArgOK
  107. if /I "%1" == "Sepchar" set _ArgSepChar=%2&shift&goto ArgOK
  108. if /I "%1" == "SvcPack_dir" set _ArgSvcPackDir=%2&shift&goto ArgOK
  109. if /I "%1" == "Temp" set _ArgTemp=%2&shift&goto ArgOK
  110. if /I "%1" == "URT" set _ArgNoURT=false & goto ArgOK
  111. if /I "%1" == "UseMyStoreCert" goto ArgOK
  112. if /I "%1" == "VaultSign" set _ArgVaultSigning=true&goto ArgOK
  113. if /I "%1" == "Verbose" set _echo=1&&echo on&goto ArgOK
  114. if /I "%1" == "Win64" set _ArgWin64=true&goto ArgOK
  115. if /I "%1" == "Win32" set _ArgWin32=true&goto ArgOK
  116. if /I "%1" == "mui_magic" set MUI_MAGIC=1&goto ArgOK
  117. if /I "%1" == "qfe" set _ArgQfe=true&goto ArgOK
  118. if NOT "%1" == "" echo Unknown argument: %1&goto Usage
  119. if "%1" == "" goto :GetStarted
  120. :ArgOK
  121. shift
  122. goto :NextArg
  123. @rem
  124. @rem OK, do the real stuff now
  125. @rem
  126. :GetStarted
  127. @rem Win9x support
  128. if "%PROCESSOR_ARCHITECTURE%" == "" set PROCESSOR_ARCHITECTURE=x86
  129. if "%COPYCMD%" == "" set COPYCMD=/Y
  130. set HOST_PROCESSOR_ARCHITECTURE=%PROCESSOR_ARCHITECTURE%
  131. @rem Check for obvious mistakes
  132. if "%_ArgPocketPC%" == "true" (
  133. if "%_ArgWin64%" == "true" echo Win64 and PocketPC are mutually exclusive&goto Usage
  134. if "%_ArgAmd64%" == "true" echo AMD64 and PocketPC are mutually exclusive&goto Usage
  135. if NOT "%PROCESSOR_ARCHITECTURE%" == "x86" echo PocketPC is only built on X86&goto Usage
  136. )
  137. if "%_ArgEmulation%" == "true" (
  138. if "%_ArgWin64%" == "true" echo Win64 and Emulation are mutually exclusive&goto Usage
  139. if "%_ArgAmd64%" == "true" echo AMD64 and Emulation are mutually exclusive&goto Usage
  140. if "%_ArgPocketPC%" == "false" echo Emulation requires PocketPC&goto Usage
  141. )
  142. if "%_ArgAmd64%" == "true" (
  143. if "%_ArgWin64%" == "false" echo AMD64 requires Win64&goto Usage
  144. if NOT "%PROCESSOR_ARCHITECTURE%" == "x86" echo AMD64 is only built on X86&goto Usage
  145. )
  146. if "%_ArgWin32%" == "true" (
  147. if "%PROCESSOR_ARCHITECTURE%" == "x86" echo Win32 is only for non-x86 machines&goto Usage
  148. )
  149. @rem
  150. @rem the script engines write some keys that cause signing errors during postbuild
  151. @rem unless they're whacked. Just do it here if the build # is between 2410 and 2480.
  152. @rem
  153. for /f "tokens=3 delims=.]" %%i in ('ver') do set OS_BUILDNUMBER=%%i
  154. @rem Previous line doesn't work on NT4. [Some ancient build machines still use NT4.]
  155. if "%OS_BUILDNUMBER%" == "" set OS_BUILDNUMBER=1381
  156. if %OS_BUILDNUMBER% GEQ 2410 (
  157. if %OS_BUILDNUMBER% LEQ 2480 (
  158. regini %RazzleToolPath%\delsip.ini
  159. )
  160. )
  161. @rem
  162. @rem Start with a pure system path. If people want to muck it up they can do so in their setenv.cmd
  163. @rem This will ensure we can build 16-bit stuff (16-bit tools sometimes puke on long paths) AND start
  164. @rem with the same environment all the time.
  165. @rem
  166. set BASE_OS_PATH=%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem
  167. @rem Set the default inf stamp date for WinXp.
  168. set STAMPINF_DATE=07/01/2001
  169. set STAMPINF_VERSION=5.1.2535.0
  170. @rem
  171. @rem Put hook in for NTTest environment
  172. @rem
  173. if "%_ArgNTTest%" == "true" set NTTestEnv=1
  174. @rem
  175. @rem Enable offline building for the source kit (no MS network access)
  176. @rem
  177. if "%_ArgOffline%" == "true" (
  178. set BUILD_OFFLINE=1
  179. set _NO_DDK=1
  180. set _ArgNoPrefast=true
  181. set _ArgNoSDRefresh=true
  182. set _ArgNoCert=true
  183. set _ArgEnigmaSigning=false
  184. set _ArgVaultSigning=false
  185. )
  186. @rem check for cross building
  187. set RazzleToolPath_CrossPlatform=
  188. set HOST_TOOLS=
  189. @rem
  190. @rem Pocket PC support
  191. @rem
  192. if "%_ArgPocketPC%" == "true" (
  193. set _BuildPocketPC=PocketPC
  194. if "%_ArgEmulation%" == "true" (
  195. set POCKETPC_EMULATION=1
  196. set _BuildPocketPC=PocketPC Emulation
  197. set _ArgEmulDir=em
  198. )
  199. set HOST_TOOLS="PATH=%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%;%RazzleToolPath%;%BASE_OS_PATH%"
  200. @rem PocketPC is always ARM and there's no other tools except the x86 hosted variants
  201. set RazzleToolPath_CrossPlatform=%RazzleToolPath%\arm;
  202. set ARM=1
  203. set _BuildArch=arm
  204. @rem Prefast not available on ARM builds
  205. set _ArgNoPrefast=true
  206. set POCKETPC=1
  207. )
  208. @rem
  209. @rem Win64 support
  210. @rem
  211. if "%_ArgWin64%" == "true" (
  212. set HOST_TOOLS="PATH=%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%;%RazzleToolPath%;%BASE_OS_PATH%"
  213. @rem Prefast not available on win64 builds
  214. set _ArgNoPrefast=true
  215. @rem If amd64 is set, use it otherwise, assume ia64.
  216. if "%_ArgAmd64%" == "true" (
  217. set _BuildArch=amd64
  218. set RazzleToolPath_CrossPlatform=%RazzleToolPath%\win64\%PROCESSOR_ARCHITECTURE%\amd64;
  219. ) else (
  220. set _BuildArch=ia64
  221. set RazzleToolPath_CrossPlatform=%RazzleToolPath%\win64\%PROCESSOR_ARCHITECTURE%;
  222. )
  223. if "%PROCESSOR_ARCHITECTURE%" == "x86" (
  224. @rem For now, managed toolset only exist on X86
  225. set MANAGED_TOOL_PATH=%RazzleToolPath%\x86\managed
  226. )
  227. )
  228. @rem
  229. @rem build x86 on win64, using the x86 on x86 tools
  230. @rem
  231. @rem THIS IT NOT SUPPORTED. USE AT YOUR OWN RISK.
  232. @rem
  233. @rem The parts of the tree that are built with 16bit tools will not build on Win64.
  234. @rem
  235. if "%_ArgWin32%" == "true" (
  236. set HOST_TOOLS="PATH=%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%;%RazzleToolPath%;%BASE_OS_PATH%"
  237. @rem assume Win32 is x86.
  238. set _BuildArch=x86
  239. set RazzleToolPath_CrossPlatform=%RazzleToolPath%\x86;
  240. set 386=1
  241. @rem Force compiler/linker to use VC6 debug formats if building for X86.
  242. set _ML_=/Zvc6
  243. set _CL_=/Ztmp
  244. set _LINK_=/tmp
  245. )
  246. @rem
  247. @rem Native Support
  248. @rem
  249. if "%RazzleToolPath_CrossPlatform%" == "" (
  250. @rem Must be a native build
  251. set _BuildArch=%PROCESSOR_ARCHITECTURE%
  252. if "%PROCESSOR_ARCHITECTURE%" == "x86" (
  253. set 386=1
  254. @rem Force compiler/linker to use VC6 debug formats if building for X86.
  255. set _ML_=/Zvc6
  256. set _CL_=/Ztmp
  257. set _LINK_=/tmp
  258. @rem For now, managed code only exists on X86.
  259. set MANAGED_TOOL_PATH=%RazzleToolPath%\x86\managed
  260. )
  261. )
  262. set BUILD_DEFAULT_TARGETS=-%_BuildArch%
  263. set %_BuildArch%=1
  264. set RazzleToolPath_Perl=%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%\perl\bin;
  265. set PERL5LIB=%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%\perl\site\lib;%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%\perl\lib
  266. set RazzleToolPath_Native=%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%
  267. if "%_ArgNoPrefast%" == "false" set RazzleToolPath_Prefast=%RazzleToolPath%\x86\prefast\scripts;
  268. @rem
  269. @rem Build up the path
  270. @rem
  271. set BUILD_PATH=%RazzleToolPath_CrossPlatform%
  272. if "%CORPATH%" == "" goto _NoCorPath
  273. set BUILD_PATH=%BUILD_PATH%%CORPATH%;
  274. :_NoCorPath
  275. set BUILD_PATH=%BUILD_PATH%%RazzleToolPath_Native%;%RazzleToolPath_Perl%%RazzleToolPath%;%BASE_OS_PATH%
  276. if "%MANAGED_TOOL_PATH%" == "" goto _NoManagedPath
  277. set BUILD_PATH=%BUILD_PATH%;%MANAGED_TOOL_PATH%\urt\v1.0.3705
  278. set BUILD_PATH=%BUILD_PATH%;%MANAGED_TOOL_PATH%\sdk\bin
  279. :_NoManagedPath
  280. set PATH=%RazzleToolPath_CrossPlatform%%RazzleToolPath_Native%;%RazzleToolPath_Perl%%RazzleToolPath%;%RazzleToolPath_Prefast%;%PATH%
  281. set RazzleToolPath_CrossPlatform=
  282. set RazzleToolPath_Perl=
  283. set RazzleToolPath_Native=
  284. set RazzleToolPath_Prefast=
  285. set BASE_OS_PATH=
  286. REM
  287. REM Install the URT.
  288. REM
  289. if "%MANAGED_TOOL_PATH%" == "" goto NoURTInstall
  290. if "%_ArgNoURT%" == "true" goto NoURTInstall
  291. call %MANAGED_TOOL_PATH%\urtinstall\urtinstall.cmd
  292. :NoURTInstall
  293. if "%UseUnsupportedOS%" == "" (
  294. if %OS_BUILDNUMBER% LEQ 2599 (
  295. echo Old OS build detected - Upgrade to XP ^(bld 2600^) or one of the .NET OS's ^(bld 35xx^)
  296. echo Old OS build detected - Upgrade to XP ^(bld 2600^) or one of the .NET OS's ^(bld 35xx^)
  297. sleep 5
  298. exit
  299. )
  300. )
  301. @rem
  302. @rem Set temp/tmp dirs if specified
  303. @rem
  304. if /i "%_ArgTemp%" == "" goto EndSetTemp
  305. set TEMP=%_ArgTemp%
  306. set TMP=%_ArgTemp%
  307. if NOT exist %_ArgTemp% (
  308. md %_ArgTemp% 2>Nul 1>Nul
  309. )
  310. :EndSetTemp
  311. @rem
  312. @rem Check/free build? Default to checked
  313. @rem
  314. set _KernelType=
  315. if "%_ArgFree%" == "true" goto BuildFree
  316. set NTDEBUG=ntsd
  317. set NTDEBUGTYPE=windbg
  318. set COMPRESS_PDBS=1
  319. set _BuildType=chk
  320. goto CheckOptimization
  321. :BuildFree
  322. set NTDEBUG=ntsdnodbg
  323. set NTDEBUGTYPE=windbg
  324. set COMPRESS_PDBS=1
  325. set _BuildType=fre
  326. if "%_ArgChkKrnl%" == "true" set BUILD_CHECKED_KERNEL=1&& set _KernelType=/ChkKernel
  327. :CheckOptimization
  328. @rem
  329. @rem Disable compiler optimizations?
  330. @rem
  331. set _BuildOpt=full opt
  332. if "%_ArgNoOpt%" == "true" set MSC_OPTIMIZATION=/Odi&& set _BuildOpt=no opt
  333. @rem
  334. @rem Binplace? Default to yes with base location of %_NTDRIVE%\binaries
  335. @rem
  336. if "%_ArgNoBin%" == "true" goto NoBinplace
  337. set BinariesDir=%_NTDRIVE%\binaries
  338. if "%_ArgQfe%" == "true" (
  339. set FilterDir=%_NTDRIVE%\qfe_filtered
  340. set SvcPackDir=%_NTDRIVE%\qfe_package
  341. ) else (
  342. set FilterDir=%_NTDRIVE%\filtered
  343. set SvcPackDir=%_NTDRIVE%\svcpack
  344. )
  345. @rem
  346. @rem Override base Binplace location? (Still append architecture and type)
  347. @rem
  348. if not "%_ArgBinDir%" == "" set BinariesDir=%_ArgBinDir%
  349. @rem
  350. @rem Override base filtered location? (Still append architecture and type)
  351. @rem
  352. if not "%_ArgFiltDir%" == "" (
  353. if "%_ArgQfe%" == "true" (
  354. set FilterDir=%_ArgFiltDir%_qfe
  355. ) else (
  356. set FilterDir=%_ArgFiltDir%
  357. )
  358. )
  359. @rem
  360. @rem Override base service pack binaries location? (Still append architecture and type)
  361. @rem
  362. if not "%_ArgSvcPackDir%" == "" (
  363. if "%_ArgQfe%" == "true" (
  364. set SvcPackDir=qfe_%_ArgSvcPackDir%
  365. ) else (
  366. set SvcPackDir=%_ArgSvcPackDir%
  367. )
  368. )
  369. :SetBinplace
  370. set _NT%_BuildArch%TREE=%BinariesDir%%_ArgSepChar%%_BuildArch%%_ArgEmulDir%%_BuildType%
  371. set _NTTREE=%BinariesDir%%_ArgSepChar%%_BuildArch%%_ArgEmulDir%%_BuildType%
  372. set NTDBGFILES=1
  373. set NTDBGFILES_PRIVATE=1
  374. set BINPLACE_FLAGS=-xa -:LOGPDB
  375. set BINPLACE_PLACEFILE_DEFAULT=%_NTDRIVE%%_NTROOT%\public\sdk\lib\placefil.txt
  376. if "%__MTSCRIPT_ENV_ID%"=="" (
  377. set BINPLACE_LOG=%BinariesDir%%_ArgSepChar%%_BuildArch%%_BuildType%\build_logs\binplace.log
  378. ) else (
  379. set BINPLACE_LOG=%BinariesDir%%_ArgSepChar%%_BuildArch%%_BuildType%\build_logs\binplace_%COMPUTERNAME%.log
  380. )
  381. set BINPLACE_EXCLUDE_FILE=%RazzleToolPath%\symbad.txt
  382. set NTBBT=1
  383. set _BuildBins=binaries in: %BinariesDir%%_ArgSepChar%%_BuildArch%%_ArgEmulDir%%_BuildType%
  384. set BinariesDir=
  385. :NoBinplace
  386. @rem
  387. @rem Define %_NTFilter% and %_NTPostBld% path for service pack process
  388. @rem
  389. set _NTFILTER=%FilterDir%%_ArgSepChar%%_BuildArch%%_ArgEmulDir%%_BuildType%
  390. set _NTPOSTBLD=%SvcPackDir%%_ArgSepChar%%_BuildArch%%_ArgEmulDir%%_BuildType%
  391. @rem
  392. @rem set vars etc for SD/SDX
  393. @rem
  394. if exist %RazzleToolPath%\SDINIT.CMD (
  395. call %RazzleToolPath%\SDINIT.CMD
  396. ) else (
  397. if "%SDCONFIG%" == "" set SDCONFIG=sd.ini
  398. if "%SDXROOT%" == "" set SDXROOT=%_NTDRIVE%%_NTROOT%
  399. )
  400. set SDDIFF=windiff.exe
  401. if "%_BuildPocketPC%" == "" (
  402. set _BuildWTitle=Build Window: %_BuildArch%/%_BuildType%%_KernelType%/%_BuildOpt%/%_BuildBins%%_PostBuildBins%
  403. ) else (
  404. set _BuildWTitle=Build Window: %_BuildPocketPC% %_BuildArch%/%_BuildType%%_KernelType%/%_BuildOpt%/%_BuildBins%%_PostBuildBins%
  405. )
  406. set BATCH_NMAKE=1
  407. @rem Make sure the sd client is current
  408. if "%_ArgNoSDRefresh%" == "false" call sdrefresh.cmd
  409. if "%_ArgOffline%" == "true" goto NoMyCert
  410. SET SIGNTOOL_SIGN=/a /uw /r "Microsoft Test Root Authority" /d "Microsoft Windows TEST" /du "http://ntbld"
  411. :NoMyCert
  412. if "%_ArgNoCert%" == "true" goto NoCertCheck
  413. @rem make sure the test root certificate is installed (so signcode etc will work).
  414. call CheckTestRoot.cmd
  415. call CheckTestPCA.cmd
  416. :NoCertCheck
  417. @rem Check if we have to sign with the enigma key
  418. if "%_ArgEnigmaSigning%" == "false" goto NoEnigma
  419. set Enigma=1
  420. :NoEnigma
  421. @rem Check if we should check for vault signatures
  422. if "%_ArgVaultSigning%" == "false" goto NoVaultSign
  423. set VAULTSIGN=1
  424. @rem Do not allow both Enigma and VaultSign to be set
  425. if "1" == "%ENIGMA%" (
  426. echo ERROR: Enigma and VaultSign options are both set...
  427. echo ERROR: Please choose one or the other.
  428. pause
  429. exit
  430. )
  431. :NoVaultSign
  432. @rem
  433. @rem perhaps update the prefast installation.
  434. @rem
  435. if "%_ArgNoPrefast%" == "true" goto NoPrefast
  436. set PREFAST_ROOT=%RazzleToolPath%\x86\prefast\
  437. set _Prefast=%RazzleToolPath%\x86\prefast\bin\modules
  438. set _PrefastVer=x
  439. set _PrefastCurrent=x
  440. if not exist "%_Prefast%\version.txt" goto PrefastCleanup
  441. if exist "%_Prefast%\installed.txt" (
  442. for /f "eol=;" %%p in (%_Prefast%\installed.txt) do set _PrefastVer=%%p
  443. ) else (
  444. set /a _PrefastVer=0
  445. )
  446. for /f "eol=;" %%p in (%_Prefast%\version.txt) do set _PrefastCurrent=%%p
  447. if /i %_PrefastVer% LSS %_PrefastCurrent% (
  448. echo Updating PREfast to version %_PrefastCurrent%
  449. call "%PREFAST_ROOT%scripts\regpft.bat"
  450. copy "%_Prefast%\version.txt" "%_Prefast%\installed.txt" 2>&1 >nul
  451. )
  452. :PrefastCleanup
  453. set _Prefast=
  454. set _PrefastVer=
  455. set _PrefastCurrent=
  456. :NoPrefast
  457. @rem
  458. @rem update the ACLs if necessary
  459. @rem
  460. if "%_ArgOffline%" == "true" goto NoRazAcl
  461. set SrcSDDLfile=%SDXROOT%\tools\sourceacl.txt
  462. set BinSDDLfile=%SDXROOT%\tools\binariesacl.txt
  463. if exist %_NTDRIVE%%_NTROOT%\developer\%USERNAME%\acl.txt (
  464. set SrcSDDLfile=%_NTDRIVE%%_NTROOT%\developer\%USERNAME%\acl.txt
  465. )
  466. if exist %_NTDRIVE%%_NTROOT%\developer\%USERNAME%\binacl.txt (
  467. set BinSDDLfile=%_NTDRIVE%%_NTROOT%\developer\%USERNAME%\binacl.txt
  468. )
  469. start /min razacl /SDDLfile:%SrcSDDLfile% /root:%SDXROOT%
  470. if "%_ArgOfficial%" == "false" (
  471. if /i not "%_NTTREE%" == "" ( if exist %_NTTREE% start /min razacl /SDDLfile:%BinSDDLfile% /root:%_NTTREE%)
  472. if /i not "%_NTPOSTBLD%" == "" ( if exist %_NTPOSTBLD% start /min razacl /SDDLfile:%BinSDDLfile% /root:%_NTPOSTBLD%)
  473. )
  474. set SrcSDDLfile=
  475. set BinSDDLfile=
  476. :NoRazAcl
  477. @rem
  478. @rem do this before setenv to allow people to override this slow, buggy cmd script
  479. @rem
  480. if NOT "%_ArgOffline%" == "true" (
  481. set BUILD_POST_PROCESS={Checkout Public Changes}%RazzleToolPath%\edit_public.cmd
  482. )
  483. @rem
  484. if EXIST %_NTDRIVE%%_NTROOT%\batch\setdbg.bat call %_NTDRIVE%%_NTROOT%\batch\setdbg.bat
  485. @rem And defer ntenv for the rest.
  486. call %_NTDRIVE%%_NTROOT%\TOOLS\ntenv.cmd
  487. @rem
  488. @rem Put hook in for ngws environment
  489. @rem
  490. if "%_ArgNgws%" == "true" call %SDXROOT%\proto\tools\ngwsenv.cmd
  491. @rem
  492. @rem Put hook in for dotnet environment
  493. @rem
  494. if "%_ArgDotnet%" == "true" call %SDXROOT%\hailstorm\tools\dotnetenv.cmd
  495. @rem
  496. @rem Now that we have called setenv, see it restricted_path is set. If it is, trim back PATH
  497. @rem
  498. if "%_ArgRestPath%" == "false" goto NoRestrictedPath
  499. path=%BUILD_PATH%
  500. :NoRestrictedPath
  501. if "%_ArgOffline%" == "true" goto NoPublicChangeNums
  502. pushd %_NTDRIVE%%_NTROOT%
  503. if NOT exist public mkdir public
  504. for %%i in (PUBLIC %BINARY_PUBLISH_PROJECTS%) do (
  505. if exist %_NTDRIVE%%_NTROOT%\%%i (
  506. call :GetPubChangeNum %%i
  507. ) else (
  508. echo No project %%i found. Ignoring.
  509. )
  510. )
  511. popd
  512. :NoPublicChangeNums
  513. @rem
  514. @rem Get the branch name for this enlistment
  515. @rem
  516. if "%_ArgOffline%" == "true" (
  517. set _BuildBranch=srckit
  518. ) else (
  519. for /f "eol=# tokens=1,2*" %%i in (%_NTBINDIR%\sd.map) do if "%%i" == "BRANCH" set _BuildBranch=%%k
  520. )
  521. if "%_ArgNoTitle%" == "true" goto NoTitle
  522. title %_BuildBranch% - %_BuildWTitle%
  523. :NoTitle
  524. @rem
  525. @rem Set the OFFICIAL_BUILD_MACHINE variable if appropriate
  526. @rem
  527. if "%_ArgOfficial%" == "true" call VerifyBuildMachine.cmd
  528. if NOT defined OFFICIAL_BUILD_MACHINE goto NotBuildMachine
  529. set __BUILDMACHINE__=%_BuildBranch%
  530. set NO_PDB_PATHS=1
  531. goto BuildMachineVarDefined
  532. :NotBuildMachine
  533. @rem
  534. @rem Public build machines (where mutiple people log in via TS and do buddy builds) need a
  535. @rem fixed __BUILDMACHINE__ define, or you get compiler errors when you don't build clean
  536. @rem
  537. @rem Don't set __BUILDMACHINE__ variable when building offline
  538. if "%_ArgOffline%" == "true" goto BuildMachineVarDefined
  539. if NOT "%PUBLIC_BUILD_MACHINE%" == "" set __BUILDMACHINE__=%_BuildBranch%(%COMPUTERNAME%)
  540. if NOT "%PUBLIC_BUILD_MACHINE%" == "" goto BuildMachineVarDefined
  541. set __BUILDMACHINE__=%_BuildBranch%(%USERNAME%)
  542. :BuildMachineVarDefined
  543. @rem call %RazzleToolPath%\BuildStrLen.cmd
  544. @rem
  545. @rem Verify that temp/tmp don't contain spaces (many build scripts don't handle this).
  546. @rem
  547. set __NoSpaceTemp=%TEMP: =%
  548. if "%__NoSpaceTemp%" == "%TEMP%" goto VerifyTmp
  549. echo ERROR: TEMP environment variable "%TEMP%"
  550. echo ERROR: contains spaces - Please remove
  551. pause
  552. exit
  553. :VerifyTmp
  554. set __NoSpaceTemp=%TMP: =%
  555. if "%__NoSpaceTemp%" == "%TMP%" goto TempOK
  556. echo ERROR: TMP environment variable "%TMP%"
  557. echo ERROR: contains spaces - Please remove
  558. pause
  559. exit
  560. :TempOK
  561. set __NoSpaceTemp=
  562. @rem
  563. @rem Start a remote session
  564. @rem
  565. if not "%_ArgRemoteServer%" == "true" goto NoRemote
  566. for /F "delims=\: tokens=1-3" %%a in ('echo %SDXROOT%') do set RemoteName=%%a_%%b
  567. remote /s cmd %RemoteName% /V %RemoteIDsAccepted%
  568. :NoRemote
  569. if "%_ArgCheckDepots%" == "true" call checkdepots.cmd
  570. :Cleanup
  571. @rem
  572. @rem Cleanup local variables
  573. @rem
  574. for /f "delims==" %%a in ('set _Arg') do set %%a=
  575. @rem
  576. @rem Remaining optional parameters to this script are command line to execute.
  577. @rem Use a name not starting with "_Arg" so it won't be cleaned up above.
  578. @rem
  579. if "%_ExecParams%" == "true" set _ExecParams=&%1 %2 %3 %4 %5 %6 %7 %8 %9
  580. set _ExecParams=
  581. goto :eof
  582. :GetPubChangeNum
  583. @rem Make sure there's a public change# available for this user.
  584. if exist %_NTDRIVE%%_NTROOT%\public\%1_CHANGENUM.SD goto :eof
  585. call get_change_num.cmd %1 %1_CHANGENUM.SD "Public Change number - Do not submit this unless you're the build lab for this branch"
  586. attrib +r public\%1_CHANGENUM.SD
  587. goto :eof
  588. :usage
  589. echo.
  590. echo Usage: %RazzleScriptName% ^<arguments^>
  591. echo.
  592. echo where ^<arguments^> can be one or more of:
  593. echo verbose - Enable verbose execution of this script
  594. echo ntttest - Build NT test sources
  595. echo Win64 - Build for Win64 target
  596. echo if on x86 and amd64 defined, build for amd64
  597. echo if on x86 and amd64 undefined build for ia64
  598. echo PocketPC - Build for ARM PocketPC target
  599. echo Emulation - Build PocketPC emulation target
  600. echo free - Build free bits (default is to build checked)
  601. echo chkkernel - Checked kernel/hal/ntdll (use with 'free')
  602. echo no_opt - disable compiler optimizations
  603. echo mui_magic - generate language neutral build
  604. echo no_binaries - disable creation of the binaries^<sepchar^>^<arch^>^<buildtype^> dir.
  605. echo binaries_dir - must specify ^<basepath^> immediately after this switch.
  606. echo Use specified path as binplace dir instead of default.
  607. echo Default value is "binaries".
  608. echo sepchar - overrides default separator character "." placed between
  609. echo the binaries_dir and the arch. Default value is "."
  610. echo Useful for putting binaries under a common parent
  611. echo directory using '\' (don't specify the quotes).
  612. echo temp - must specify ^<temp_dir^> immediately after this switch.
  613. echo Use specified path as TEMP and TMP values.
  614. echo Default value is set by the system.
  615. echo no_title - don't set the default window title bar.
  616. echo no_certcheck - don't ensure the testroot certificate is installed.
  617. echo no_sdrefresh - don't update sd.exe (for script use only)
  618. echo restricted_path - set path to the same restricted path that build uses
  619. echo (for debugging "why can't build find my tool" problems)
  620. echo officialbuild - Build as one of the official build machines for this branch.
  621. echo The machine and build type must be identified in
  622. echo %RazzleToolPath%\BuildMachines.txt.
  623. echo exec - Optionally execute the remaining command line.
  624. echo If specified, this must be the last razzle parameter
  625. echo specified. The remaining command line parameters are
  626. echo then passed to command prompt as is.
  627. echo Enigma - Will turn on CSP signing and CSP signature checks in advapi
  628. echo VaultSign - Will require that CSP's are vault signed with the Microsoft key
  629. goto Cleanup