Merge pull request #116 from SamuelLongchamps/licenses_compliance

Added dual license option, proper copyright
This commit is contained in:
Daniel Lemire 2021-10-19 14:11:50 -04:00 committed by GitHub
commit a2fa7863fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 11 deletions

View File

@ -178,7 +178,7 @@
APPENDIX: How to apply the Apache License to your work. APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}" boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a comment syntax for the file format. We also recommend that a
@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.
Copyright 2020 The fast_float authors Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

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

View File

@ -10,15 +10,25 @@ for filename in ['AUTHORS', 'CONTRIBUTORS']:
text += '// fast_float by ' + line text += '// fast_float by ' + line
if filename == 'CONTRIBUTORS': if filename == 'CONTRIBUTORS':
text += '// with contributions from ' + line text += '// with contributions from ' + line
processed_files[filename] = text processed_files[filename] = text + '//\n'
# licenses # licenses
for filename in ['LICENSE-MIT', 'LICENSE-APACHE']: for filename in ['LICENSE-MIT', 'LICENSE-APACHE']:
lines = []
with open(filename) as f: with open(filename) as f:
text = '' lines = f.readlines()
for line in f:
text += '// ' + line # Retrieve subset required for inclusion in source
processed_files[filename] = text if filename == 'LICENSE-APACHE':
lines = [
' Copyright 2021 The fast_float authors\n',
*lines[189:-1]
]
text = ''
for line in lines:
text += '// ' + line.strip() + '\n'
processed_files[filename] = text
# code # code
for filename in [ 'fast_float.h', 'float_common.h', 'ascii_number.h', for filename in [ 'fast_float.h', 'float_common.h', 'ascii_number.h',
@ -29,20 +39,42 @@ for filename in [ 'fast_float.h', 'float_common.h', 'ascii_number.h',
for line in f: for line in f:
if line.startswith('#include "'): continue if line.startswith('#include "'): continue
text += line text += line
processed_files[filename] = text processed_files[filename] = '\n' + text
# command line # command line
import argparse import argparse
parser = argparse.ArgumentParser(description='Amalgamate fast_float.') parser = argparse.ArgumentParser(description='Amalgamate fast_float.')
parser.add_argument('--license', default='MIT', help='choose license') parser.add_argument('--license', default='DUAL', choices=['DUAL', 'MIT', 'APACHE'], help='choose license')
parser.add_argument('--output', default='', help='output file (stdout if none') parser.add_argument('--output', default='', help='output file (stdout if none')
args = parser.parse_args() args = parser.parse_args()
text = '\n\n'.join([ def license_content(license_arg):
result = []
if license_arg == 'DUAL':
result += [
'// Licensed under the Apache License, Version 2.0, or the\n',
'// MIT License at your option. This file may not be copied,\n',
'// modified, or distributed except according to those terms.\n',
'//\n'
]
if license_arg in ('DUAL', 'MIT'):
result.append('// MIT License Notice\n//\n')
result.append(processed_files['LICENSE-MIT'])
result.append('//\n')
if license_arg in ('DUAL', 'APACHE'):
result.append('// Apache License (Version 2.0) Notice\n//\n')
result.append(processed_files['LICENSE-APACHE'])
result.append('//\n')
return result
text = ''.join([
processed_files['AUTHORS'], processed_files['CONTRIBUTORS'], processed_files['AUTHORS'], processed_files['CONTRIBUTORS'],
processed_files['LICENSE-' + args.license], *license_content(args.license),
processed_files['fast_float.h'], processed_files['float_common.h'], processed_files['fast_float.h'], processed_files['float_common.h'],
processed_files['ascii_number.h'], processed_files['fast_table.h'], processed_files['ascii_number.h'], processed_files['fast_table.h'],
processed_files['decimal_to_binary.h'], processed_files['bigint.h'], processed_files['decimal_to_binary.h'], processed_files['bigint.h'],