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.

249 lines
7.4 KiB

  1. @echo off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  5. REM Splits lists into a number of lists equal to number or processors
  6. REM Argumnent is input list. Output list is %tmp%\%lang%\filename.
  7. REM -------------------------------------------------------------------------------------------
  8. REM Template for the postbuild scripts:
  9. REM SD Location: %sdxroot%\tools\postbuildscripts
  10. REM
  11. REM (1) Code section description:
  12. REM PreMain - Developer adaptable code. Use this model and add your script params
  13. REM Main - Developer code section. This is where your work gets done.
  14. REM PostMain - Logging support code. No changes should be made here.
  15. REM
  16. REM (2) GetParams.pm - Usage
  17. REM run perl.exe GetParams.pm /? for complete usage
  18. REM
  19. REM (3) Reserved Variables -
  20. REM lang - The specified language. Defaults to USA.
  21. REM logfile - The path and filename of the logs file.
  22. REM logfile_bak - The path and filename of the logfile.
  23. REM errfile - The path and filename of the error file.
  24. REM tmpfile - The path and filename of the temp file.
  25. REM errors - The scripts errorlevel.
  26. REM script_name - The script name.
  27. REM script_args - The arguments passed to the script.
  28. REM CMD_LINE - The script name plus arguments passed to the script.
  29. REM _NTPostBld - Abstracts the language from the files path that
  30. REM postbuild operates on.
  31. REM _NTPostBld_Bak - Reserved support var.
  32. REM _temp_bak - Reserved support var.
  33. REM _logs_bak - Reserved support var.
  34. REM
  35. REM (4) Reserved Subs -
  36. REM Usage - Use this sub to discribe the scripts usage.
  37. REM ValidateParams - Use this sub to verify the parameters passed to the script.
  38. REM
  39. REM
  40. REM (8) Do not turn echo off, copy the 3 lines from the beginning of the template
  41. REM instead.
  42. REM
  43. REM (9) Use setlocal/endlocal as in this template.
  44. REM
  45. REM (10)Have your changes reviewed by a member of the US build team (ntbusa) and
  46. REM by a member of the international build team (ntbintl).
  47. REM
  48. REM -------------------------------------------------------------------------------------------
  49. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  50. REM Begin PreProcessing Section - Adapt this section but do not remove support
  51. REM scripts or reorder section.
  52. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  53. :PreMain
  54. REM
  55. REM Define SCRIPT_NAME. Used by the logging scripts.
  56. REM Define CMD_LINE. Used by the logging scripts.
  57. REM Define SCRIPT_ARGS. Used by the logging scripts.
  58. REM
  59. set SCRIPT_NAME=%~nx0
  60. set CMD_LINE=%script_name% %*
  61. set SCRIPT_ARGS=%*
  62. REM
  63. REM Parse the command line arguments - Add your scripts command line arguments
  64. REM as indicated by brackets.
  65. REM For complete usage run: perl.exe GetParams.pm /?
  66. REM
  67. for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  68. REM call :GetParams -n <add required prams> -o l:<add optional params> -p "lang <add variable names>" %SCRIPT_ARGS%
  69. call :GetParams -n s: -o l: -p "srcfile lang" %SCRIPT_ARGS%
  70. if errorlevel 1 goto :End
  71. REM
  72. REM Set up the local enviroment extensions.
  73. REM
  74. call :LocalEnvEx -i
  75. if errorlevel 1 goto :End
  76. REM
  77. REM Validate the command line parameters.
  78. REM
  79. call :ValidateParams
  80. if errorlevel 1 goto :End
  81. REM
  82. REM Execute Main
  83. REM
  84. call :Main
  85. :End_PreMain
  86. goto PostMain
  87. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  88. REM Begin Main code section
  89. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  90. REM (5) Call other executables or command scripts by using:
  91. REM call ExecuteCmd.cmd "<command>"
  92. REM Check for errors by using:
  93. REM if errorlevel 1 ...
  94. REM Note that the executable/script you're calling with ExecuteCmd must return a
  95. REM non-zero value on errors to make the error checking mechanism work.
  96. REM
  97. REM Example
  98. REM call ExecuteCmd.cmd "xcopy /f foo1 foo2"
  99. REM if errorlevel 1 (
  100. REM set errors=%errorlevel%
  101. REM goto end
  102. REM )
  103. REM
  104. REM (6) Log non-error information by using:
  105. REM call logmsg.cmd "<log message>"
  106. REM and log error information by using:
  107. REM call errmsg.cmd "<error message>"
  108. REM
  109. REM (7) Exit from the option routines with
  110. REM set errors=%errorlevel%
  111. REM goto end
  112. REM if errors found during execution and with
  113. REM goto end
  114. REM otherwise.
  115. :Main
  116. REM Main code section
  117. REM <Start your script's code here>
  118. REM If uniproc, skip altogether.
  119. if "%NUMBER_OF_PROCESSORS%" == "1" goto End
  120. set /a Count=0
  121. set FilePath=%srcfile%
  122. for %%j in (%FilePath%) do set FileName=%%~nj
  123. for /l %%j in (1,1,%NUMBER_OF_PROCESSORS%) do (
  124. if exist %tmp%\%FileName%.%%j del /f %tmp%\%FileName%.%%j
  125. )
  126. for /f "tokens=1,2" %%j in (%FilePath%) do (
  127. if !Count! == %NUMBER_OF_PROCESSORS% set Count=0
  128. set /a Count=!Count! + 1
  129. echo %%j %%k>>%tmp%\%FileName%.!Count!
  130. )
  131. goto end
  132. :ValidateParams
  133. REM
  134. REM Validate the option given as parameter.
  135. REM
  136. goto end
  137. :Usage
  138. REM Usage of the script
  139. REM If errors, goto errend
  140. echo Splits lists into a number of lists equal to number or processors
  141. echo Argumnent is input list. Output list is %tmp%\filename.#
  142. echo Usage: %script_name% -s srcfile [-l lang][-?]
  143. echo -s source path and filename
  144. echo -l lang 2-3 letter language identifier
  145. echo -? Displays usage
  146. set ERRORS=1
  147. goto end
  148. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  149. REM End Main code section
  150. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  151. :End_Main
  152. goto PostMain
  153. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  154. REM Support Subs - Do not touch this section!
  155. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  156. :GetParams
  157. REM
  158. REM Parse the command line arguments
  159. REM
  160. set ERRORS=0
  161. for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  162. pushd %RazzleToolPath%\PostBuildScripts
  163. set ERRORS=0
  164. for /f "tokens=1 delims=;" %%c in ('perl.exe GetParams.pm %*') do (
  165. set commandline=%%c
  166. set commandtest=!commandline:~0,3!
  167. if /i "!commandtest!" neq "set" (
  168. if /i "!commandtest!" neq "ech" (
  169. echo %%c
  170. ) else (
  171. %%c
  172. )
  173. ) else (
  174. %%c
  175. )
  176. )
  177. if "%errorlevel%" neq "0" (
  178. set ERRORS=%errorlevel%
  179. goto end
  180. )
  181. popd
  182. goto end
  183. :LocalEnvEx
  184. REM
  185. REM Manage local script environment extensions
  186. REM
  187. pushd %RazzleToolPath%\PostBuildScripts
  188. for /f "tokens=1 delims=;" %%c in ('perl.exe LocalEnvEx.pm %1') do (
  189. set commandline=%%c
  190. set commandtest=!commandline:~0,3!
  191. if /i "!commandtest!" neq "set" (
  192. if /i "!commandtest!" neq "ech" (
  193. echo %%c
  194. ) else (
  195. %%c
  196. )
  197. ) else (
  198. %%c
  199. )
  200. )
  201. if "%errorlevel%" neq "0" (
  202. set errors=%errorlevel%
  203. goto end
  204. )
  205. popd
  206. goto end
  207. :end
  208. seterror.exe "%errors%"& goto :EOF
  209. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  210. REM Begin PostProcessing - Do not touch this section!
  211. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  212. :PostMain
  213. REM
  214. REM End the local environment extensions.
  215. REM
  216. call :LocalEnvEx -e
  217. REM
  218. REM Check for errors
  219. REM
  220. endlocal& seterror.exe "%errors%"