-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuildaux.py
57 lines (46 loc) · 1.84 KB
/
buildaux.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
56
57
import SCons
def FindHeaderFiles(self, target):
def _find_sources(tgt, src, all):
for item in tgt:
if SCons.Util.is_List(item):
_find_sources(item, src, all)
else:
if item.abspath in all:
continue
all[item.abspath] = True
if item.path.endswith('.h') and not item.path.startswith('/usr'):
if not item.exists():
item = item.srcnode()
src.append(item.abspath)
else:
lst = item.children(scan=1)
_find_sources(lst, src, all)
sources = []
_find_sources(target, sources, {})
return sources
def FindAllSourceFiles(self, target):
def _find_sources(tgt, src, all):
for item in tgt:
if SCons.Util.is_List(item):
_find_sources(item, src, all)
else:
if item.abspath in all:
continue
all[item.abspath] = True
if item.path.endswith('.c'):
if not item.exists():
item = item.srcnode()
src.append(item.abspath)
elif item.path.endswith('.h') and not item.path.startswith('/usr'):
if not item.exists():
item = item.srcnode()
src.append(item.abspath)
else:
lst = item.children(scan=1)
_find_sources(lst, src, all)
sources = []
_find_sources(target, sources, {})
return sources
from SCons.Script.SConscript import SConsEnvironment # just do this once
SConsEnvironment.FindHeaderFiles = FindHeaderFiles
SConsEnvironment.FindAllSourceFiles = FindAllSourceFiles