Skip to content

Commit

Permalink
do not go down include directory, usually the relative path is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
jszheng committed Apr 14, 2017
1 parent 361aedb commit f478b47
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions gen_pro.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import re
from pathlib import Path, PurePath

header = """
TEMPLATE = app
Expand All @@ -13,25 +15,34 @@
headers = []
sources = []
include_path = set()

for path, dirs, files in os.walk('.'):
if '.git' in dirs:
dirs.remove('.git')

for afile in files:
if afile.endswith('.c') or afile.endswith('.cpp') or afile.endswith('.cc'):
rel_path = os.path.join(path, afile)
rel_path = rel_path.replace('\\', '/', 1000)
#rel_path = rel_path.replace('\\', '/', 1000)
sources.append(rel_path)
continue

if afile.endswith('.h') or afile.endswith('.hpp'):
rel_path = os.path.join(path, afile)
rel_path = rel_path.replace('\\', '/', 1000)
#rel_path = rel_path.replace('\\', '/', 1000)
headers.append(rel_path)
include_path.add(os.path.dirname(rel_path))

p = Path(path)
segments = p.parts
path_seg = []
for segment in segments:
path_seg.append(segment)
if segment == 'include': # this is an include path, stop here.
break
include_path.add(os.path.join(*path_seg))
continue

print('INCLUDEPATH +=', '\\\n'.join(include_path))
print('INCLUDEPATH +=', ' \\\n'.join(sorted(include_path)))
print()

print('HEADERS +=', '\\\n'.join(headers))
Expand Down

0 comments on commit f478b47

Please sign in to comment.