PageRenderTime 40ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/build/win32/pgomerge.py

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Python | 40 lines | 24 code | 3 blank | 13 comment | 11 complexity | 7e19f50a375efa3aa35cb9214a75d5cc MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. #!/usr/bin/python
  2. # Usage: pgomerge.py <binary basename> <dist/bin>
  3. # Gathers .pgc files from dist/bin and merges them into
  4. # $PWD/$basename.pgd using pgomgr, then deletes them.
  5. # No errors if any of these files don't exist.
  6. import sys, os, os.path, subprocess
  7. if not sys.platform == "win32":
  8. raise Exception("This script was only meant for Windows.")
  9. def MergePGOFiles(basename, pgddir, pgcdir):
  10. """Merge pgc files produced from an instrumented binary
  11. into the pgd file for the second pass of profile-guided optimization
  12. with MSVC. |basename| is the name of the DLL or EXE without the
  13. extension. |pgddir| is the path that contains <basename>.pgd
  14. (should be the objdir it was built in). |pgcdir| is the path
  15. containing basename!N.pgc files, which is probably dist/bin.
  16. Calls pgomgr to merge each pgc file into the pgd, then deletes
  17. the pgc files."""
  18. if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir):
  19. return
  20. pgdfile = os.path.abspath(os.path.join(pgddir, basename + ".pgd"))
  21. if not os.path.isfile(pgdfile):
  22. return
  23. for file in os.listdir(pgcdir):
  24. if file.startswith(basename) and file.endswith(".pgc"):
  25. try:
  26. pgcfile = os.path.normpath(os.path.join(pgcdir, file))
  27. subprocess.call(['pgomgr', '-merge',
  28. pgcfile,
  29. pgdfile])
  30. os.remove(pgcfile)
  31. except OSError:
  32. pass
  33. if __name__ == '__main__':
  34. if len(sys.argv) != 3:
  35. print >>sys.stderr, "Usage: pgomerge.py <binary basename> <dist/bin>"
  36. sys.exit(1)
  37. MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2])