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.

154 lines
4.4 KiB

  1. @REM ------------------------------------------------------------------
  2. @REM
  3. @REM symcabgen.cmd - BarbKess
  4. @REM Generates symbols.cab
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  8. @REM ------------------------------------------------------------------
  9. @if defined _CPCMAGIC goto CPCBegin
  10. @perl -x "%~f0" %*
  11. @goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use PbuildEnv;
  17. use ParseArgs;
  18. sub Usage { print<<USAGE; exit(1) }
  19. symcabgen -f:filename -s:DDFdir -t:<cab|cat> -d:destdir [-l <language>]
  20. -f filename of the cab (includes .cab)
  21. or the catalog file (does not include .CAT)
  22. -s DDF directoyr - this is where the makefile and the CDF files are located
  23. -t CAB or CAT to distinguish which is being created
  24. -d CAB or CAT destination directory
  25. USAGE
  26. parseargs('?' => \&Usage,
  27. 'f:'=> \$ENV{FILENAME},
  28. 's:'=> \$ENV{DDFDIR},
  29. 't:'=> \$ENV{TYPE},
  30. 'd:'=> \$ENV{DESTDIR});
  31. # *** TEMPLATE CODE ***
  32. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  33. __END__
  34. @:CPCBegin
  35. @set _CPCMAGIC=
  36. @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  37. @if not defined DEBUG echo off
  38. @REM *** CMD SCRIPT BELOW ***
  39. cd /d %ddfdir%
  40. if /i "%type%" == "CAT" (
  41. call logmsg "Starting %filename%.CAT"
  42. echo started %filename%.CAT > %ddfdir%\temp\%filename%.txt
  43. makecat -v %ddfdir%\%filename%.CDF > %ddfdir%\%filename%.CAT.log
  44. copy %ddfdir%\%filename%.CAT %destdir%\%filename%.CAT
  45. del /f /q %ddfdir%\temp\%filename%.txt
  46. ) else (
  47. call logmsg "Starting %filename%"
  48. echo started %filename% > %ddfdir%\temp\%filename%.txt
  49. for /f %%f in ('echo %filename%') do if exist %%~nf.txt del %%~nf.txt
  50. echo nmake %ddfdir%\makefile %destdir%\%filename% >> %ddfdir%\temp\%filename%.txt
  51. nmake makefile %destdir%\%filename%
  52. call :CompressMe %filename% %filename%
  53. del /f /q %ddfdir%\temp\%filename%.txt
  54. )
  55. goto end
  56. :CompressMe
  57. set CabFileName=%~n1.cab
  58. set CabFileSpec=%~dp1..\cabs\%~n1.cab
  59. set DependenceFile=%~n2.txt
  60. set WholeListFile=%~dp2..\..\%Lang%.bak\ddf.bak\%~n2.txt.bak
  61. set DDFFileName=%~n1.ddf
  62. echo CabFileSpec=%CabFileSpec%
  63. echo WholeListFile=%WholeListFile%
  64. set IncrementalFiles=
  65. REM Check Exist symbols?.txt
  66. if not exist %DependenceFile% (
  67. call logmsg "No need to regenerate the cab %CabFileName%"
  68. goto :EOF
  69. )
  70. REM File is Zero
  71. for %%t in ('echo %WholeListFile%') do (
  72. if "%%~zt"=="0" (
  73. call logmsg "Nothing to do"
  74. goto :EOF
  75. )
  76. )
  77. for %%f in (%WholeListFile%) do md %%~dpf 2>nul
  78. REM Compare to determine fully or incremental
  79. if exist %WholeListFile% (
  80. set /A DifferentFiles=0
  81. fc %DependenceFile% %WholeListFile%
  82. if errorlevel 1 (
  83. call logmsg "Create Incremental List"
  84. call :CreateList %DependenceFile% %DDFFileName%
  85. echo !IncrementalFiles!
  86. set /A DifferentFiles+=0
  87. @echo !DifferentFiles!
  88. if !DifferentFiles! LEQ 10 (
  89. @echo cabinc /s %CabFileSpec% !IncrementalFiles!
  90. cabinc /s %CabFileSpec% !IncrementalFiles!
  91. goto EndCabCreation
  92. )
  93. )
  94. )
  95. set ThisErrFile=%DDFFileName%.Output
  96. call logmsg.cmd "Create Whole Cab %CabFileName%"
  97. call logmsg.cmd "%DDFFileName%: Issuing makecab directive ..."
  98. call logmsg.cmd "Output is in %ThisErrFile% ..."
  99. call ExecuteCmd.cmd "makecab.exe /f %DDFFileName%"
  100. if %ErrorLevel% NEQ 0 (
  101. call errmsg.cmd "%CabFileName% : Failed to create cab ... here's the errors ..."
  102. for /f "tokens=1 delims=" %%a in (%ThisErrFile%) do (
  103. call errmsg.cmd "%%a"
  104. )
  105. ) else (
  106. call logmsg.cmd "%CabFileName% : Cab generation successful ..."
  107. REM Backup if is first time succesfuly ran
  108. if not exist %WholeListFile% (
  109. copy %DependenceFile% %WholeListFile%
  110. if errorlevel 1 (
  111. call errmsg "Copy Failed. - %DependenceFile%"
  112. goto :EOF
  113. )
  114. )
  115. )
  116. :EndCabCreation
  117. copy %DependenceFile% %DependenceFile%.bak
  118. del %DependenceFile%
  119. goto :EOF
  120. :CreateList
  121. set DependenceFileName=%1
  122. set DDFFileName=%2
  123. for /f %%a in (%DependenceFileName%) do (
  124. for /f "tokens=1,2" %%m in ('findstr /ilc:%%a %DDFFileName%') do (
  125. set /A DifferentFiles+=1
  126. set IncrementalFiles=!IncrementalFiles! %%n %%m
  127. )
  128. )
  129. goto :EOF
  130. :end
  131. seterror.exe "%errors%"& goto :EOF