]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/serf/build/gen_def.py
Update Apache Serf to 1.3.9 to support OpenSSL 1.1.1.
[FreeBSD/FreeBSD.git] / contrib / serf / build / gen_def.py
1 #!/usr/bin/env python
2 #
3 # gen_def.py :  Generate the .DEF file for Windows builds
4 #
5 # ===================================================================
6 #   Licensed to the Apache Software Foundation (ASF) under one
7 #   or more contributor license agreements.  See the NOTICE file
8 #   distributed with this work for additional information
9 #   regarding copyright ownership.  The ASF licenses this file
10 #   to you under the Apache License, Version 2.0 (the
11 #   "License"); you may not use this file except in compliance
12 #   with the License.  You may obtain a copy of the License at
13
14 #     http://www.apache.org/licenses/LICENSE-2.0
15
16 #   Unless required by applicable law or agreed to in writing,
17 #   software distributed under the License is distributed on an
18 #   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 #   KIND, either express or implied.  See the License for the
20 #   specific language governing permissions and limitations
21 #   under the License.
22 # ===================================================================
23 #
24 # Typically, this script is used like:
25 #
26 #    C:\PATH> python build/gen_def.py serf.h serf_bucket_types.h serf_bucket_util.h > build/serf.def
27 #
28
29 import re
30 import sys
31
32 # This regex parses function declarations that look like:
33 #
34 #    return_type serf_func1(...
35 #    return_type *serf_func2(...
36 #
37 # Where return_type is a combination of words and "*" each separated by a
38 # SINGLE space. If the function returns a pointer type (like serf_func2),
39 # then a space may exist between the "*" and the function name. Thus,
40 # a more complicated example might be:
41 #    const type * const * serf_func3(...
42 #
43 _funcs = re.compile(r'^(?:(?:\w+|\*) )+\*?(serf_[a-z][a-zA-Z_0-9]*)\(',
44                     re.MULTILINE)
45
46 # This regex parses the bucket type definitions which look like:
47 #
48 #    extern const serf_bucket_type_t serf_bucket_type_FOO;
49 #
50 _types = re.compile(r'^extern const serf_bucket_type_t (serf_[a-z_]*);',
51                     re.MULTILINE)
52
53
54 def extract_exports(fname):
55   content = open(fname).read()
56   exports = [ ]
57   for name in _funcs.findall(content):
58     exports.append(name)
59   for name in _types.findall(content):
60     exports.append(name)
61   return exports
62
63 # Blacklist the serf v2 API for now
64 blacklist = ['serf_connection_switch_protocol',
65              'serf_http_protocol_create',
66              'serf_http_request_create',
67              'serf_https_protocol_create']
68
69 if __name__ == '__main__':
70   # run the extraction over each file mentioned
71   import sys
72   print("EXPORTS")
73
74   for fname in sys.argv[1:]:
75     funclist = extract_exports(fname)
76     funclist = set(funclist) - set(blacklist)
77     for func in funclist:
78       print(func)