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

Side by Side Diff: build/android/gn/generate_isolate.py

Issue 2502363005: [android] Stop using isolate.py for data dependency management. (RELAND) (Closed)
Patch Set: fixed: moved the runtime_deps file. Created 4 years, 1 month 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/PRESUBMIT.py ('k') | build/android/gyp/create_test_runner_script.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 # Copyright 2016 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 """Creates an .isolate given a list of files.
7
8 """
9
10 import argparse
11 import os
12 import pprint
13 import re
14 import sys
15
16
17 _UNIVERSAL_BLACKLIST = (
18 r'.*OWNERS', # Should never be included.
19 )
20
21 _ANDROID_BLACKLIST = (
22 r'.*\.crx', # Chrome extension zip files.
23 r'.*external_extensions\.json', # Chrome external extensions config file.
24 r'.*\.so', # Libraries packed into .apk.
25 r'.*\.mojom\.js', # Some test_support targets include python deps.
26 r'.*Mojo.*manifest\.json', # Some source_set()s pull these in.
27 r'.*jni_generator_tests', # Exists just to test the compile, not to be run.
28 )
29
30 _DEVICE_BLACKLIST = (
31 r'.*\.py', # Some test_support targets include python deps.
32
33 # v8's blobs get packaged into APKs.
34 r'.*natives_blob.*\.bin',
35 r'.*snapshot_blob.*\.bin',
36 )
37
38 _ASSERT_WHITELIST = (
39 r'.*\.pak',
40 r'.*/', # Assume directories are always included on purpose.
41 )
42
43
44 def _IsExecutable(path):
45 return os.path.isfile(path) and os.access(path, os.X_OK)
46
47
48 def _MatchesAny(path, patterns):
49 return any(re.match(p, path) for p in patterns)
50
51
52 def main():
53 parser = argparse.ArgumentParser(description=__doc__)
54 parser.add_argument('--command',
55 help='The command to put in the .isolate (optional)')
56 parser.add_argument('--runtime-deps-file', required=True,
57 help='Input .runtime_deps file.')
58 parser.add_argument('--output-directory', required=True,
59 help='Location of the ninja output directory')
60 parser.add_argument('--out-file', help='Write to file rather than stdout.')
61 parser.add_argument('--apply-android-filters', action='store_true',
62 help='Filter files not required for Android.')
63 parser.add_argument('--apply-device-filters', action='store_true',
64 help='Filter files not required in *.device.isolate.')
65 parser.add_argument('--assert-no-odd-data', action='store_true',
66 help='Fail if any data deps exist (after filtering) '
67 'that are not a part of the _ASSERT_WHITELIST. Use '
68 'this to prevent unexpected runtime_deps from '
69 'creeping in')
70 options = parser.parse_args()
71
72 deps = []
73 with open(options.runtime_deps_file) as deps_file:
74 for path in deps_file:
75 if path.startswith('./'):
76 path = path[2:]
77 deps.append(path.rstrip())
78
79 deps = (d for d in deps if not _MatchesAny(d, _UNIVERSAL_BLACKLIST))
80
81 if options.apply_android_filters:
82 deps = (d for d in deps if not _MatchesAny(d, _ANDROID_BLACKLIST))
83
84 if options.apply_device_filters:
85 deps = (d for d in deps if not _MatchesAny(d, _DEVICE_BLACKLIST))
86 # Breakpad tests have a helper exe, which is packaged in the _dist.
87 deps = (d for d in deps if not _IsExecutable(d))
88
89 # Make them relative to out-file.
90 if options.out_file:
91 subdir = os.path.relpath(options.output_directory,
92 os.path.dirname(options.out_file))
93 deps = (os.path.join(subdir, d) for d in deps)
94
95 deps = sorted(deps)
96
97 if options.assert_no_odd_data:
98 odd_files = [d for d in deps if not _MatchesAny(d, _ASSERT_WHITELIST)]
99 assert not odd_files, ('Found possibly undesired file in runtime_deps: %s' %
100 odd_files)
101
102 isolate_dict = {
103 'variables': {
104 'files': deps,
105 }
106 }
107 if options.command:
108 isolate_dict['variables']['command'] = [options.command]
109
110 isolate_data = pprint.pformat(isolate_dict)
111 if options.out_file:
112 with open(options.out_file, 'w') as f:
113 f.write(isolate_data + '\n')
114 else:
115 print isolate_data
116
117
118 if __name__ == '__main__':
119 sys.exit(main())
120
OLDNEW
« no previous file with comments | « build/android/PRESUBMIT.py ('k') | build/android/gyp/create_test_runner_script.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698