-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConstruct
More file actions
executable file
·57 lines (43 loc) · 1.41 KB
/
SConstruct
File metadata and controls
executable file
·57 lines (43 loc) · 1.41 KB
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
"""
SCons entry point
Invoke the command "scons" with a shell while the current directory is this file's directory
References:
- https://scons.org/
- https://github.com/SCons/scons/wiki
"""
import os
import sys
"""
CLI arguments
"""
AddOption(
"--project",
metavar="<directory name>",
default="lpc40xx_freertos",
help="Specify a target project directory to build."
)
def main():
project_dirpath = GetOption("project")
"""
Jump to the target project subsidary SConscript
"""
if not os.path.isdir(project_dirpath):
print("Target project directory [{}] does not exist or is not a directory!".format(project_dirpath))
sys.exit(-1)
elif not has_subsidary_scons(Dir(project_dirpath)):
print("Target project directory [{}] is invalid! Expecting SConscript inside!".format(project_dirpath))
sys.exit(-1)
else:
project_dirnode = Dir(project_dirpath)
Export("project_dirnode")
SConscript("SConscript")
def has_subsidary_scons(dirnode):
"""
Check if a directory node has a subsidiary SConscript file exactly named "SConscript"
:param dirnode: A directory node (Dir)
:return: Boolean indicating that the provided directory node contains an SConscript file (bool)
"""
dirnode = Dir(dirnode)
filenames = os.listdir(dirnode.abspath)
return len(list(filter(lambda filename: filename == "SConscript", filenames))) > 0
main()