1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
9 def CreateArgumentParser():
10 parser
= argparse
.ArgumentParser()
11 parser
.add_argument('declaration', help='Path to declaration file.')
12 parser
.add_argument('--root', default
='.', help='Path to src/ dir.')
13 parser
.add_argument('--destination',
14 help='Root directory for generated files.')
17 def ToUpperCamelCase(underscore_name
):
18 return re
.sub(r
'(?:_|^)(.)', lambda m
: m
.group(1).upper(), underscore_name
)
20 def ToLowerCamelCase(underscore_name
):
21 return re
.sub(r
'_(.)', lambda m
: m
.group(1).upper(), underscore_name
)
23 def PathToIncludeGuard(path
):
24 return re
.sub(r
'[/.]', '_', path
.upper()) + '_'
26 def CreateDirIfNotExists(path
):
27 if not os
.path
.isdir(path
):
28 if os
.path
.exists(path
):
29 raise Exception('%s exists and is not a directory.' % path
)