Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: trunk/src/build/android/gyp/pack_arm_relocations.py

Issue 370633002: Revert 281286 "Add gyp machinery to build with packed ARM relati..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/build/all.gyp ('k') | trunk/src/build/android/pack_arm_relocations.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
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
5 # found in the LICENSE file.
6
7 """Pack ARM relative relocations in a library (or copy unchanged).
8
9 If --enable-packing, invoke the relocation_packer tool to pack the .rel.dyn
10 section in the given library files. This step is inserted after the libraries
11 are stripped. Packing adds a new .android.rel.dyn section to the file and
12 reduces the size of .rel.dyn accordingly.
13
14 Currently packing only understands ARM32 shared libraries. For all other
15 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
18 Any library listed in --exclude-packing-list is also copied verbatim,
19 irrespective of any --enable-packing setting. Typically this would be
20 'libchromium_android_linker.so'.
21 """
22
23 import json
24 import optparse
25 import os
26 import shlex
27 import shutil
28 import sys
29 import tempfile
30
31 from util import build_utils
32
33 def PackArmLibraryRelocations(android_pack_relocations,
34 android_objcopy,
35 library_path,
36 output_path):
37 if not build_utils.IsTimeStale(output_path, [library_path]):
38 return
39
40 # Copy and add a 'NULL' .android.rel.dyn section for the packing tool.
41 with tempfile.NamedTemporaryFile() as stream:
42 stream.write('NULL')
43 stream.flush()
44 objcopy_command = [android_objcopy,
45 '--add-section', '.android.rel.dyn=%s' % stream.name,
46 library_path, output_path]
47 build_utils.CheckOutput(objcopy_command)
48
49 # Pack R_ARM_RELATIVE relocations.
50 pack_command = [android_pack_relocations, output_path]
51 build_utils.CheckOutput(pack_command)
52
53
54 def CopyArmLibraryUnchanged(library_path, output_path):
55 if not build_utils.IsTimeStale(output_path, [library_path]):
56 return
57
58 shutil.copy(library_path, output_path)
59
60
61 def main():
62 parser = optparse.OptionParser()
63
64 parser.add_option('--enable-packing',
65 choices=['0', '1'],
66 help='Pack relocations if 1, otherwise plain file copy')
67 parser.add_option('--exclude-packing-list',
68 default='',
69 help='Names of any libraries explicitly not packed')
70 parser.add_option('--android-pack-relocations',
71 help='Path to the ARM relocations packer binary')
72 parser.add_option('--android-objcopy',
73 help='Path to the toolchain\'s objcopy binary')
74 parser.add_option('--stripped-libraries-dir',
75 help='Directory for stripped libraries')
76 parser.add_option('--packed-libraries-dir',
77 help='Directory for packed libraries')
78 parser.add_option('--libraries-file',
79 help='Path to json file containing list of libraries')
80 parser.add_option('--stamp', help='Path to touch on success')
81
82 options, _ = parser.parse_args()
83 enable_packing = options.enable_packing == '1'
84 exclude_packing_set = set(shlex.split(options.exclude_packing_list))
85
86 with open(options.libraries_file, 'r') as libfile:
87 libraries = json.load(libfile)
88
89 for library in libraries:
90 library_path = os.path.join(options.stripped_libraries_dir, library)
91 output_path = os.path.join(options.packed_libraries_dir, library)
92
93 if enable_packing and library not in exclude_packing_set:
94 PackArmLibraryRelocations(options.android_pack_relocations,
95 options.android_objcopy,
96 library_path,
97 output_path)
98 else:
99 CopyArmLibraryUnchanged(library_path, output_path)
100
101 if options.stamp:
102 build_utils.Touch(options.stamp)
103
104 return 0
105
106
107 if __name__ == '__main__':
108 sys.exit(main())
OLDNEW
« no previous file with comments | « trunk/src/build/all.gyp ('k') | trunk/src/build/android/pack_arm_relocations.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698