Skip to content

Commit

Permalink
Fix amalgamation
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletXF committed May 21, 2024
1 parent 3f70043 commit 764eaf2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/amalgamate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import re


def amalgamate(paths: [str], out_header: str, out_source: str):
visited = set()
header_content = "#pragma once\n"
Expand Down Expand Up @@ -35,17 +36,19 @@ def dfs(path, is_source=False):
for line in f:
if line.strip().startswith("#pragma once"):
continue
m = re.match(r'#include\s+<(.*)>', line)
m = re.match(r"#include\s+<(.*)>", line)
if not line.strip().startswith("#include") or m:
source_content += line
source_content += "\n"
for path in header_files:
with open(path, "r") as f:
for line in f:
if line.strip().startswith("#pragma once"):
continue
m = re.match(r'#include\s+<(.*)>', line)
m = re.match(r"#include\s+<(.*)>", line)
if not line.strip().startswith("#include") or m:
header_content += line
header_content += "\n"

with open(out_header, "w") as f:
f.write(header_content)
Expand All @@ -56,6 +59,7 @@ def dfs(path, is_source=False):
if __name__ == "__main__":
# glob to get all files
import sys

if len(sys.argv) < 4:
print("Usage: python amalgamate.py <out_header> <out_source> <in>...")
sys.exit(1)
Expand Down

0 comments on commit 764eaf2

Please sign in to comment.