Index: tools/symsrc/source_index.py |
diff --git a/tools/symsrc/source_index.py b/tools/symsrc/source_index.py |
old mode 100644 |
new mode 100755 |
index 816087262936cfca997be614b4f7179d14ec71ec..e2a58e02019559975ad47b52a04255c7f4bf2906 |
--- a/tools/symsrc/source_index.py |
+++ b/tools/symsrc/source_index.py |
@@ -1,6 +1,5 @@ |
#!/usr/bin/env python |
- |
-# Copyright (c) 2008 The Chromium Authors. All rights reserved. |
+# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
@@ -45,6 +44,7 @@ REPO_MAP = { |
"http://google-url.googlecode.com/svn": None, |
} |
+ |
def FindFile(filename): |
"""Return the full windows path to a file in the same dir as this code.""" |
thisdir = os.path.dirname(os.path.join(os.path.curdir, __file__)) |
@@ -61,6 +61,7 @@ def ExtractSourceFiles(pdb_filename): |
raise "srctool failed: " + filelist |
return [x for x in filelist.split('\r\n') if len(x) != 0] |
+ |
def ReadSourceStream(pdb_filename): |
"""Read the contents of the source information stream from a PDB.""" |
srctool = subprocess.Popen([FindFile('pdbstr.exe'), |
@@ -74,6 +75,7 @@ def ReadSourceStream(pdb_filename): |
raise "pdbstr failed: " + data |
return data |
+ |
def WriteSourceStream(pdb_filename, data): |
"""Write the contents of the source information stream to a PDB.""" |
# Write out the data to a temporary filename that we can pass to pdbstr. |
@@ -95,6 +97,7 @@ def WriteSourceStream(pdb_filename, data): |
os.unlink(fname) |
+ |
# TODO for performance, we should probably work in directories instead of |
# files. I'm scared of DEPS and generated files, so for now we query each |
# individual file, and don't make assumptions that all files in the same |
@@ -119,6 +122,7 @@ def ExtractSvnInfo(local_filename): |
return [root, path, rev] |
+ |
def UpdatePDB(pdb_filename, verbose=False): |
"""Update a pdb file with source information.""" |
dir_blacklist = { } |
@@ -190,13 +194,19 @@ def UpdatePDB(pdb_filename, verbose=False): |
WriteSourceStream(pdb_filename, '\r\n'.join(lines)) |
-if __name__ == '__main__': |
+ |
+def main(): |
if len(sys.argv) < 2 or len(sys.argv) > 3: |
print "usage: file.pdb [-v]" |
- sys.exit(1) |
+ return 1 |
verbose = False |
if len(sys.argv) == 3: |
verbose = (sys.argv[2] == '-v') |
UpdatePDB(sys.argv[1], verbose=verbose) |
+ return 0 |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |