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

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

Issue 2840193003: [Android] Fix stack symbolization when packed relocations are on. (Closed)
Patch Set: tedchoc comment Created 3 years, 7 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 | « PRESUBMIT.py ('k') | build/config/android/internal_rules.gni » ('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 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6
7 import argparse
8 import os
9 import sys
10 import textwrap
11
12 from util import build_utils
13
14 SCRIPT_TEMPLATE = textwrap.dedent(
15 """\
16 #!/usr/bin/env python
17 #
18 # This file was generated by build/android/gyp/create_stack_script.py
19
20 import os
21 import sys
22
23 def main(argv):
24 script_directory = os.path.dirname(__file__)
25 resolve = lambda p: os.path.abspath(os.path.join(script_directory, p))
26 script_path = resolve('{script_path}')
27 script_args = {script_args}
28 script_path_args = {script_path_args}
29 for arg, path in script_path_args:
30 script_args.extend([arg, resolve(path)])
31 script_cmd = [script_path] + script_args + argv
32 print ' '.join(script_cmd)
33 os.execv(script_path, script_cmd)
34
35 if __name__ == '__main__':
36 sys.exit(main(sys.argv[1:]))
37 """)
38
39
40 def main(args):
41
42 parser = argparse.ArgumentParser()
43 build_utils.AddDepfileOption(parser)
44 parser.add_argument(
45 '--script-path',
46 help='Path to the wrapped script.')
47 parser.add_argument(
48 '--script-output-path',
49 help='Path to the output script.')
50 group = parser.add_argument_group('Path arguments')
51 group.add_argument('--output-directory')
52 group.add_argument('--packed-libs')
53
54 args, script_args = parser.parse_known_args(build_utils.ExpandFileArgs(args))
55
56 def relativize(p):
57 return os.path.relpath(p, os.path.dirname(args.script_output_path))
58
59 script_path = relativize(args.script_path)
60
61 script_path_args = []
62 if args.output_directory:
63 script_path_args.append(
64 ('--output-directory', relativize(args.output_directory)))
65 if args.packed_libs:
66 for p in build_utils.ParseGnList(args.packed_libs):
67 script_path_args.append(('--packed-lib', relativize(p)))
68
69 with open(args.script_output_path, 'w') as script:
70 script.write(SCRIPT_TEMPLATE.format(
71 script_path=script_path,
72 script_args=script_args,
73 script_path_args=script_path_args))
74
75 os.chmod(args.script_output_path, 0750)
76
77 if args.depfile:
78 build_utils.WriteDepfile(args.depfile, args.script_output_path)
79
80 return 0
81
82
83 if __name__ == '__main__':
84 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698