()
| 71 | total_line_count += 1 |
| 72 | |
| 73 | def _main(): |
| 74 | parser = argparse.ArgumentParser( |
| 75 | description='Generates a single include file from a file including multiple C/C++ headers') |
| 76 | parser.add_argument('-i', '--input', action='store', type=str, default='in.cpp', |
| 77 | help='Input file including the headers to be merged') |
| 78 | parser.add_argument('-o', '--output', action='store', type=str, default='out.cpp', |
| 79 | help='Output file. NOTE: It will be overwritten!') |
| 80 | parser.add_argument('-p', '--path', action='store', type=str, default='.', |
| 81 | help='Include path') |
| 82 | parser.add_argument('--hash', action='store', type=str, |
| 83 | help='The git hash to print in the output file, e.g. the output of "git rev-parse HEAD"') |
| 84 | parser.add_argument('prefix', action='store', type=str, |
| 85 | help='Non-empty include file prefix (e.g. a/b)') |
| 86 | parser.add_argument('--linerefs', action='store_true', |
| 87 | help='Output #line references to the original files. By default the line references are written commented out') |
| 88 | args = parser.parse_args() |
| 89 | |
| 90 | regex_includes = re.compile(r"""^\s*#[\t\s]*include[\t\s]*("|\<)(?P<include>%s.*)("|\>)""" % args.prefix) |
| 91 | print('Rebuilding %s:' % args.input) |
| 92 | tmp_file_name = args.output + '.tmp' |
| 93 | with open(tmp_file_name, 'w') as tmp_file, open(args.input, 'r') as input_file: |
| 94 | tmp_file.write( |
| 95 | '#ifndef BOOST_LEAF_HPP_INCLUDED\n' |
| 96 | '#define BOOST_LEAF_HPP_INCLUDED\n' |
| 97 | '\n' |
| 98 | '// Boost LEAF single header distribution. Do not edit.\n' |
| 99 | '// Generated on ' + date.today().strftime('%b %d, %Y')) |
| 100 | if args.hash: |
| 101 | tmp_file.write( |
| 102 | ' from https://github.com/boostorg/leaf/tree/' + args.hash[0:7]) |
| 103 | tmp_file.write( |
| 104 | '.\n' |
| 105 | '\n' |
| 106 | '// Latest published version of this file: https://raw.githubusercontent.com/boostorg/leaf/gh-pages/leaf.hpp.\n' |
| 107 | '\n' |
| 108 | '// Copyright 2018-2025 Emil Dotchevski and Reverge Studios, Inc.\n' |
| 109 | '// Distributed under the Boost Software License, Version 1.0. (See accompanying\n' |
| 110 | '// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n' |
| 111 | '\n') |
| 112 | append(args.input, input_file, tmp_file, regex_includes, args.path, '' if args.linerefs else '// ', 0) |
| 113 | tmp_file.write( |
| 114 | '\n' |
| 115 | '#endif // BOOST_LEAF_HPP_INCLUDED\n' ) |
| 116 | compare_and_update(args.output, tmp_file_name) |
| 117 | # print('%d' % total_line_count) |
| 118 | |
| 119 | if __name__ == "__main__": |
no test coverage detected