From 8072f8721975f606a457aee18927e31fd0d0f778 Mon Sep 17 00:00:00 2001 From: satoren Date: Fri, 26 Feb 2016 17:30:56 +0900 Subject: [PATCH] add script for generate of one header file --- utils/Makefile | 3 +++ utils/generate_one_header.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 utils/generate_one_header.py diff --git a/utils/Makefile b/utils/Makefile index aabd9207..3301ef1b 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -5,6 +5,9 @@ gen_push_tuple: push_tuple_generator.py gen_ref_tuple: ref_tuple_generator.py python ref_tuple_generator.py > ../include/kaguya/gen/ref_tuple.inl + +one_header_file: generate_one_header.py + python generate_one_header.py > ../kaguya.hpp clean: diff --git a/utils/generate_one_header.py b/utils/generate_one_header.py new file mode 100644 index 00000000..16d64e28 --- /dev/null +++ b/utils/generate_one_header.py @@ -0,0 +1,26 @@ + +import os +import sys +import re + +def inner_include_path(line): + m = re.search('#include\s\"(?P.*)\"',line) + if m: + return m.group('headername') + return None; + +def parseheader(out,filepath,basedir,onceincludedfiles): + + for line in open(os.path.join(basedir,filepath), 'r'): + if line.find('#pragma once') != -1: + onceincludedfiles.append(os.path.join(basedir,filepath)) + path = inner_include_path(line) + if path: + if not os.path.join(basedir,path) in onceincludedfiles: + parseheader(out,path,basedir,onceincludedfiles) + else: + out.write(line) + +if __name__ == "__main__": + onceincludedfiles=[] + parseheader(sys.stdout,'kaguya\\kaguya.hpp','..\\include\\',onceincludedfiles) \ No newline at end of file