| 1 |
# - /usr/bin/env python |
| 2 |
""" |
| 3 |
Reads a pyg file and emits the corresponding |
| 4 |
C++ header file into the specified destination |
| 5 |
directory. |
| 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("pyg_file", help="pyg file") |
| 17 |
parser.add_argument("destination_dir", help="destination directory") |
| 18 |
pargs = parser.parse_args(args) |
| 19 |
|
| 20 |
if not os.path.exists(pargs.pyg_file): |
| 21 |
logging.error('"{}" does not exist'.format(pargs.pyg_file)) |
| 22 |
return 1 |
| 23 |
|
| 24 |
if not mk_genfile_common.check_dir_exists(pargs.destination_dir): |
| 25 |
return 1 |
| 26 |
|
| 27 |
pyg_full_path = os.path.abspath(pargs.pyg_file) |
| 28 |
destination_dir_full_path = os.path.abspath(pargs.destination_dir) |
| 29 |
logging.info('Using {}'.format(pyg_full_path)) |
| 30 |
output = mk_genfile_common.mk_hpp_from_pyg(pyg_full_path, destination_dir_full_path) |
| 31 |
logging.info('Generated "{}"'.format(output)) |
| 32 |
return 0 |
| 33 |
|
| 34 |
if __name__ == '__main__': |
| 35 |
sys.exit(main(sys.argv[1:])) |
| 36 |
|