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

Side by Side Diff: build/android/gyp/pack_relocations.py

Issue 1647353002: Use gn_helpers to [se]serialize GN lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@python_impl
Patch Set: more Created 4 years, 4 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
« no previous file with comments | « build/android/gyp/main_dex_list.py ('k') | build/android/gyp/package_resources.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 relocations in a library (or copy unchanged). 7 """Pack relocations in a library (or copy unchanged).
8 8
9 If --enable-packing and --configuration-name=='Release', invoke the 9 If --enable-packing and --configuration-name=='Release', invoke the
10 relocation_packer tool to pack the .rel.dyn or .rela.dyn section in the given 10 relocation_packer tool to pack the .rel.dyn or .rela.dyn section in the given
11 library files. This step is inserted after the libraries are stripped. 11 library files. This step is inserted after the libraries are stripped.
12 12
13 If --enable-packing is zero, the script copies files verbatim, with no 13 If --enable-packing is zero, the script copies files verbatim, with no
14 attempt to pack relocations. 14 attempt to pack relocations.
15
16 Any library listed in --exclude-packing-list is also copied verbatim,
17 irrespective of any --enable-packing setting. Typically this would be
18 'libchromium_android_linker.so'.
19 """ 15 """
20 16
17 import ast
21 import optparse 18 import optparse
22 import os 19 import os
23 import shutil 20 import shutil
24 import sys 21 import sys
25 import tempfile 22 import tempfile
26 23
27 from util import build_utils 24 from util import build_utils
28 25
29 def PackLibraryRelocations(android_pack_relocations, library_path, output_path): 26 def PackLibraryRelocations(android_pack_relocations, library_path, output_path):
30 shutil.copy(library_path, output_path) 27 shutil.copy(library_path, output_path)
(...skipping 14 matching lines...) Expand all
45 'before copying files to it. This is highly recommended to ' 42 'before copying files to it. This is highly recommended to '
46 'ensure that no stale files are left in the directory.') 43 'ensure that no stale files are left in the directory.')
47 44
48 parser.add_option('--configuration-name', 45 parser.add_option('--configuration-name',
49 default='Release', 46 default='Release',
50 help='Gyp configuration name (i.e. Debug, Release)') 47 help='Gyp configuration name (i.e. Debug, Release)')
51 parser.add_option('--enable-packing', 48 parser.add_option('--enable-packing',
52 choices=['0', '1'], 49 choices=['0', '1'],
53 help=('Pack relocations if 1 and configuration name is \'Release\',' 50 help=('Pack relocations if 1 and configuration name is \'Release\','
54 ' otherwise plain file copy')) 51 ' otherwise plain file copy'))
55 parser.add_option('--exclude-packing-list',
56 default='',
57 help='Names of any libraries explicitly not packed')
58 parser.add_option('--android-pack-relocations', 52 parser.add_option('--android-pack-relocations',
59 help='Path to the relocations packer binary') 53 help='Path to the relocations packer binary')
60 parser.add_option('--stripped-libraries-dir', 54 parser.add_option('--stripped-libraries-dir',
61 help='Directory for stripped libraries') 55 help='Directory for stripped libraries')
62 parser.add_option('--packed-libraries-dir', 56 parser.add_option('--packed-libraries-dir',
63 help='Directory for packed libraries') 57 help='Directory for packed libraries')
64 parser.add_option('--libraries', action='append', 58 parser.add_option('--libraries', action='append',
65 help='List of libraries') 59 help='List of libraries in Python dictionary format')
66 parser.add_option('--stamp', help='Path to touch on success') 60 parser.add_option('--stamp', help='Path to touch on success')
67 parser.add_option('--filelistjson', 61 parser.add_option('--filelistjson',
68 help='Output path of filelist.json to write') 62 help='Output path of filelist.json to write')
69 63
70 options, _ = parser.parse_args(args) 64 options, _ = parser.parse_args(args)
71 enable_packing = (options.enable_packing == '1' and 65 enable_packing = (options.enable_packing == '1' and
72 options.configuration_name == 'Release') 66 options.configuration_name == 'Release')
73 exclude_packing_set = set(build_utils.ParseGypList(
74 options.exclude_packing_list))
75 67
76 libraries = [] 68 libraries = []
77 for libs_arg in options.libraries: 69 for libs_arg in options.libraries:
78 libraries += build_utils.ParseGypList(libs_arg) 70 libraries += ast.literal_eval(libs_arg)
79 71
80 if options.clear_dir: 72 if options.clear_dir:
81 build_utils.DeleteDirectory(options.packed_libraries_dir) 73 build_utils.DeleteDirectory(options.packed_libraries_dir)
82 74
83 build_utils.MakeDirectory(options.packed_libraries_dir) 75 build_utils.MakeDirectory(options.packed_libraries_dir)
84 76
85 output_paths = [] 77 output_paths = []
86 for library in libraries: 78 for library in libraries:
87 library_path = os.path.join(options.stripped_libraries_dir, library) 79 library_path = os.path.join(options.stripped_libraries_dir, library)
88 output_path = os.path.join( 80 output_path = os.path.join(
89 options.packed_libraries_dir, os.path.basename(library)) 81 options.packed_libraries_dir, os.path.basename(library))
90 output_paths.append(output_path) 82 output_paths.append(output_path)
91 83
92 if enable_packing and library not in exclude_packing_set: 84 if enable_packing:
93 PackLibraryRelocations(options.android_pack_relocations, 85 PackLibraryRelocations(options.android_pack_relocations,
94 library_path, 86 library_path,
95 output_path) 87 output_path)
96 else: 88 else:
97 CopyLibraryUnchanged(library_path, output_path) 89 CopyLibraryUnchanged(library_path, output_path)
98 90
99 if options.filelistjson: 91 if options.filelistjson:
100 build_utils.WriteJson({ 'files': output_paths }, options.filelistjson) 92 build_utils.WriteJson({ 'files': output_paths }, options.filelistjson)
101 93
102 if options.depfile: 94 if options.depfile:
103 build_utils.WriteDepfile( 95 build_utils.WriteDepfile(
104 options.depfile, 96 options.depfile,
105 libraries + build_utils.GetPythonDependencies()) 97 libraries + build_utils.GetPythonDependencies())
106 98
107 if options.stamp: 99 if options.stamp:
108 build_utils.Touch(options.stamp) 100 build_utils.Touch(options.stamp)
109 101
110 return 0 102 return 0
111 103
112 104
113 if __name__ == '__main__': 105 if __name__ == '__main__':
114 sys.exit(main(sys.argv[1:])) 106 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build/android/gyp/main_dex_list.py ('k') | build/android/gyp/package_resources.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698