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

Side by Side Diff: ios/web_view/internal/hide_symbols.py

Issue 2665333002: Add a BUILD target and a script to build a public static library for ios/web_view. (Closed)
Patch Set: Created 3 years, 10 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
« ios/web_view/BUILD.gn ('K') | « ios/web_view/internal/BUILD.gn ('k') | no next file » | 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 2017 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 # Create a static library which exposes only symbols which are explicitly marked
8 # as visible e.g., by __attribute__((visibility("default"))).
9 #
10 # See BUILD.gn in this directory for usage example.
11 #
12 # This way, we can reduce risk of symbol conflict when linking it into apps
13 # by exposing internal symbols, especially in third-party libraries.
14
15 import optparse
16 import subprocess
17
18
19 def main():
20 parser = optparse.OptionParser()
21 parser.add_option(
22 '--input_lib',
23 help='The path to an input .a file which contains symbols which must be '
24 'always linked.')
25 parser.add_option(
26 '--deps_lib',
27 help='The path to a complete static library (.a file) which contains all '
28 'dependencies of --input_lib. .o files in this library are also '
29 'added to the output library, but only if they are referred from '
30 '--input_lib.')
31 parser.add_option(
32 '--output_obj',
33 help='Outputs the generated .o file here. This is an intermediate file.')
34 parser.add_option(
35 '--output_lib',
36 help='Outputs the generated .a file here.')
37 (options, args) = parser.parse_args()
38 assert not args
39
40 # ld -r concatenates multiple .o files and .a files into a single .o file,
41 # while "hiding" symbols not marked as visible.
42 command = [
43 'xcrun', 'ld', '-r',
44 # By default, ld only pulls .o files out of a static library if needed to
45 # resolve some symbol reference. We apply -force_load option to input_lib
46 # (but not to deps_lib) to force pulling all .o files.
47 '-force_load', options.input_lib,
48 options.deps_lib,
49 '-o', options.output_obj
50 ]
51 subprocess.check_call(command)
52
53 # Creates a .a file which contains a single .o file.
54 command = [
55 'xcrun', 'ar', '-r',
56 options.output_lib,
57 options.output_obj,
58 ]
59 subprocess.check_call(command)
60
61
62 if __name__ == "__main__":
63 main()
OLDNEW
« ios/web_view/BUILD.gn ('K') | « ios/web_view/internal/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698