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

Unified Diff: sync/protocol/prepare_protos_for_java_tests.py

Issue 998373004: Sync: Generalize entity injection in Android tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: sync/protocol/prepare_protos_for_java_tests.py
diff --git a/sync/protocol/prepare_protos_for_java_tests.py b/sync/protocol/prepare_protos_for_java_tests.py
new file mode 100755
index 0000000000000000000000000000000000000000..4f97b35eba8f73001aeba6e16ea749aa994042c8
--- /dev/null
+++ b/sync/protocol/prepare_protos_for_java_tests.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
nyquist 2015/03/24 00:25:35 I think the new hotness is to use #!/usr/bin/env p
pval...(no longer on Chromium) 2015/03/26 21:17:57 Done.
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import optparse
+import os
+import shutil
+import sys
+
+def main():
nyquist 2015/03/24 00:25:36 What does this script do? Could you add a python-s
pval...(no longer on Chromium) 2015/03/26 21:17:57 Done.
+ parser = optparse.OptionParser(
+ usage='Usage: %prog [options...] original_proto_files')
+ parser.add_option('-o', '--output_dir', dest='output_dir',
+ help='Where to put the modified proto files')
+
+ options, args = parser.parse_args()
+ if not options.output_dir:
+ print 'output_dir not specified.'
+ return 1
+
+ # Copy the original proto files to the new location.
+ for original_proto_file in args:
+ shutil.copy(original_proto_file, options.output_dir)
+
+ for new_proto_file_name in os.listdir(options.output_dir):
+ new_proto_file_path = os.path.join(options.output_dir, new_proto_file_name)
+ # The retain_unknown_fields option is removed because it is not supported by
+ # the protobuf nano library (used in Chromium Java).
+ # Java-specific options are set to ensure that the protos are properly
+ # organized and compiled.
+ os.system("sed -i 's/option retain_unknown_fields = true;/"
pval...(no longer on Chromium) 2015/03/13 00:32:45 should I match whitespace here? for example, what
nyquist 2015/03/24 00:25:36 I'd use built in tools in python for regexp here i
pval...(no longer on Chromium) 2015/03/26 21:17:57 Done.
+ "option java_multiple_files = true; "
+ "option java_package = \"org.chromium.sync.protocol\";"
+ "/g' %s" % new_proto_file_path)
+
+
+if __name__ == '__main__':
+ sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698