1 # The MIT License (MIT)
3 # Copyright (c) 2014 Philippe Proulx <philippe.proulx@efficios.com>
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 from termcolor
import cprint
, colored
29 def _perror(msg
, exit_code
=1):
30 cprint('Error: {}'.format(msg
), 'red', attrs
=['bold'], file=sys
.stderr
)
35 cprint(':: {}'.format(msg
), 'blue', attrs
=['bold'], file=sys
.stderr
)
39 ap
= argparse
.ArgumentParser()
41 ap
.add_argument('-O', '--output', metavar
='OUTPUT', action
='store',
43 help='output directory of C files')
44 ap
.add_argument('-p', '--prefix', metavar
='PREFIX', action
='store',
46 help='custom prefix for C function and structure names')
47 ap
.add_argument('-s', '--static-inline', action
='store_true',
48 help='generate static inline C functions')
49 ap
.add_argument('-c', '--manual-clock', action
='store_true',
50 help='do not use a clock callback: pass clock value to tracing functions')
51 ap
.add_argument('metadata', metavar
='METADATA', action
='store',
52 help='CTF metadata input file')
55 args
= ap
.parse_args()
57 # validate output directory
58 if not os
.path
.isdir(args
.output
):
59 _perror('"{}" is not an existing directory'.format(args
.output
))
62 if not re
.match(r
'^[a-zA-Z_][a-zA-Z0-9_]*$', args
.prefix
):
63 _perror('"{}" is not a valid C identifier'.format(args
.prefix
))
65 # validate that metadata file exists
66 if not os
.path
.isfile(args
.metadata
):
67 _perror('"{}" is not an existing file'.format(args
.metadata
))
72 def gen_barectf(output
, prefix
, static_inline
, manual_clock
):
81 gen_barectf(args
.output
, args
.prefix
, args
.static_inline
,
This page took 0.045805 seconds and 5 git commands to generate.