Chromium Code Reviews| Index: build/android/gyp/java_cpp_enum.py |
| diff --git a/build/android/gyp/java_cpp_enum.py b/build/android/gyp/java_cpp_enum.py |
| index 46417eca5e6735a1413256bad7c21588c0bca1af..8b9674c6ddac54d0294b0d0d29b4e650cc7fbd3a 100755 |
| --- a/build/android/gyp/java_cpp_enum.py |
| +++ b/build/android/gyp/java_cpp_enum.py |
| @@ -228,14 +228,21 @@ def GetScriptName(): |
| return os.sep.join(script_components[build_index:]) |
| -def DoGenerate(options, source_paths): |
| +def DoGenerate(options, output_dir_and_source_paths): |
|
cjhopman
2015/02/17 21:38:25
extracting out bits of the list like this is odd,
mnaganov (inactive)
2015/02/23 11:35:26
Done.
|
| + output_dir = output_dir_and_source_paths[0] |
| + source_paths = output_dir_and_source_paths[1:] |
| output_paths = [] |
| for source_path in source_paths: |
| enum_definitions = DoParseHeaderFile(source_path) |
| + if not enum_definitions: |
| + raise Exception('No enums found in %s\n' |
| + 'Did you forget prefixing enums with ' |
| + '"// GENERATED_JAVA_ENUM_PACKAGE: foo"?' % |
| + source_path) |
| for enum_definition in enum_definitions: |
| package_path = enum_definition.enum_package.replace('.', os.path.sep) |
| file_name = enum_definition.class_name + '.java' |
| - output_path = os.path.join(options.output_dir, package_path, file_name) |
| + output_path = os.path.join(output_dir, package_path, file_name) |
| output_paths.append(output_path) |
| if not options.print_output_only: |
|
cjhopman
2015/02/17 21:38:25
We could totally get rid of the options argument h
mnaganov (inactive)
2015/02/23 11:35:26
Done.
|
| build_utils.MakeDirectory(os.path.dirname(output_path)) |
| @@ -300,18 +307,19 @@ def AssertFilesList(output_paths, assert_files_list): |
| 'add %s and remove %s.' % (need_to_add, need_to_remove)) |
| def DoMain(argv): |
| - parser = optparse.OptionParser() |
| + usage = 'usage: %prog [options] output_dir input_file(s)...' |
| + parser = optparse.OptionParser(usage=usage) |
| parser.add_option('--assert_file', action="append", default=[], |
| dest="assert_files_list", help='Assert that the given ' |
| 'file is an output. There can be multiple occurrences of ' |
| 'this flag.') |
| - parser.add_option('--output_dir', help='Base path for generated files.') |
| parser.add_option('--print_output_only', help='Only print output paths.', |
| action='store_true') |
| options, args = parser.parse_args(argv) |
| - |
| + if len(args) < 2: |
| + parser.error('Need to specify output directory and at least one input file') |
| output_paths = DoGenerate(options, args) |
| if options.assert_files_list: |
| @@ -320,4 +328,4 @@ def DoMain(argv): |
| return " ".join(output_paths) |
| if __name__ == '__main__': |
| - DoMain(sys.argv[1:]) |
| + print DoMain(sys.argv[1:]) |
|
cjhopman
2015/02/17 21:38:25
We try to limit the output in a normal build, so I
mnaganov (inactive)
2015/02/23 11:35:26
I see. Added a flag then.
|