Skip to content

Commit

Permalink
add script for generate of one header file
Browse files Browse the repository at this point in the history
  • Loading branch information
satoren committed Feb 26, 2016
1 parent 75b5f1f commit 8072f87
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions utils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
26 changes: 26 additions & 0 deletions utils/generate_one_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import os
import sys
import re

def inner_include_path(line):
m = re.search('#include\s\"(?P<headername>.*)\"',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)

0 comments on commit 8072f87

Please sign in to comment.