| 1 |
# -- /usr/bin/env python |
| 2 |
""" |
| 3 |
Determines the available tactics from a list of header files and generates a |
| 4 |
``install_tactic.cpp`` file in the destination directory that defines a |
| 5 |
function ``void install_tactics(tactic_manager& ctx)``. |
| 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("deps", help="file with header file names to parse") |
| 18 |
pargs = parser.parse_args(args) |
| 19 |
|
| 20 |
if not mk_genfile_common.check_dir_exists(pargs.destination_dir): |
| 21 |
return 1 |
| 22 |
|
| 23 |
if not mk_genfile_common.check_files_exist([pargs.deps]): |
| 24 |
return 1 |
| 25 |
|
| 26 |
with open(pargs.deps, 'r') as f: |
| 27 |
lines = f.read().split('\n') |
| 28 |
h_files_full_path = [os.path.abspath(header_file) |
| 29 |
for header_file in lines if header_file] |
| 30 |
|
| 31 |
if not mk_genfile_common.check_files_exist(h_files_full_path): |
| 32 |
return 1 |
| 33 |
|
| 34 |
output = mk_genfile_common.mk_install_tactic_cpp_internal( |
| 35 |
h_files_full_path, |
| 36 |
pargs.destination_dir |
| 37 |
) |
| 38 |
logging.info('Generated "{}"'.format(output)) |
| 39 |
return 0 |
| 40 |
|
| 41 |
if __name__ == '__main__': |
| 42 |
sys.exit(main(sys.argv[1:])) |