mirror of
https://github.com/boostorg/openmethod.git
synced 2026-01-19 04:22:12 +00:00
bring back flat headers
This commit is contained in:
@@ -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)
|
||||
|
||||
11
dev/flatten.sh
Executable file
11
dev/flatten.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user