| Index: third_party/grpc/tools/buildgen/plugins/list_api.py
|
| diff --git a/third_party/WebKit/Source/build/scripts/make_internal_runtime_flags.py b/third_party/grpc/tools/buildgen/plugins/list_api.py
|
| similarity index 52%
|
| copy from third_party/WebKit/Source/build/scripts/make_internal_runtime_flags.py
|
| copy to third_party/grpc/tools/buildgen/plugins/list_api.py
|
| index 131394158827761ba9ef8f782c019eff403493d1..ff937a0ab837acd0b2365f3a16153eadbbc9dcab 100755
|
| --- a/third_party/WebKit/Source/build/scripts/make_internal_runtime_flags.py
|
| +++ b/third_party/grpc/tools/buildgen/plugins/list_api.py
|
| @@ -1,5 +1,7 @@
|
| -#!/usr/bin/env python
|
| -# Copyright (C) 2013 Google Inc. All rights reserved.
|
| +#!/usr/bin/env python2.7
|
| +
|
| +# Copyright 2016, Google Inc.
|
| +# All rights reserved.
|
| #
|
| # Redistribution and use in source and binary forms, with or without
|
| # modification, are permitted provided that the following conditions are
|
| @@ -27,41 +29,50 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -import os.path
|
| +import collections
|
| +import fnmatch
|
| +import os
|
| +import re
|
| import sys
|
| +import yaml
|
| +
|
| +
|
| +_RE_API = r'(?:GPRAPI|GRPCAPI|CENSUSAPI)([^;]*);'
|
|
|
| -import in_generator
|
| -import make_runtime_features
|
| -import name_utilities
|
| -import template_expander
|
|
|
| +def list_c_apis(filenames):
|
| + for filename in filenames:
|
| + with open(filename, 'r') as f:
|
| + text = f.read()
|
| + for m in re.finditer(_RE_API, text):
|
| + api_declaration = re.sub('[ \r\n\t]+', ' ', m.group(1))
|
| + type_and_name, args_and_close = api_declaration.split('(', 1)
|
| + args = args_and_close[:args_and_close.rfind(')')].strip()
|
| + last_space = type_and_name.rfind(' ')
|
| + last_star = type_and_name.rfind('*')
|
| + type_end = max(last_space, last_star)
|
| + return_type = type_and_name[0:type_end+1].strip()
|
| + name = type_and_name[type_end+1:].strip()
|
| + yield {'return_type': return_type, 'name': name, 'arguments': args, 'header': filename}
|
|
|
| -# We want exactly the same parsing as RuntimeFeatureWriter
|
| -# but generate different files.
|
| -class InternalRuntimeFlagsWriter(make_runtime_features.RuntimeFeatureWriter):
|
| - class_name = 'InternalRuntimeFlags'
|
|
|
| - def __init__(self, in_file_path):
|
| - super(InternalRuntimeFlagsWriter, self).__init__(in_file_path)
|
| - self._outputs = {(self.class_name + '.idl'): self.generate_idl,
|
| - (self.class_name + '.h'): self.generate_header,
|
| - }
|
| +def headers_under(directory):
|
| + for root, dirnames, filenames in os.walk(directory):
|
| + for filename in fnmatch.filter(filenames, '*.h'):
|
| + yield os.path.join(root, filename)
|
|
|
| - @template_expander.use_jinja(class_name + '.idl.tmpl')
|
| - def generate_idl(self):
|
| - return {
|
| - 'features': self._features,
|
| - 'standard_features': self._standard_features,
|
| - }
|
|
|
| - @template_expander.use_jinja(class_name + '.h.tmpl')
|
| - def generate_header(self):
|
| - return {
|
| - 'features': self._features,
|
| - 'feature_sets': self._feature_sets(),
|
| - 'standard_features': self._standard_features,
|
| - }
|
| +def mako_plugin(dictionary):
|
| + apis = []
|
| +
|
| +# for lib in dictionary['libs']:
|
| +# if lib['name'] == 'grpc':
|
| +# apis.extend(list_c_apis(lib['public_headers']))
|
| + apis.extend(list_c_apis(sorted(headers_under('include/grpc'))))
|
| +
|
| + dictionary['c_apis'] = apis
|
|
|
|
|
| if __name__ == '__main__':
|
| - in_generator.Maker(InternalRuntimeFlagsWriter).main(sys.argv)
|
| + print yaml.dump([api for api in list_c_apis(headers_under('include/grpc'))])
|
| +
|
|
|