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

Unified Diff: tools/protoc_wrapper/protoc_wrapper.py

Issue 343543003: Forbid hyphens in *.proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Extract a function for doing the work as requested Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/protoc_wrapper/protoc_wrapper.py
diff --git a/tools/protoc_wrapper/protoc_wrapper.py b/tools/protoc_wrapper/protoc_wrapper.py
index 69a7aec62b372e5ce52e658f5f2b65719fe3710b..7827c27e21bca714f6fc462c837bc8a9ca08b808 100755
--- a/tools/protoc_wrapper/protoc_wrapper.py
+++ b/tools/protoc_wrapper/protoc_wrapper.py
@@ -10,6 +10,7 @@ A simple wrapper for protoc.
- Handles building with system protobuf as an option.
"""
+import fnmatch
import optparse
import os.path
import shutil
@@ -41,6 +42,26 @@ def ModifyHeader(header_file, extra_header):
f.write(''.join(header_contents))
return 0
+def ScanForBadFiles(scan_root):
+ """Scan for bad file names, see crbug/386125 for details. Returns 1 if any
Paweł Hajdan Jr. 2014/06/20 18:38:22 nit: Please make the link clickable, http://crbug.
Andrew Hayden (chromium.org) 2014/06/25 08:40:24 Done.
+ filenames are bad. Outputs errors to stderr.
+
+ |scan_root| is the path to the directory to be recursively scanned.
+ """
+ badname = False
+ real_scan_root = os.path.realpath(scan_root)
+ for dirpath, dirnames, filenames in os.walk(real_scan_root):
+ matches = fnmatch.filter(filenames, '*-*.proto')
+ if len(matches) > 0:
+ if not badname:
+ badname = True
+ sys.stderr.write('proto files must not have hyphens in their names ('
+ 'see issue 386125 for more information):\n')
Paweł Hajdan Jr. 2014/06/20 18:38:22 Please make this a link, otherwise people can easi
Andrew Hayden (chromium.org) 2014/06/25 08:40:24 Done.
+ for filename in matches:
+ sys.stderr.write(' ' + os.path.join(real_scan_root,
+ dirpath, filename) + '\n')
+ return 1 if badname else 0
Paweł Hajdan Jr. 2014/06/20 18:38:22 This is Python, why not return bool? Also update t
Andrew Hayden (chromium.org) 2014/06/25 08:40:25 Done.
+
def RewriteProtoFilesForSystemProtobuf(path):
wrapper_dir = tempfile.mkdtemp()
@@ -84,6 +105,9 @@ def main(argv):
if len(args) < 2:
return 1
+ if ScanForBadFiles(options.proto_in_dir) != 0:
+ return 1
+
proto_path = options.proto_in_dir
if options.use_system_protobuf == 1:
proto_path = RewriteProtoFilesForSystemProtobuf(proto_path)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698