Counter Strike : Global Offensive Source Code
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.

72 lines
2.6 KiB

  1. import glob, sys, os, stat, shutil
  2. g_nFilesCopied = 0
  3. g_nFilesAdded = 0
  4. g_nFilesSkipped = 0
  5. def IsSame( a, b ):
  6. return False
  7. if a.st_size == b.st_size:
  8. if a.st_mtime == b.st_mtime:
  9. return True #perhaps we need to actually compare the files??
  10. if abs( a.st_mtime - b.st_mtime ) < 1: # may not be runnable on all platforms, but runs fine on windows python 2.6+
  11. return True
  12. else:
  13. return False
  14. def Copy(fromDir, toDir, extensions):
  15. global g_nFilesCopied
  16. global g_nFilesAdded
  17. global g_nFilesSkipped
  18. if( toDir == "" ):
  19. toDir = os.getcwd()
  20. toDir = os.path.abspath( toDir )
  21. fromDir = os.path.abspath( fromDir )
  22. for root, subFolders, files in os.walk(fromDir):
  23. for file in files:
  24. if os.path.splitext(file)[1][1:].strip() in extensions and root[:len(fromDir)]==fromDir:
  25. fromFile = os.path.join(root, file)
  26. fromFileStat = os.stat( fromFile )
  27. toFile = os.path.join(toDir,root[len(fromDir)+1:],file)
  28. p4AddNeeded = True
  29. if( os.path.isfile( toFile ) ): #file exists already, if it's the same file, there's no need to copy anything
  30. p4AddNeeded = False
  31. toFileStat = os.stat( toFile )
  32. if( IsSame( toFileStat, fromFileStat ) ):
  33. g_nFilesSkipped += 1
  34. continue
  35. if not( toFileStat.st_mode & stat.S_IWRITE ):
  36. os.system( "p4 edit " + toFile )
  37. if os.path.exists( os.path.dirname( toFile ) ):
  38. if not os.path.isdir( os.path.dirname( toFile ) ):
  39. print "This is not a dir. Expected a dir: " + os.path.dirname( toFile )
  40. sys.exit(-1)
  41. else:
  42. os.makedirs( os.path.dirname( toFile ) )
  43. #print fromFile + " -> " + toFile
  44. shutil.copyfile( fromFile, toFile )
  45. os.utime( toFile, ( fromFileStat.st_atime, fromFileStat.st_mtime ) )
  46. if p4AddNeeded:
  47. g_nFilesAdded += 1
  48. os.system( "p4 add " + toFile )
  49. g_nFilesCopied += 1
  50. extInc = ["h","inc","inl","gen","def"]
  51. extLib = ["lib","pdb","def"]
  52. Copy( "f:/L/llvm.build64/tools/clang/include", "include/win64", extInc )
  53. Copy( "f:/L/llvm.build64/include", "include/win64", extInc )
  54. Copy( "f:/L/llvm.build/tools/clang/include", "include/win32", extInc )
  55. Copy( "f:/L/llvm.build/include", "include/win32", extInc )
  56. Copy( "f:/L/llvm/include", "include", extInc )
  57. Copy( "f:/L/llvm/tools/clang/include", "include", extInc )
  58. Copy( "f:/L/llvm.build64/lib/Debug", "lib/win64/Debug", extLib )
  59. Copy( "f:/L/llvm.build64/lib/RelWithDebInfo", "lib/win64/Release", extLib )
  60. Copy( "f:/L/llvm.build/lib/Debug", "lib/win32/Debug", extLib )
  61. Copy( "f:/L/llvm.build/lib/RelWithDebInfo", "lib/win32/Release", extLib )
  62. print "Files copied: %d, added: %d, skipped: %d" % ( g_nFilesCopied, g_nFilesAdded, g_nFilesSkipped )