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

Side by Side Diff: build/android/gyp/insert_chromium_version.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/generate_resource_rewriter.py ('k') | build/android/gyp/jar.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 """Insert a version string into a library as a section '.chromium.version'.
8 """
9
10 import optparse
11 import os
12 import sys
13 import tempfile
14
15 from util import build_utils
16
17 def InsertChromiumVersion(android_objcopy,
18 library_path,
19 version_string):
20 # Remove existing .chromium.version section from .so
21 objcopy_command = [android_objcopy,
22 '--remove-section=.chromium.version',
23 library_path]
24 build_utils.CheckOutput(objcopy_command)
25
26 # Add a .chromium.version section.
27 with tempfile.NamedTemporaryFile() as stream:
28 stream.write(version_string)
29 stream.flush()
30 objcopy_command = [android_objcopy,
31 '--add-section', '.chromium.version=%s' % stream.name,
32 library_path]
33 build_utils.CheckOutput(objcopy_command)
34
35 def main(args):
36 args = build_utils.ExpandFileArgs(args)
37 parser = optparse.OptionParser()
38
39 parser.add_option('--android-objcopy',
40 help='Path to the toolchain\'s objcopy binary')
41 parser.add_option('--stripped-libraries-dir',
42 help='Directory of native libraries')
43 parser.add_option('--libraries',
44 help='List of libraries')
45 parser.add_option('--version-string',
46 help='Version string to be inserted')
47 parser.add_option('--stamp', help='Path to touch on success')
48
49 options, _ = parser.parse_args(args)
50 libraries = build_utils.ParseGypList(options.libraries)
51
52 for library in libraries:
53 library_path = os.path.join(options.stripped_libraries_dir, library)
54
55 InsertChromiumVersion(options.android_objcopy,
56 library_path,
57 options.version_string)
58
59 if options.stamp:
60 build_utils.Touch(options.stamp)
61
62 return 0
63
64
65 if __name__ == '__main__':
66 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build/android/gyp/generate_resource_rewriter.py ('k') | build/android/gyp/jar.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698