-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgen_pro.py
55 lines (45 loc) · 1.37 KB
/
gen_pro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import re
from pathlib import Path, PurePath
header = """
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
"""
print(header)
print()
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)
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)
headers.append(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
if len(path_seg) == 0:
include_path.add(path)
else:
include_path.add(os.path.join(*path_seg))
continue
print('INCLUDEPATH +=', ' \\\n'.join(sorted(include_path)))
print()
print('HEADERS +=', ' \\\n'.join(headers))
print()
print('SOURCES +=', ' \\\n'.join(sources))
print()