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.

112 lines
3.1 KiB

  1. REM ------------------------------------------------------------------
  2. REM
  3. REM sxs_compress.cmd
  4. REM compress binary files(*.dll and *.cat) for fusion win32 assemblies
  5. REM during postbuild
  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. sxs_compress [-?]
  21. compress the binary files of Fusion Win32 Assembly during the postbuild
  22. -? this message
  23. USAGE
  24. parseargs('?' => \&Usage);
  25. # *** NEXT FEW LINES ARE TEMPLATE ***
  26. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  27. __END__
  28. :CPCBegin
  29. set _CPCMAGIC=
  30. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  31. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  32. setlocal ENABLEDELAYEDEXPANSION
  33. set asms_dir=%_nttree%\asms
  34. if /i "%Comp%" NEQ "Yes" goto :NoCompress
  35. if not "%1"=="" set asms_dir=%1
  36. set SxsCompressList=%temp%\sxs-compress.txt
  37. if EXIST %SxsCompressList% del /f /q %SxsCompressList%
  38. REM
  39. REM this list is unique for each manifest
  40. REM
  41. dir /s /b %asms_dir%\*.man > %SxsCompressList%
  42. call logmsg.cmd "Start: Compressing files (with update and rename) in %asms_dir%"
  43. for /f %%f in (%SxsCompressList%) do (
  44. REM
  45. REM create a temporary directory
  46. REM
  47. set AssemblyTempDir=%%~dpf%random%
  48. REM
  49. REM delete it as a directory
  50. REM
  51. if exist %AssemblyTempDir% rmdir /s /q %AssemblyTempDir%
  52. if "!errorlevel!" == "1" (
  53. call logmsg.cmd "Failed to create temporary directory %%AssemblyTempDir%%"
  54. goto :EOF
  55. )
  56. REM
  57. REM create directory
  58. REM
  59. call ExecuteCmd.cmd "md %%AssemblyTempDir%%"
  60. REM
  61. REM call compress to compress the dlls and catalogs,
  62. REM special case here is that some assembly does not have dll file at all
  63. REM
  64. if EXIST %%~dpf*.dll (
  65. call ExecuteCmd.cmd "compress -zx21 -s %%~dpf*.dll %%AssemblyTempDir%%"
  66. if "!errorlevel!" == "1" (
  67. call errmsg.cmd "Failed to compress Assembly Dlls under %%AssemblyTempDir%%"
  68. goto :EOF
  69. )
  70. )
  71. REM
  72. REM catalog of assembly is always there
  73. REM
  74. call ExecuteCmd.cmd "compress -zx21 -s %%~dpf*.cat %%AssemblyTempDir%%"
  75. if "!errorlevel!" == "1" (
  76. call errmsg.cmd "Failed to compress Assembly Catalog under %%AssemblyTempDir%%"
  77. goto :EOF
  78. )
  79. REM
  80. REM replace the uncompressed-original files with the compressed-files from the temporary directory
  81. REM
  82. call ExecuteCmd.cmd "move /Y %%AssemblyTempDir%%\*.* %%~dpf"
  83. if "!errorlevel!" == "1" (
  84. call errmsg.cmd "Failed to move compress Assembly file to originial directory"
  85. goto :EOF
  86. )
  87. REM
  88. REM remove the temporary directory
  89. REM
  90. call ExecuteCmd.cmd "rmdir /q %%AssemblyTempDir%%"
  91. )
  92. goto :EOF
  93. :NoCompress
  94. echo Not compressing files in %asms_dir% - Env. var "COMP" not set.
  95. goto :EOF