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

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

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 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
« no previous file with comments | « build/android/gyp/locale_pak_resources.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
(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 relocations in a library (or copy unchanged).
8
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
11 library files. This step is inserted after the libraries are stripped.
12
13 If --enable-packing is zero, the script copies files verbatim, with no
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 """
20
21 import optparse
22 import os
23 import shlex
24 import shutil
25 import sys
26 import tempfile
27
28 from util import build_utils
29
30 def PackLibraryRelocations(android_pack_relocations, library_path, output_path):
31 shutil.copy(library_path, output_path)
32 pack_command = [android_pack_relocations, output_path]
33 build_utils.CheckOutput(pack_command)
34
35
36 def CopyLibraryUnchanged(library_path, output_path):
37 shutil.copy(library_path, output_path)
38
39
40 def main(args):
41 args = build_utils.ExpandFileArgs(args)
42 parser = optparse.OptionParser()
43 build_utils.AddDepfileOption(parser)
44 parser.add_option('--clear-dir', action='store_true',
45 help='If set, the destination directory will be deleted '
46 'before copying files to it. This is highly recommended to '
47 'ensure that no stale files are left in the directory.')
48
49 parser.add_option('--configuration-name',
50 default='Release',
51 help='Gyp configuration name (i.e. Debug, Release)')
52 parser.add_option('--enable-packing',
53 choices=['0', '1'],
54 help=('Pack relocations if 1 and configuration name is \'Release\','
55 ' otherwise plain file copy'))
56 parser.add_option('--exclude-packing-list',
57 default='',
58 help='Names of any libraries explicitly not packed')
59 parser.add_option('--android-pack-relocations',
60 help='Path to the relocations packer binary')
61 parser.add_option('--stripped-libraries-dir',
62 help='Directory for stripped libraries')
63 parser.add_option('--packed-libraries-dir',
64 help='Directory for packed libraries')
65 parser.add_option('--libraries', action='append',
66 help='List of libraries')
67 parser.add_option('--stamp', help='Path to touch on success')
68
69 options, _ = parser.parse_args(args)
70 enable_packing = (options.enable_packing == '1' and
71 options.configuration_name == 'Release')
72 exclude_packing_set = set(shlex.split(options.exclude_packing_list))
73
74 libraries = []
75 for libs_arg in options.libraries:
76 libraries += build_utils.ParseGypList(libs_arg)
77
78 if options.clear_dir:
79 build_utils.DeleteDirectory(options.packed_libraries_dir)
80
81 build_utils.MakeDirectory(options.packed_libraries_dir)
82
83 for library in libraries:
84 library_path = os.path.join(options.stripped_libraries_dir, library)
85 output_path = os.path.join(
86 options.packed_libraries_dir, os.path.basename(library))
87
88 if enable_packing and library not in exclude_packing_set:
89 PackLibraryRelocations(options.android_pack_relocations,
90 library_path,
91 output_path)
92 else:
93 CopyLibraryUnchanged(library_path, output_path)
94
95 if options.depfile:
96 build_utils.WriteDepfile(
97 options.depfile,
98 libraries + build_utils.GetPythonDependencies())
99
100 if options.stamp:
101 build_utils.Touch(options.stamp)
102
103 return 0
104
105
106 if __name__ == '__main__':
107 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build/android/gyp/locale_pak_resources.py ('k') | build/android/gyp/package_resources.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698