| 1 |
# -- /usr/bin/env python |
| 2 |
""" |
| 3 |
Determines the available global parameters from a list of header files and |
| 4 |
generates a ``gparams_register_modules.cpp`` file in the destination directory |
| 5 |
that defines a function ``void gparams_register_modules()``. |
| 6 |
""" |
| 7 |
import mk_genfile_common |
| 8 |
import argparse |
| 9 |
import logging |
| 10 |
import os |
| 11 |
import sys |
| 12 |
|
| 13 |
def main(args): |
| 14 |
logging.basicConfig(level=logging.INFO) |
| 15 |
parser = argparse.ArgumentParser(description=__doc__) |
| 16 |
parser.add_argument("destination_dir", help="destination directory") |
| 17 |
parser.add_argument("header_files", nargs="+", |
| 18 |
help="One or more header files to parse") |
| 19 |
pargs = parser.parse_args(args) |
| 20 |
|
| 21 |
if not mk_genfile_common.check_dir_exists(pargs.destination_dir): |
| 22 |
return 1 |
| 23 |
|
| 24 |
if not mk_genfile_common.check_files_exist(pargs.header_files): |
| 25 |
return 1 |
| 26 |
|
| 27 |
h_files_full_path = [] |
| 28 |
for header_file in pargs.header_files: |
| 29 |
h_files_full_path.append(os.path.abspath(header_file)) |
| 30 |
|
| 31 |
output = mk_genfile_common.mk_gparams_register_modules_internal( |
| 32 |
h_files_full_path, |
| 33 |
pargs.destination_dir |
| 34 |
) |
| 35 |
logging.info('Generated "{}"'.format(output)) |
| 36 |
return 0 |
| 37 |
|
| 38 |
if __name__ == '__main__': |
| 39 |
sys.exit(main(sys.argv[1:])) |
| 40 |
|