Index: build/android/gyp/emma_instr.py |
diff --git a/build/android/gyp/emma_instr.py b/build/android/gyp/emma_instr.py |
index 9ba67769b60c8c3cb1c24b013435974557153a2a..abb5653ed31af2f994dcc5f8fcdb8bef5512d7b7 100755 |
--- a/build/android/gyp/emma_instr.py |
+++ b/build/android/gyp/emma_instr.py |
@@ -58,6 +58,8 @@ def _AddInstrumentOptions(option_parser): |
help='Space separated list of source files. ' |
'source-dirs should not be specified if ' |
'source-files is specified') |
+ option_parser.add_option('--java-sources-file', |
+ help='File containing newline-separated .java paths') |
option_parser.add_option('--src-root', |
help='Root of the src repository.') |
option_parser.add_option('--emma-jar', |
@@ -102,17 +104,15 @@ def _RunCopyCommand(_command, options, _, option_parser): |
build_utils.GetPythonDependencies()) |
-def _GetSourceDirsFromSourceFiles(source_files_string): |
- """Returns list of directories for the files in |source_files_string|. |
+def _GetSourceDirsFromSourceFiles(source_files): |
+ """Returns list of directories for the files in |source_files|. |
Args: |
- source_files_string: String generated from GN or GYP containing the list |
- of source files. |
+ source_files: List of source files. |
Returns: |
List of source directories. |
""" |
- source_files = build_utils.ParseGypList(source_files_string) |
return list(set(os.path.dirname(source_file) for source_file in source_files)) |
@@ -158,7 +158,8 @@ def _RunInstrumentCommand(_command, options, _, option_parser): |
""" |
if not (options.input_path and options.output_path and |
options.coverage_file and options.sources_list_file and |
- (options.source_files or options.source_dirs) and |
+ (options.source_files or options.source_dirs or |
+ options.java_sources_file) and |
options.src_root and options.emma_jar): |
option_parser.error('All arguments are required.') |
@@ -196,7 +197,17 @@ def _RunInstrumentCommand(_command, options, _, option_parser): |
if options.source_dirs: |
source_dirs = build_utils.ParseGypList(options.source_dirs) |
else: |
- source_dirs = _GetSourceDirsFromSourceFiles(options.source_files) |
+ source_files = [] |
+ if options.source_files: |
+ source_files += build_utils.ParseGypList(options.source_files) |
+ if options.java_sources_file: |
+ with open(options.java_sources_file) as f: |
+ source_files.extend(l.strip() for l in f) |
+ source_dirs = _GetSourceDirsFromSourceFiles(source_files) |
+ |
+ # TODO(GYP): In GN, we are passed the list of sources, detecting source |
+ # directories, then walking them to re-establish the list of sources. |
+ # This can obviously be simplified! |
_CreateSourcesListFile(source_dirs, options.sources_list_file, |
options.src_root) |