OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Converts protocol buffer definitions to ones supported by the Nano library. | 6 """Converts protocol buffer definitions to ones supported by the Nano library. |
7 | 7 |
8 Note: Java files generated from the output of this script should only be used | 8 Note: Java files generated from the output of this script should only be used |
9 in tests. | 9 in tests. |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 r'^\s*option\s+retain_unknown_fields\s*=.*;', re.MULTILINE) | 57 r'^\s*option\s+retain_unknown_fields\s*=.*;', re.MULTILINE) |
58 pruned_contents = incompatible_option_regex.sub('', contents) | 58 pruned_contents = incompatible_option_regex.sub('', contents) |
59 | 59 |
60 # Add the java_multiple_files and java_package options. Options must be set | 60 # Add the java_multiple_files and java_package options. Options must be set |
61 # after the syntax declaration, so look for the declaration and place the | 61 # after the syntax declaration, so look for the declaration and place the |
62 # options immediately after it. | 62 # options immediately after it. |
63 # TODO(pvalenzuela): Set Java options via proto compiler flags instead of | 63 # TODO(pvalenzuela): Set Java options via proto compiler flags instead of |
64 # modifying the files here. | 64 # modifying the files here. |
65 syntax_regex = re.compile(r'^\s*syntax\s*=.*;', re.MULTILINE) | 65 syntax_regex = re.compile(r'^\s*syntax\s*=.*;', re.MULTILINE) |
66 syntax_end = syntax_regex.search(pruned_contents).end() | 66 syntax_end = syntax_regex.search(pruned_contents).end() |
67 java_options = ('option java_multiple_files = true; ' | 67 java_options = ( |
68 'option java_package = "org.chromium.sync.protocol";') | 68 'option java_multiple_files = true; ' |
| 69 'option java_package = "org.chromium.components.sync.protocol";') |
69 | 70 |
70 contents_to_join = (pruned_contents[:syntax_end], java_options, | 71 contents_to_join = (pruned_contents[:syntax_end], java_options, |
71 pruned_contents[syntax_end:]) | 72 pruned_contents[syntax_end:]) |
72 return ''.join(contents_to_join) | 73 return ''.join(contents_to_join) |
73 | 74 |
74 | 75 |
75 if __name__ == '__main__': | 76 if __name__ == '__main__': |
76 sys.exit(main()) | 77 sys.exit(main()) |
OLD | NEW |