diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8544073..5c27f18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -103,6 +103,8 @@ jobs: run: | sudo apt-get install asciidoctor asciidoctor doc/openmethod.adoc -o build_outputs_folder/index.html + - name: Build flat headers + run: dev/flatten.sh - name: Upload static files as artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/dev/flatten.py b/dev/flatten.py index 647f171..01c9805 100644 --- a/dev/flatten.py +++ b/dev/flatten.py @@ -5,19 +5,20 @@ from pathlib import Path import re parser = argparse.ArgumentParser() -parser.add_argument('output', type=Path) -parser.add_argument('input', nargs="+", type=Path) +parser.add_argument("output", type=Path) +parser.add_argument("input", nargs="+", type=Path) args = parser.parse_args() prefix = args.input[0].absolute() -while prefix.name != 'boost': +while prefix.name != "boost": assert prefix.parent != prefix prefix = prefix.parent prefix = prefix.parent skip = len(str(prefix)) + 1 + def flatten(input, output, done): header = str(input)[skip:] if header in done: @@ -25,16 +26,22 @@ def flatten(input, output, done): done.add(header) with input.open() as ifh: for line in ifh: + if input.name != "openmethod.hpp" and re.match( + r"#include <(boost/openmethod/core\.hpp+)>", line + ): + continue + if m := re.match(r"#include <(boost/openmethod/[^>]+)>", line): include = m[1] print(file=output) flatten(prefix / include, output, done) print(file=output) - else: - output.write(line) + continue + + output.write(line) -with args.output.open('w') as ofh: +with args.output.open("w") as ofh: done = set() for input in args.input: flatten(input.absolute(), ofh, done) diff --git a/dev/flatten.sh b/dev/flatten.sh new file mode 100755 index 0000000..cef33e6 --- /dev/null +++ b/dev/flatten.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +mkdir -p build_outputs_folder/boost/openmethod + +python3 dev/flatten.py build_outputs_folder/boost/openmethod.hpp \ + include/boost/openmethod.hpp + +for header in core compiler shared_ptr unique_ptr; do + python3 dev/flatten.py "build_outputs_folder/boost/openmethod/$header.hpp" \ + "include/boost/openmethod/$header.hpp" +done