From f861b35c82fc6ec94442a34c89395f96c9138781 Mon Sep 17 00:00:00 2001 From: Fabio Pellacini Date: Wed, 23 Jun 2021 07:24:28 +0200 Subject: [PATCH 1/5] Added analgamation script --- CONTRIBUTORS | 1 + script/amalgamate.py | 56 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 script/amalgamate.py diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7ca4c7d..58a037c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3,3 +3,4 @@ Maksim Kita Marcin Wojdyr Neal Richardson Tim Paine +Fabio Pellacini diff --git a/script/amalgamate.py b/script/amalgamate.py new file mode 100644 index 0000000..f4896e9 --- /dev/null +++ b/script/amalgamate.py @@ -0,0 +1,56 @@ +# text parts +processed_files = { } + +# authors +for filename in ['AUTHORS', 'CONTRIBUTORS']: + with open(filename) as f: + text = '' + for line in f: + if filename == 'AUTHORS': + text += '// fast_float by ' + line + if filename == 'CONTRIBUTORS': + text += '// with contributions from ' + line + processed_files[filename] = text + +# licenses +for filename in ['LICENSE-MIT', 'LICENSE-APACHE']: + with open(filename) as f: + text = '' + for line in f: + text += '// ' + line + processed_files[filename] = text + +# code +for filename in [ 'fast_float.h', 'float_common.h', 'ascii_number.h', + 'fast_table.h', 'decimal_to_binary.h', 'ascii_number.h', + 'simple_decimal_conversion.h', 'parse_number.h']: + with open('include/fast_float/' + filename) as f: + text = '' + for line in f: + if line.startswith('#include "'): continue + text += line + processed_files[filename] = text + +# command line +import argparse + +parser = argparse.ArgumentParser(description='Amalgamate fast_float.') +parser.add_argument('--license', default='MIT', help='choose license') +parser.add_argument('--output', default='', help='output file (stdout if none') + +args = parser.parse_args() + +text = '\n\n'.join([ + processed_files['AUTHORS'], processed_files['CONTRIBUTORS'], + processed_files['LICENSE-' + args.license], + processed_files['fast_float.h'], processed_files['float_common.h'], + processed_files['ascii_number.h'], processed_files['fast_table.h'], + processed_files['decimal_to_binary.h'], processed_files['ascii_number.h'], + processed_files['simple_decimal_conversion.h'], + processed_files['parse_number.h']]) + +if args.output: + with open(args.output, 'wt') as f: + f.write(text) +else: + print(text) From aea0ea79688a9d923430ad2fbbfb822fee0cd289 Mon Sep 17 00:00:00 2001 From: Fabio Pellacini Date: Wed, 23 Jun 2021 07:27:17 +0200 Subject: [PATCH 2/5] updated readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 2f1e2d6..0d95c2b 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,11 @@ target_link_libraries(myprogram PUBLIC fast_float) ``` +## Using as single header + +The script `amalgamate.py` may be used to generate a single header version of the library is so desired. +Just run the script from the root directory of this repository. +You can customize the license type and output file is desired as described in the command line help. ## Credit From f900953621b23762a9be854d07d2cb568cdd7c97 Mon Sep 17 00:00:00 2001 From: Fabio Pellacini Date: Wed, 23 Jun 2021 23:23:39 +0200 Subject: [PATCH 3/5] updated readme --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0d95c2b..4808c6a 100644 --- a/README.md +++ b/README.md @@ -143,9 +143,11 @@ target_link_libraries(myprogram PUBLIC fast_float) ## Using as single header -The script `amalgamate.py` may be used to generate a single header version of the library is so desired. +The script `scripts/amalgamate.py` may be used to generate a single header +version of the library if so desired. Just run the script from the root directory of this repository. -You can customize the license type and output file is desired as described in the command line help. +You can customize the license type and output file if desired as described in +the command line help. ## Credit From cdae8a0357f966c681ff26caff83ce0f6d2746e8 Mon Sep 17 00:00:00 2001 From: Fabio Pellacini Date: Wed, 23 Jun 2021 23:32:10 +0200 Subject: [PATCH 4/5] test for amalgamation --- .github/workflows/amalgamate-ubuntu20.yml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/amalgamate-ubuntu20.yml diff --git a/.github/workflows/amalgamate-ubuntu20.yml b/.github/workflows/amalgamate-ubuntu20.yml new file mode 100644 index 0000000..5a4257c --- /dev/null +++ b/.github/workflows/amalgamate-ubuntu20.yml @@ -0,0 +1,25 @@ +name: Amalgamate Ubuntu 20.04 CI (GCC 9, 8) + +on: [push, pull_request] + +jobs: + ubuntu-build: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + # Legacy/x86 compilers cause CI failures. + #- {cxx: -DCMAKE_CXX_COMPILER=g++-8, arch: } + - {cxx: , arch: } # default=gcc9 + #- {cxx: , arch: -DCMAKE_CXX_FLAGS="-m32"} # default=gcc9 + steps: + - uses: actions/checkout@v2 + - name: Compile with amalgamation + run: | + mkdir build && + mkdir build/fast_float && + python3 ./scripts/amalgamate.py > build/fast_float/fast_float.h && + cp tests/string_test.cpp build/ && + cd build && + g++ string_test.cpp From bd76291dd05c76bebdc6bb997dda67ffbbc91da6 Mon Sep 17 00:00:00 2001 From: Fabio Pellacini Date: Wed, 23 Jun 2021 23:33:58 +0200 Subject: [PATCH 5/5] updated test --- .github/workflows/amalgamate-ubuntu20.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/amalgamate-ubuntu20.yml b/.github/workflows/amalgamate-ubuntu20.yml index 5a4257c..3d47714 100644 --- a/.github/workflows/amalgamate-ubuntu20.yml +++ b/.github/workflows/amalgamate-ubuntu20.yml @@ -19,7 +19,7 @@ jobs: run: | mkdir build && mkdir build/fast_float && - python3 ./scripts/amalgamate.py > build/fast_float/fast_float.h && + python3 ./script/amalgamate.py > build/fast_float/fast_float.h && cp tests/string_test.cpp build/ && cd build && g++ string_test.cpp diff --git a/README.md b/README.md index 4808c6a..1b2ff6a 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ target_link_libraries(myprogram PUBLIC fast_float) ## Using as single header -The script `scripts/amalgamate.py` may be used to generate a single header +The script `script/amalgamate.py` may be used to generate a single header version of the library if so desired. Just run the script from the root directory of this repository. You can customize the license type and output file if desired as described in