Index: third_party/android_platform/development/scripts/symbol.py |
diff --git a/third_party/android_platform/development/scripts/symbol.py b/third_party/android_platform/development/scripts/symbol.py |
index b72253d63134446653e9db89dc97ddd6a8518394..2e7df376095100026c8c306164a8ed0adab66969 100755 |
--- a/third_party/android_platform/development/scripts/symbol.py |
+++ b/third_party/android_platform/development/scripts/symbol.py |
@@ -33,7 +33,7 @@ CHROME_SRC = os.path.join(os.path.realpath(os.path.dirname(__file__)), |
os.pardir, os.pardir, os.pardir, os.pardir) |
ANDROID_BUILD_TOP = CHROME_SRC |
SYMBOLS_DIR = CHROME_SRC |
-CHROME_SYMBOLS_DIR = CHROME_SRC |
+CHROME_SYMBOLS_DIR = None |
ARCH = "arm" |
@@ -202,34 +202,42 @@ def PathListJoin(prefix_list, suffix_list): |
""" |
return [ |
os.path.join(prefix, suffix) |
- for prefix in prefix_list for suffix in suffix_list ] |
+ for suffix in suffix_list for prefix in prefix_list ] |
-def GetCandidates(dirs, filepart, candidate_fun): |
+ |
+def _GetChromeOutputDirCandidates(): |
johnme
2015/10/20 15:40:20
This could perhaps reuse existing logic:
sys.path
agrieve
2015/10/20 18:24:27
Done.
|
+ """Returns a list of output directories to look in.""" |
+ out_dir = os.environ.get('CHROMIUM_OUTPUT_DIR') |
+ if out_dir: |
+ return [out_dir] |
+ out_dir = os.environ.get('CHROMIUM_OUT_DIR', 'out') |
+ out_dir = os.path.join(CHROME_SRC, out_dir) |
+ buildtype = os.environ.get('BUILDTYPE') |
+ if buildtype: |
+ buildtype_list = [ buildtype ] |
+ else: |
+ buildtype_list = [ 'Debug', 'Release' ] |
+ return PathListJoin([out_dir], buildtype_list) |
+ |
+ |
+def GetCandidates(dirs, filepart, candidate_fun, sort=True): |
"""Returns a list of candidate filenames. |
Args: |
dirs: a list of the directory part of the pathname. |
filepart: the file part of the pathname. |
candidate_fun: a function to apply to each candidate, returns a list. |
+ sort: Whether to sort by modification time (newest first). |
Returns: |
- A list of candidate files ordered by modification time, newest first. |
+ A list of candidate files filtered by candidate_fun, in the order given. |
""" |
- out_dir = os.environ.get('CHROMIUM_OUT_DIR', 'out') |
- out_dir = os.path.join(CHROME_SYMBOLS_DIR, out_dir) |
- buildtype = os.environ.get('BUILDTYPE') |
- if buildtype: |
- buildtype_list = [ buildtype ] |
- else: |
- buildtype_list = [ 'Debug', 'Release' ] |
- |
- candidates = PathListJoin([out_dir], buildtype_list) + [CHROME_SYMBOLS_DIR] |
- candidates = PathListJoin(candidates, dirs) |
- candidates = PathListJoin(candidates, [filepart]) |
+ candidates = PathListJoin(dirs, [filepart]) |
logging.debug('GetCandidates: prefiltered candidates = %s' % candidates) |
candidates = list( |
itertools.chain.from_iterable(map(candidate_fun, candidates))) |
- candidates = sorted(candidates, key=os.path.getmtime, reverse=True) |
+ if sort: |
+ candidates.sort(key=os.path.getmtime, reverse=True) |
return candidates |
def GetCandidateApks(): |
@@ -241,7 +249,8 @@ def GetCandidateApks(): |
Returns: |
list of APK filename which could contain the library. |
""" |
- return GetCandidates(['apks'], '*.apk', glob.glob) |
+ dirs = PathListJoin(_GetChromeOutputDirCandidates(), ['apks']) |
+ return GetCandidates(dirs, '*.apk', glob.glob, sort=True) |
def GetCrazyLib(apk_filename): |
"""Returns the name of the first crazy library from this APK. |
@@ -294,6 +303,12 @@ def MapDeviceApkToLibrary(device_apk_name): |
if crazy_lib: |
return crazy_lib |
+def GetLibrarySearchPaths(): |
+ if CHROME_SYMBOLS_DIR: |
+ return [CHROME_SYMBOLS_DIR] |
+ dirs = _GetChromeOutputDirCandidates() |
+ return PathListJoin(dirs, ['lib.unstripped', 'lib', 'lib.target', '.']) |
+ |
def GetCandidateLibraries(library_name): |
"""Returns a list of candidate library filenames. |
@@ -303,9 +318,12 @@ def GetCandidateLibraries(library_name): |
Returns: |
A list of matching library filenames for library_name. |
""" |
+ # Sorting doens't work for native libraries because the stripped version is |
johnme
2015/10/20 15:40:20
doesn't
agrieve
2015/10/20 18:24:27
Done.
|
+ # always newer than the unstripped version. |
johnme
2015/10/20 15:40:20
Hmm, but not sorting seems a risky way to get the
agrieve
2015/10/20 18:24:27
Like it. ;)
|
return GetCandidates( |
- ['lib', 'lib.target', '.'], library_name, |
- lambda filename: filter(os.path.exists, [filename])) |
+ GetLibrarySearchPaths(), library_name, |
+ lambda filename: filter(os.path.exists, [filename]), |
+ sort=False) |
def TranslateLibPath(lib): |
# The filename in the stack trace maybe an APK name rather than a library |