Skip to content

Commit f861b35

Browse files
committed
Added analgamation script
1 parent 8159e8b commit f861b35

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Maksim Kita
33
Marcin Wojdyr
44
Neal Richardson
55
Tim Paine
6+
Fabio Pellacini

script/amalgamate.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# text parts
2+
processed_files = { }
3+
4+
# authors
5+
for filename in ['AUTHORS', 'CONTRIBUTORS']:
6+
with open(filename) as f:
7+
text = ''
8+
for line in f:
9+
if filename == 'AUTHORS':
10+
text += '// fast_float by ' + line
11+
if filename == 'CONTRIBUTORS':
12+
text += '// with contributions from ' + line
13+
processed_files[filename] = text
14+
15+
# licenses
16+
for filename in ['LICENSE-MIT', 'LICENSE-APACHE']:
17+
with open(filename) as f:
18+
text = ''
19+
for line in f:
20+
text += '// ' + line
21+
processed_files[filename] = text
22+
23+
# code
24+
for filename in [ 'fast_float.h', 'float_common.h', 'ascii_number.h',
25+
'fast_table.h', 'decimal_to_binary.h', 'ascii_number.h',
26+
'simple_decimal_conversion.h', 'parse_number.h']:
27+
with open('include/fast_float/' + filename) as f:
28+
text = ''
29+
for line in f:
30+
if line.startswith('#include "'): continue
31+
text += line
32+
processed_files[filename] = text
33+
34+
# command line
35+
import argparse
36+
37+
parser = argparse.ArgumentParser(description='Amalgamate fast_float.')
38+
parser.add_argument('--license', default='MIT', help='choose license')
39+
parser.add_argument('--output', default='', help='output file (stdout if none')
40+
41+
args = parser.parse_args()
42+
43+
text = '\n\n'.join([
44+
processed_files['AUTHORS'], processed_files['CONTRIBUTORS'],
45+
processed_files['LICENSE-' + args.license],
46+
processed_files['fast_float.h'], processed_files['float_common.h'],
47+
processed_files['ascii_number.h'], processed_files['fast_table.h'],
48+
processed_files['decimal_to_binary.h'], processed_files['ascii_number.h'],
49+
processed_files['simple_decimal_conversion.h'],
50+
processed_files['parse_number.h']])
51+
52+
if args.output:
53+
with open(args.output, 'wt') as f:
54+
f.write(text)
55+
else:
56+
print(text)

0 commit comments

Comments
 (0)