diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2011-08-09 15:52:57 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-25 08:55:51 +0000 |
commit | c52067ca0b79daf6ffae5376481e6fef74849254 (patch) | |
tree | 9a4b19451eb85dcd6e16afb9d49a45a2f4f5aa83 /mozilla/nsprpub/build/win32/pgomerge.py | |
parent | 40d4517c5b760454c076064fac192b28a22e7a37 (diff) | |
download | nspr-c52067ca0b79daf6ffae5376481e6fef74849254.tar.gz |
Imported from /srv/lorry/lorry-area/nspr/nspr-4.8.9.tar.gz.HEADnspr-4.8.9master
Diffstat (limited to 'mozilla/nsprpub/build/win32/pgomerge.py')
-rw-r--r-- | mozilla/nsprpub/build/win32/pgomerge.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mozilla/nsprpub/build/win32/pgomerge.py b/mozilla/nsprpub/build/win32/pgomerge.py new file mode 100644 index 0000000..383457b --- /dev/null +++ b/mozilla/nsprpub/build/win32/pgomerge.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# Usage: pgomerge.py <binary basename> <dist/bin> +# Gathers .pgc files from dist/bin and merges them into +# $PWD/$basename.pgd using pgomgr, then deletes them. +# No errors if any of these files don't exist. + +import sys, os, os.path, subprocess +if not sys.platform == "win32": + raise Exception("This script was only meant for Windows.") + +def MergePGOFiles(basename, pgddir, pgcdir): + """Merge pgc files produced from an instrumented binary + into the pgd file for the second pass of profile-guided optimization + with MSVC. |basename| is the name of the DLL or EXE without the + extension. |pgddir| is the path that contains <basename>.pgd + (should be the objdir it was built in). |pgcdir| is the path + containing basename!N.pgc files, which is probably dist/bin. + Calls pgomgr to merge each pgc file into the pgd, then deletes + the pgc files.""" + if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir): + return + pgdfile = os.path.abspath(os.path.join(pgddir, basename + ".pgd")) + if not os.path.isfile(pgdfile): + return + for file in os.listdir(pgcdir): + if file.startswith(basename+"!") and file.endswith(".pgc"): + try: + pgcfile = os.path.normpath(os.path.join(pgcdir, file)) + subprocess.call(['pgomgr', '-merge', + pgcfile, + pgdfile]) + os.remove(pgcfile) + except OSError: + pass + +if __name__ == '__main__': + if len(sys.argv) != 3: + print >>sys.stderr, "Usage: pgomerge.py <binary basename> <dist/bin>" + sys.exit(1) + MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2]) |