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.

154 lines
4.2 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM symcabgen.cmd
  5. REM Generates symbols.cab
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. if defined _CPCMAGIC goto CPCBegin
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. sub Usage { print<<USAGE; exit(1) }
  20. symcabgen -f:filename -s:DDFdir -t:<cab|cat> -d:destdir [-l <language>]
  21. -f filename of the cab (includes .cab)
  22. or the catalog file (does not include .CAT)
  23. -s DDF directoyr - this is where the makefile and the CDF files are located
  24. -t CAB or CAT to distinguish which is being created
  25. -d CAB or CAT destination directory
  26. USAGE
  27. parseargs('?' => \&Usage,
  28. 'f:'=> \$ENV{FILENAME},
  29. 's:'=> \$ENV{DDFDIR},
  30. 't:'=> \$ENV{TYPE},
  31. 'd:'=> \$ENV{DESTDIR});
  32. # *** NEXT FEW LINES ARE TEMPLATE ***
  33. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  34. __END__
  35. :CPCBegin
  36. set _CPCMAGIC=
  37. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  38. REM *** BEGIN YOUR 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 -n -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