-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathctypegen
executable file
·52 lines (48 loc) · 2.37 KB
/
ctypegen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# Copyright 2020 Arista Networks.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import CTypeGen
import argparse
import importlib
def main():
ap = argparse.ArgumentParser( description="Generate python from debug info" )
ap.add_argument( "-i", "--input", metavar="shared library", type=str,
nargs='+', help="libraries to process", required=True )
ap.add_argument( "-o", "--output", metavar="python output", type=str,
help="libraries to process", required=True )
ap.add_argument( "-m", "--modname", metavar="module-name", type=str,
help="name for python module", required=False )
ap.add_argument( "-M", "--macros", default=False, action='store_true',
help="include mappings for basic macros" )
ap.add_argument( "-c", "--nameless-enums", default=False, action='store_true',
help="use 'nameless enums'" )
ap.add_argument( "-S", "--skip-types", nargs="+", help="types to skip",
default=[] )
ap.add_argument( "-U", "--use-modules", nargs="+",
help="existing python modules to import and find definitions in",
default=[] )
ap.add_argument( "-C", "--nonamespaces",
help="don't walk C++ namespaces", default=False, action='store_true' )
res = ap.parse_args()
existingTypes= [ importlib.import_module( mod ) for mod in res.use_modules ]
CTypeGen.generateAll( res.input,
res.output,
modname=res.modname,
namelessEnums=res.nameless_enums,
macroFiles=( lambda fname: True ) if res.macros else None,
skipTypes=res.skip_types,
existingTypes=existingTypes,
namespaceFilter = lambda ns: not res.nonamespaces )
if __name__ == "__main__":
main()