diff options
author | Peter Wen <wnwen@chromium.org> | 2018-04-20 02:57:10 +0900 |
---|---|---|
committer | Qijiang Fan <fqj@google.com> | 2020-06-05 09:06:56 +0900 |
commit | fc8c22a25e94b998d500cd4288694399cfc226dc (patch) | |
tree | 4b166403cbbd82f7b2a3adfacba7638b208e167f /build | |
parent | 05d83e3d4086917d5ae283f057b74205d4c04e6e (diff) | |
download | libchrome-fc8c22a25e94b998d500cd4288694399cfc226dc.tar.gz |
Supersize: Properly attribute res/ symbols
Create .info files for resources during jinja processing, aapt2
compressing, and aapt2 linking, using these .info files to create a
per-apk *.apk.res.info file that supersize then uses to properly map a
resource file back to its source file.
There is some complexity with resource overloading and android build
tools changing the resource file or directory as part of packaging an
apk. This is handled by a combination of storing renames and parsing
heuristics.
Bug: 827196
Change-Id: Ic8243c218791ec048b1563604d93c7b735fdc71c
Reviewed-on: https://chromium-review.googlesource.com/1014255
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552081}
CrOS-Libchrome-Original-Commit: da8025abca3ac835c8f59f4622372d4dec02fcae
Diffstat (limited to 'build')
-rw-r--r-- | build/android/gyp/util/resource_utils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/build/android/gyp/util/resource_utils.py b/build/android/gyp/util/resource_utils.py index 3775e3dcf2..47b39ef438 100644 --- a/build/android/gyp/util/resource_utils.py +++ b/build/android/gyp/util/resource_utils.py @@ -30,6 +30,22 @@ _TextSymbolEntry = collections.namedtuple('RTextEntry', ('java_type', 'resource_type', 'name', 'value')) +def CreateResourceInfoFile(files_to_zip, zip_path): + """Given a mapping of archive paths to their source, write an info file. + + The info file contains lines of '{archive_path},{source_path}' for ease of + parsing. Assumes that there is no comma in the file names. + + Args: + files_to_zip: Dict mapping path in the zip archive to original source. + zip_path: Path where the zip file ends up, this is where the info file goes. + """ + info_file_path = zip_path + '.info' + with open(info_file_path, 'w') as info_file: + for archive_path, source_path in files_to_zip.iteritems(): + info_file.write('{},{}\n'.format(archive_path, source_path)) + + def _ParseTextSymbolsFile(path, fix_package_ids=False): """Given an R.txt file, returns a list of _TextSymbolEntry. |