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

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

Issue 2127013002: 🎣 Reland of Make Android .build_configs aware of prebuilts and java sources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN not knowing the list of inputs in javac and emma rules 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 | « no previous file | build/android/gyp/javac.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Instruments classes and jar files. 7 """Instruments classes and jar files.
8 8
9 This script corresponds to the 'emma_instr' action in the java build process. 9 This script corresponds to the 'emma_instr' action in the java build process.
10 Depending on whether emma_instrument is set, the 'emma_instr' action will either 10 Depending on whether emma_instrument is set, the 'emma_instr' action will either
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 """Adds options related to instrumentation to |option_parser|.""" 51 """Adds options related to instrumentation to |option_parser|."""
52 _AddCommonOptions(option_parser) 52 _AddCommonOptions(option_parser)
53 option_parser.add_option('--source-dirs', 53 option_parser.add_option('--source-dirs',
54 help='Space separated list of source directories. ' 54 help='Space separated list of source directories. '
55 'source-files should not be specified if ' 55 'source-files should not be specified if '
56 'source-dirs is specified') 56 'source-dirs is specified')
57 option_parser.add_option('--source-files', 57 option_parser.add_option('--source-files',
58 help='Space separated list of source files. ' 58 help='Space separated list of source files. '
59 'source-dirs should not be specified if ' 59 'source-dirs should not be specified if '
60 'source-files is specified') 60 'source-files is specified')
61 option_parser.add_option('--java-sources-file',
62 help='File containing newline-separated .java paths')
61 option_parser.add_option('--src-root', 63 option_parser.add_option('--src-root',
62 help='Root of the src repository.') 64 help='Root of the src repository.')
63 option_parser.add_option('--emma-jar', 65 option_parser.add_option('--emma-jar',
64 help='Path to emma.jar.') 66 help='Path to emma.jar.')
65 option_parser.add_option( 67 option_parser.add_option(
66 '--filter-string', default='', 68 '--filter-string', default='',
67 help=('Filter string consisting of a list of inclusion/exclusion ' 69 help=('Filter string consisting of a list of inclusion/exclusion '
68 'patterns separated with whitespace and/or comma.')) 70 'patterns separated with whitespace and/or comma.'))
69 71
70 72
(...skipping 24 matching lines...) Expand all
95 shutil.copy(options.input_path, options.output_path) 97 shutil.copy(options.input_path, options.output_path)
96 98
97 if options.stamp: 99 if options.stamp:
98 build_utils.Touch(options.stamp) 100 build_utils.Touch(options.stamp)
99 101
100 if options.depfile: 102 if options.depfile:
101 build_utils.WriteDepfile(options.depfile, 103 build_utils.WriteDepfile(options.depfile,
102 build_utils.GetPythonDependencies()) 104 build_utils.GetPythonDependencies())
103 105
104 106
105 def _GetSourceDirsFromSourceFiles(source_files_string): 107 def _GetSourceDirsFromSourceFiles(source_files):
106 """Returns list of directories for the files in |source_files_string|. 108 """Returns list of directories for the files in |source_files|.
107 109
108 Args: 110 Args:
109 source_files_string: String generated from GN or GYP containing the list 111 source_files: List of source files.
110 of source files.
111 112
112 Returns: 113 Returns:
113 List of source directories. 114 List of source directories.
114 """ 115 """
115 source_files = build_utils.ParseGypList(source_files_string)
116 return list(set(os.path.dirname(source_file) for source_file in source_files)) 116 return list(set(os.path.dirname(source_file) for source_file in source_files))
117 117
118 118
119 def _CreateSourcesListFile(source_dirs, sources_list_file, src_root): 119 def _CreateSourcesListFile(source_dirs, sources_list_file, src_root):
120 """Adds all normalized source directories to |sources_list_file|. 120 """Adds all normalized source directories to |sources_list_file|.
121 121
122 Args: 122 Args:
123 source_dirs: List of source directories. 123 source_dirs: List of source directories.
124 sources_list_file: File into which to write the JSON list of sources. 124 sources_list_file: File into which to write the JSON list of sources.
125 src_root: Root which sources added to the file should be relative to. 125 src_root: Root which sources added to the file should be relative to.
(...skipping 25 matching lines...) Expand all
151 this function. 151 this function.
152 options: optparse options dictionary. 152 options: optparse options dictionary.
153 args: List of extra args from optparse. 153 args: List of extra args from optparse.
154 option_parser: optparse.OptionParser object. 154 option_parser: optparse.OptionParser object.
155 155
156 Returns: 156 Returns:
157 An exit code. 157 An exit code.
158 """ 158 """
159 if not (options.input_path and options.output_path and 159 if not (options.input_path and options.output_path and
160 options.coverage_file and options.sources_list_file and 160 options.coverage_file and options.sources_list_file and
161 (options.source_files or options.source_dirs) and 161 (options.source_files or options.source_dirs or
162 options.java_sources_file) and
162 options.src_root and options.emma_jar): 163 options.src_root and options.emma_jar):
163 option_parser.error('All arguments are required.') 164 option_parser.error('All arguments are required.')
164 165
165 if os.path.exists(options.coverage_file): 166 if os.path.exists(options.coverage_file):
166 os.remove(options.coverage_file) 167 os.remove(options.coverage_file)
167 temp_dir = tempfile.mkdtemp() 168 temp_dir = tempfile.mkdtemp()
168 try: 169 try:
169 cmd = ['java', '-cp', options.emma_jar, 170 cmd = ['java', '-cp', options.emma_jar,
170 'emma', 'instr', 171 'emma', 'instr',
171 '-ip', options.input_path, 172 '-ip', options.input_path,
(...skipping 17 matching lines...) Expand all
189 # input_path is a hardlink to output_path. http://crbug.com/571642 190 # input_path is a hardlink to output_path. http://crbug.com/571642
190 if os.path.exists(options.output_path): 191 if os.path.exists(options.output_path):
191 os.unlink(options.output_path) 192 os.unlink(options.output_path)
192 shutil.move(os.path.join(temp_jar_dir, jars[0]), options.output_path) 193 shutil.move(os.path.join(temp_jar_dir, jars[0]), options.output_path)
193 finally: 194 finally:
194 shutil.rmtree(temp_dir) 195 shutil.rmtree(temp_dir)
195 196
196 if options.source_dirs: 197 if options.source_dirs:
197 source_dirs = build_utils.ParseGypList(options.source_dirs) 198 source_dirs = build_utils.ParseGypList(options.source_dirs)
198 else: 199 else:
199 source_dirs = _GetSourceDirsFromSourceFiles(options.source_files) 200 source_files = []
201 if options.source_files:
202 source_files += build_utils.ParseGypList(options.source_files)
203 if options.java_sources_file:
204 with open(options.java_sources_file) as f:
205 source_files.extend(l.strip() for l in f)
206 source_dirs = _GetSourceDirsFromSourceFiles(source_files)
207
208 # TODO(GYP): In GN, we are passed the list of sources, detecting source
209 # directories, then walking them to re-establish the list of sources.
210 # This can obviously be simplified!
200 _CreateSourcesListFile(source_dirs, options.sources_list_file, 211 _CreateSourcesListFile(source_dirs, options.sources_list_file,
201 options.src_root) 212 options.src_root)
202 213
203 if options.stamp: 214 if options.stamp:
204 build_utils.Touch(options.stamp) 215 build_utils.Touch(options.stamp)
205 216
206 if options.depfile: 217 if options.depfile:
207 build_utils.WriteDepfile(options.depfile, 218 build_utils.WriteDepfile(options.depfile,
208 build_utils.GetPythonDependencies()) 219 build_utils.GetPythonDependencies())
209 220
(...skipping 11 matching lines...) Expand all
221 232
222 233
223 def main(): 234 def main():
224 option_parser = command_option_parser.CommandOptionParser( 235 option_parser = command_option_parser.CommandOptionParser(
225 commands_dict=VALID_COMMANDS) 236 commands_dict=VALID_COMMANDS)
226 command_option_parser.ParseAndExecute(option_parser) 237 command_option_parser.ParseAndExecute(option_parser)
227 238
228 239
229 if __name__ == '__main__': 240 if __name__ == '__main__':
230 sys.exit(main()) 241 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/javac.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698