Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Pack ARM relative relocations in a library (or copy unchanged). | 7 """Pack ARM relative relocations in a library (or copy unchanged). |
| 8 | 8 |
| 9 If --enable-packing, invoke the relocation_packer tool to pack the .rel.dyn | 9 If --enable-packing and --configuration-name=='Release', invoke the |
| 10 section in the given library files. This step is inserted after the libraries | 10 relocation_packer tool to pack the .rel.dyn section in the given library |
| 11 are stripped. Packing adds a new .android.rel.dyn section to the file and | 11 files. This step is inserted after the libraries are stripped. Packing |
| 12 reduces the size of .rel.dyn accordingly. | 12 adds a new .android.rel.dyn section to the file and reduces the size of |
| 13 .rel.dyn accordingly. | |
| 13 | 14 |
| 14 Currently packing only understands ARM32 shared libraries. For all other | 15 Currently packing only understands ARM32 shared libraries. For all other |
| 15 architectures --enable-packing should be set to zero. In this case the | 16 architectures --enable-packing should be set to zero. In this case the |
| 16 script copies files verbatim, with no attempt to pack relative relocations. | 17 script copies files verbatim, with no attempt to pack relative relocations. |
| 17 | 18 |
| 18 Any library listed in --exclude-packing-list is also copied verbatim, | 19 Any library listed in --exclude-packing-list is also copied verbatim, |
| 19 irrespective of any --enable-packing setting. Typically this would be | 20 irrespective of any --enable-packing setting. Typically this would be |
| 20 'libchromium_android_linker.so'. | 21 'libchromium_android_linker.so'. |
| 21 """ | 22 """ |
| 22 | 23 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 def CopyArmLibraryUnchanged(library_path, output_path): | 55 def CopyArmLibraryUnchanged(library_path, output_path): |
| 55 if not build_utils.IsTimeStale(output_path, [library_path]): | 56 if not build_utils.IsTimeStale(output_path, [library_path]): |
| 56 return | 57 return |
| 57 | 58 |
| 58 shutil.copy(library_path, output_path) | 59 shutil.copy(library_path, output_path) |
| 59 | 60 |
| 60 | 61 |
| 61 def main(): | 62 def main(): |
| 62 parser = optparse.OptionParser() | 63 parser = optparse.OptionParser() |
| 63 | 64 |
| 65 parser.add_option('--configuration-name', | |
| 66 help='Gyp configuration name (i.e. Debug, Release)') | |
|
rmcilroy
2014/07/16 15:24:04
Make a default value of Release, so that manual us
simonb (inactive)
2014/07/16 16:17:00
Done.
| |
| 64 parser.add_option('--enable-packing', | 67 parser.add_option('--enable-packing', |
| 65 choices=['0', '1'], | 68 choices=['0', '1'], |
| 66 help='Pack relocations if 1, otherwise plain file copy') | 69 help='Pack relocations if 1, otherwise plain file copy') |
|
rmcilroy
2014/07/16 15:24:03
Mention that --configuration-name needs to be Rele
simonb (inactive)
2014/07/16 16:17:00
Done.
| |
| 67 parser.add_option('--exclude-packing-list', | 70 parser.add_option('--exclude-packing-list', |
| 68 default='', | 71 default='', |
| 69 help='Names of any libraries explicitly not packed') | 72 help='Names of any libraries explicitly not packed') |
| 70 parser.add_option('--android-pack-relocations', | 73 parser.add_option('--android-pack-relocations', |
| 71 help='Path to the ARM relocations packer binary') | 74 help='Path to the ARM relocations packer binary') |
| 72 parser.add_option('--android-objcopy', | 75 parser.add_option('--android-objcopy', |
| 73 help='Path to the toolchain\'s objcopy binary') | 76 help='Path to the toolchain\'s objcopy binary') |
| 74 parser.add_option('--stripped-libraries-dir', | 77 parser.add_option('--stripped-libraries-dir', |
| 75 help='Directory for stripped libraries') | 78 help='Directory for stripped libraries') |
| 76 parser.add_option('--packed-libraries-dir', | 79 parser.add_option('--packed-libraries-dir', |
| 77 help='Directory for packed libraries') | 80 help='Directory for packed libraries') |
| 78 parser.add_option('--libraries-file', | 81 parser.add_option('--libraries-file', |
| 79 help='Path to json file containing list of libraries') | 82 help='Path to json file containing list of libraries') |
| 80 parser.add_option('--stamp', help='Path to touch on success') | 83 parser.add_option('--stamp', help='Path to touch on success') |
| 81 | 84 |
| 82 options, _ = parser.parse_args() | 85 options, _ = parser.parse_args() |
| 83 enable_packing = options.enable_packing == '1' | 86 enable_packing = (options.enable_packing == '1' and |
| 87 options.configuration_name == 'Release') | |
| 84 exclude_packing_set = set(shlex.split(options.exclude_packing_list)) | 88 exclude_packing_set = set(shlex.split(options.exclude_packing_list)) |
| 85 | 89 |
| 86 with open(options.libraries_file, 'r') as libfile: | 90 with open(options.libraries_file, 'r') as libfile: |
| 87 libraries = json.load(libfile) | 91 libraries = json.load(libfile) |
| 88 | 92 |
| 89 build_utils.MakeDirectory(options.packed_libraries_dir) | 93 build_utils.MakeDirectory(options.packed_libraries_dir) |
| 90 | 94 |
| 91 for library in libraries: | 95 for library in libraries: |
| 92 library_path = os.path.join(options.stripped_libraries_dir, library) | 96 library_path = os.path.join(options.stripped_libraries_dir, library) |
| 93 output_path = os.path.join(options.packed_libraries_dir, library) | 97 output_path = os.path.join(options.packed_libraries_dir, library) |
| 94 | 98 |
| 95 if enable_packing and library not in exclude_packing_set: | 99 if enable_packing and library not in exclude_packing_set: |
| 96 PackArmLibraryRelocations(options.android_pack_relocations, | 100 PackArmLibraryRelocations(options.android_pack_relocations, |
| 97 options.android_objcopy, | 101 options.android_objcopy, |
| 98 library_path, | 102 library_path, |
| 99 output_path) | 103 output_path) |
| 100 else: | 104 else: |
| 101 CopyArmLibraryUnchanged(library_path, output_path) | 105 CopyArmLibraryUnchanged(library_path, output_path) |
| 102 | 106 |
| 103 if options.stamp: | 107 if options.stamp: |
| 104 build_utils.Touch(options.stamp) | 108 build_utils.Touch(options.stamp) |
| 105 | 109 |
| 106 return 0 | 110 return 0 |
| 107 | 111 |
| 108 | 112 |
| 109 if __name__ == '__main__': | 113 if __name__ == '__main__': |
| 110 sys.exit(main()) | 114 sys.exit(main()) |
| OLD | NEW |