Skip to content

Commit 38b5900

Browse files
Added dual license option, proper copyright
Fixed #115
1 parent 052975d commit 38b5900

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

LICENSE-APACHE

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "{}"
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a
185185
file or class name and description of purpose be included on the
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2020 The fast_float authors
189+
Copyright [yyyy] [name of copyright owner]
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

LICENSE-MIT

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
MIT License
2+
3+
Copyright (c) 2021 The fast_float authors
4+
15
Permission is hereby granted, free of charge, to any
26
person obtaining a copy of this software and associated
37
documentation files (the "Software"), to deal in the

script/amalgamate.py

+41-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,25 @@
1010
text += '// fast_float by ' + line
1111
if filename == 'CONTRIBUTORS':
1212
text += '// with contributions from ' + line
13-
processed_files[filename] = text
13+
processed_files[filename] = text + '//\n'
1414

1515
# licenses
1616
for filename in ['LICENSE-MIT', 'LICENSE-APACHE']:
17+
lines = []
1718
with open(filename) as f:
18-
text = ''
19-
for line in f:
20-
text += '// ' + line
21-
processed_files[filename] = text
19+
lines = f.readlines()
20+
21+
# Retrieve subset required for inclusion in source
22+
if filename == 'LICENSE-APACHE':
23+
lines = [
24+
' Copyright 2021 The fast_float authors\n',
25+
*lines[189:-1]
26+
]
27+
28+
text = ''
29+
for line in lines:
30+
text += '// ' + line.strip() + '\n'
31+
processed_files[filename] = text
2232

2333
# code
2434
for filename in [ 'fast_float.h', 'float_common.h', 'ascii_number.h',
@@ -29,20 +39,42 @@
2939
for line in f:
3040
if line.startswith('#include "'): continue
3141
text += line
32-
processed_files[filename] = text
42+
processed_files[filename] = '\n' + text
3343

3444
# command line
3545
import argparse
3646

3747
parser = argparse.ArgumentParser(description='Amalgamate fast_float.')
38-
parser.add_argument('--license', default='MIT', help='choose license')
48+
parser.add_argument('--license', default='DUAL', choices=['DUAL', 'MIT', 'APACHE'], help='choose license')
3949
parser.add_argument('--output', default='', help='output file (stdout if none')
4050

4151
args = parser.parse_args()
4252

43-
text = '\n\n'.join([
53+
def license_content(license_arg):
54+
result = []
55+
56+
if license_arg == 'DUAL':
57+
result += [
58+
'// Licensed under the Apache License, Version 2.0, or the\n',
59+
'// MIT License at your option. This file may not be copied,\n',
60+
'// modified, or distributed except according to those terms.\n',
61+
'//\n'
62+
]
63+
64+
if license_arg in ('DUAL', 'MIT'):
65+
result.append('// MIT License Notice\n//\n')
66+
result.append(processed_files['LICENSE-MIT'])
67+
result.append('//\n')
68+
if license_arg in ('DUAL', 'APACHE'):
69+
result.append('// Apache License (Version 2.0) Notice\n//\n')
70+
result.append(processed_files['LICENSE-APACHE'])
71+
result.append('//\n')
72+
73+
return result
74+
75+
text = ''.join([
4476
processed_files['AUTHORS'], processed_files['CONTRIBUTORS'],
45-
processed_files['LICENSE-' + args.license],
77+
*license_content(args.license),
4678
processed_files['fast_float.h'], processed_files['float_common.h'],
4779
processed_files['ascii_number.h'], processed_files['fast_table.h'],
4880
processed_files['decimal_to_binary.h'], processed_files['bigint.h'],

0 commit comments

Comments
 (0)