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

Unified Diff: components/cronet/tools/api_static_checks.py

Issue 2544043002: [Cronet] Enforce Cronet API never modified, only grown (Closed)
Patch Set: fix Created 4 years 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: components/cronet/tools/api_static_checks.py
diff --git a/components/cronet/tools/api_static_checks.py b/components/cronet/tools/api_static_checks.py
index 1c67132ce428fc83e15452175cf876913384a5d6..861594773d0e272b7a33f614fb0d030187c3db9b 100755
--- a/components/cronet/tools/api_static_checks.py
+++ b/components/cronet/tools/api_static_checks.py
@@ -3,9 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""api_static_checks.py - Check Cronet implementation does not call through
-API classes.
-"""
+"""api_static_checks.py - Enforce Cronet API requirements."""
import argparse
import os
@@ -14,6 +12,8 @@ import shutil
import sys
import tempfile
+import update_api
+
REPOSITORY_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__), '..', '..', '..'))
@@ -22,7 +22,7 @@ import build_utils
# These regular expressions catch the beginning of lines that declar classes and
# methods. The first group returned by a match is the class or method name.
-CLASS_RE = re.compile(r'.*class ([^ ]*) .*{')
+from update_api import CLASS_RE
METHOD_RE = re.compile(r'.* ([^ ]*)\(.*\);')
# Allowed exceptions. Adding anything to this list is dangerous and should be
@@ -93,24 +93,9 @@ def find_api_calls(dump, api_classes, bad_calls):
bad_calls += [bad_call]
-def main(args):
+def check_api_calls(opts):
# Returns True if no calls through API classes in implementation.
- parser = argparse.ArgumentParser(
- description='Check modules do not contain ARM Neon instructions.')
- parser.add_argument('--api_jar',
- help='Path to API jar (i.e. cronet_api.jar)',
- required=True,
- metavar='path/to/cronet_api.jar')
- parser.add_argument('--impl_jar',
- help='Path to implementation jar '
- '(i.e. cronet_impl_native_java.jar)',
- required=True,
- metavar='path/to/cronet_impl_native_java.jar',
- action='append')
- parser.add_argument('--stamp', help='Path to touch on success.')
- opts = parser.parse_args(args)
-
temp_dir = tempfile.mkdtemp()
# Extract API class files from jar
@@ -162,10 +147,40 @@ def main(args):
print ' does not contain newer methods. Please call through a'
print ' wrapper class from VersionSafeCallbacks.'
print '\n'.join(api_calls)
+ return not api_calls
+
- if not api_calls and opts.stamp:
+def check_api_version(opts):
+ if update_api.check_up_to_date(opts.api_jar):
+ return True
+ print 'ERROR: API file out of date. Please run this command:'
+ print ' components/cronet/tools/update_api.py --api_jar %s' % (
+ os.path.abspath(opts.api_jar))
+ return False
+
+
+def main(args):
+ parser = argparse.ArgumentParser(
+ description='Enforce Cronet API requirements.')
+ parser.add_argument('--api_jar',
+ help='Path to API jar (i.e. cronet_api.jar)',
+ required=True,
+ metavar='path/to/cronet_api.jar')
+ parser.add_argument('--impl_jar',
+ help='Path to implementation jar '
+ '(i.e. cronet_impl_native_java.jar)',
+ required=True,
+ metavar='path/to/cronet_impl_native_java.jar',
+ action='append')
+ parser.add_argument('--stamp', help='Path to touch on success.')
+ opts = parser.parse_args(args)
+
+ ret = True
+ ret = check_api_calls(opts) and ret
+ ret = check_api_version(opts) and ret
+ if ret and opts.stamp:
build_utils.Touch(opts.stamp)
- return not api_calls
+ return ret
if __name__ == '__main__':

Powered by Google App Engine
This is Rietveld 408576698