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.

116 lines
2.8 KiB

  1. @if "%_echo%" == "" echo off
  2. setlocal
  3. setlocal ENABLEEXTENSIONS
  4. setlocal ENABLEDELAYEDEXPANSION
  5. rem Do Args
  6. set Build=Invalid
  7. set Log=con:
  8. set DoIt=FALSE
  9. set Source=Invalid
  10. set FileList=%tmp%\FileDiffList
  11. set ImportList=%tmp%\ImportDiffList
  12. :ArgsLoop
  13. if "%1" == "" goto ArgsDone
  14. if "%1" == "-build" set Build=%2&& shift&& shift&& goto ArgsLoop
  15. if "%1" == "-log" set Log=%2&& shift&& shift&& goto ArgsLoop
  16. if "%1" == "-doit" set DoIt=TRUE&& shift&& goto ArgsLoop
  17. if "%1" == "-source" set Source=%2&& shift&& shift&& goto ArgsLoop
  18. goto Usage
  19. :ArgsDone
  20. if %Source% == Invalid goto DefaultSource
  21. goto CompFileLoop
  22. :DefaultSource
  23. if %Build% == Invalid goto Usage
  24. set SourceBase=\\tdsrc\SRC%Build%
  25. set Source=%SourceBase%\ese
  26. goto CompFileLoop
  27. :CompFileLoop
  28. set SourcePath=%Source%
  29. set DestPath=%CD%
  30. del /f %FileList% >nul: 2>&1
  31. del /f %ImportList% >nul: 2>&1
  32. del %LogFile% >nul: 2>&1
  33. for /D %%i in (%SourcePath%\*) do call :DirComp %SourcePath% . %%i
  34. rem
  35. rem a special path for the imported header files
  36. rem
  37. for %%i in (%DestPath%\eximport\*) do (
  38. set FullFile=%%~i
  39. set RelFile=!FullFile:%DestPath%\eximport\=!
  40. rem echo calling 'diff -b "!FullFile!" "%SourceBase%\exc\inc\!RelFile!"'>>%Log%
  41. diff -b "!FullFile!" "%SourceBase%\exc\inc\!RelFile!" >nul: 2>&1
  42. if !ERRORLEVEL! == 1 echo !RelFile!>>%ImportList%
  43. )
  44. if exist %FileList% goto ProcessFile
  45. if exist %ImportList% goto ProcessFile
  46. echo No differing files in common
  47. goto :EOF
  48. :ProcessFile
  49. if %DoIt% == TRUE goto CopyFiles
  50. echo DoIt flag not specified, files not copied
  51. goto :EOF
  52. :CopyFiles
  53. if not exist %FileList% goto CopyImports
  54. for /f %%F in (%FileList%) do (
  55. sd open %DestPath%\%%F
  56. copy /y %DestPath%\%%F %DestPath%\%%F.prev
  57. copy /y %SourcePath%\%%F %DestPath%\%%F
  58. )
  59. if not exist %ImportList% goto DoneCopy
  60. for /f %%F in (%ImportList%) do (
  61. sd open %DestPath%\eximport\%%F
  62. copy /y %DestPath%\eximport\%%F %DestPath%\eximport\%%F.prev
  63. copy /y %SourceBase%\exc\inc\%%F %DestPath%\eximport\%%F
  64. )
  65. :DoneCopy
  66. goto :EOF
  67. :Usage
  68. echo tdcopy [-build build] [-log logfile] [-doit] [-source sourcepath]
  69. goto :EOF
  70. :DirComp
  71. rem on entry, %1 is the source root, %2 is the dest root, %3 is the full path
  72. set SourceRoot=%1
  73. set DestRoot=%2
  74. set SourceFileFull=%3
  75. set SourceFileRel=!SourceFileFull:%SourceRoot%\=!
  76. echo Processing %SourceFileRel%>>%Log%
  77. for %%F in (%SourceFileFull%\*) do (
  78. set FullFile=%%~fF
  79. set RelFile=!FullFile:%SourceRoot%\=!
  80. rem echo calling 'diff -b "!FullFile!" "%DestRoot%\!RelFile!">>%Log%
  81. diff -b "!FullFile!" "%DestRoot%\!RelFile!" >nul: 2>&1
  82. if !ERRORLEVEL! == 1 echo !RelFile!>> %FileList%
  83. )
  84. for /D %%D in (%SourceFileFull%\*) do call :DirComp %SourceRoot% %DestRoot% %%D
  85. goto :EOF