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.

92 lines
3.7 KiB

  1. ' docopy.vbs
  2. ' This script (re)calculates the build number, creates a directory on the target machine
  3. ' with that build number as a directory name, then copies all the files identified in the
  4. ' filecopy.dat file to the destinations noted there.
  5. BUILDDEST = "\\b11nlbuilds\sapi5"
  6. BUILDER = "spgbld"
  7. BUILDMAIL = "spgmake"
  8. on error resume next
  9. ' VerifyPath takes the destination from the filecopy.dat, as modified to include BUILDDEST
  10. ' and the build number, and looks to see if the destination actually exists. It starts from
  11. ' the root of the name, BUILDDEST, and checks at each node to see if that folder exists; if
  12. ' not, it creates that folder, then continues down the destination name.
  13. sub VerifyPath(pathname)
  14. if right(pathname,1) <> "\" then 'strip off filename, if any
  15. beginfname = InStrRev(pathname, "\")
  16. pathname = left(pathname,len(pathname) - beginfname)
  17. end if
  18. lasttry = instr(pathname, BUILDDEST) + len(BUILDDEST) ' offset for known directory
  19. do while lasttry < (len(pathname) - 1)
  20. ptr = InStr(lasttry + 2, pathname, "\") - 1 'end of path component
  21. trial = left(pathname, ptr)
  22. if not fso.FolderExists(trial) then
  23. fso.CreateFolder(trial)
  24. end if
  25. lasttry = ptr
  26. loop
  27. end sub
  28. set wso = CreateObject("WScript.Shell")
  29. USER = wso.ExpandEnvironmentStrings("%USERNAME%")
  30. SAPIROOT = wso.ExpandEnvironmentStrings("%SAPIROOT%")
  31. ' The following if..then ensures that only the official builder will do
  32. ' the copy functions through the buildall command file. If the username
  33. ' in the environment is not that of the official builder, the loop will
  34. ' not be executed.
  35. if USER = BUILDER then
  36. set fso = CreateObject("Scripting.FileSystemObject")
  37. ' The following retrieves the build number from the
  38. ' currver.inc file that is generated by the build process
  39. set verfile = fso.GetFile(SAPIROOT & "\build\currver.inc")
  40. set fstream = verfile.OpenAsTextStream
  41. do while fstream.AtEndOfStream <> True
  42. linein = fstream.ReadLine
  43. if left(linein, 15) = "#define VERSION" then
  44. BuildNum = left(right(linein, 5), 4)
  45. end if
  46. loop
  47. fstream.Close()
  48. ' Now read the data file to find out which files to copy and
  49. ' where to put them.
  50. set file = fso.GetFile(SAPIROOT & "\builder\filecopy.dat")
  51. set fstream = file.OpenAsTextStream
  52. do while fstream.AtEndOfStream <> True
  53. linein = fstream.ReadLine
  54. if left(linein, 1) <> "#" then
  55. fromto = split(linein, ",")
  56. filefrom = SAPIROOT & "\" & trim(fromto(0))
  57. fileto = BUILDDEST & "\" & BuildNum & "\" & trim(fromto(1))
  58. VerifyPath(fileto)
  59. fso.CopyFile filefrom, fileto
  60. if err.number <> 0 then
  61. wscript.echo "Error: " & err.description & ": copying " & filefrom & " to " & fileto
  62. err.clear
  63. end if
  64. end if
  65. loop
  66. fstream.Close()
  67. ' Now an xcopy to get all the source & pdbs
  68. wso.Run("xcopy /s /i " & SAPIROOT & "\src\*.cpp " & BUILDDEST & "\" & BuildNum & "\src")
  69. wso.Run("xcopy /s /i " & SAPIROOT & "\src\*.h " & BUILDDEST & "\" & BuildNum & "\src")
  70. wso.Run("xcopy /s /i " & SAPIROOT & "\src\*.pdb " & BUILDDEST & "\" & BuildNum & "\src")
  71. wso.Run("xcopy /s /i " & SAPIROOT & "\QA\*.cpp " & BUILDDEST & "\" & BuildNum & "\src\QA")
  72. wso.Run("xcopy /s /i " & SAPIROOT & "\QA\*.h " & BUILDDEST & "\" & BuildNum & "\src\QA")
  73. wso.Run("xcopy /s /i " & SAPIROOT & "\QA\*.pdb " & BUILDDEST & "\" & BuildNum & "\src\QA")
  74. ' Clean up attributes on copied files
  75. wso.Run("attrib -r -h " & BUILDDEST & "\" & BuildNum & " /s")
  76. ' Get rid of slm.ini files from copied files
  77. wso.Run("del /s " & BUILDDEST & "\" & BuildNum & "\slm.ini")
  78. else
  79. permstring = "You are not the official builder, therefore your build "
  80. permstring = permstring & "will not be copied to the build repository. Please look "
  81. permstring = permstring & "for your result binaries in the appropriate directories."
  82. msgbox permstring, , "SPG Build Process"
  83. end if