-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
94 lines (67 loc) · 2.49 KB
/
SConstruct
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#*#*#*#*#*#*#*#*#*#*#*#
#*#*# Cooper FSAE #*#*#
#*#*#*#*#*#*#*#*#*#*#*#
import os
# Basic setup ---------------------------------------------
# We should get more disciplined about our PATH later.
env = Environment(ENV = {'PATH' : os.environ['PATH']})
# Save the repo root in the env
env['REPO_ROOT'] = env.Dir('.')
Decider('content-timestamp')
term = os.environ.get('TERM') # for color
if term is not None:
env['ENV']['TERM'] = term
# ---------------------------------------------------------
# Global help adder function ------------------------------
help_list = []
def AddHelp(cmd, text):
global help_list
help_list.append((cmd, text))
env['AddHelp'] = AddHelp
# ---------------------------------------------------------
# Cleaning targets ----------------------------------------
[rm_build] = env.Command(
'phony-rm-build',
[],
'rm -rf build/'
)
[rm_deps] = env.Command(
'phony-rm-deps',
[],
'rm -rf deps/'
)
env.Alias('clean', rm_build)
env.Alias('cleanall', [rm_build, rm_deps])
AddHelp('clean', 'Clean (remove) build/ directory')
AddHelp('cleanall', 'Clean (remove) build/ and deps/ (aka everything)')
# ---------------------------------------------------------
# Call SConscripts ----------------------------------------
Default(None)
Export('env')
# Dependencies first
env.SConscript('dependencies.SConscript', variant_dir='deps', duplicate=0)
env.SConscript('can/SConscript', variant_dir='build/can', duplicate=0)
env.SConscript('fw/SConscript', variant_dir='build/fw', duplicate=0)
# ---------------------------------------------------------
# Populate Help -------------------------------------------
# scons provides Help for you to call to provide the text given by `scons -h`.
# you can call Help more than once and it will append.
Help('''
So you want to build a car?
You can specify targets after `scons`, like:
''')
help_list.sort()
for (cmd, text) in help_list:
Help(f" `scons {cmd + '`' : <30} {text : <60}\n")
Help(f'''
Note: try these helpful aliases (if you have `direnv`):
`fwpio` Equivalent to `pio`, but specifically for fw, can be
used anywhere in the repo, and uses scons. This is the
recommended way to use PlatformIO. For example:
$ fwpio run -e pch
''')
# ---------------------------------------------------------
if not COMMAND_LINE_TARGETS:
from SCons.Script import help_text
print(help_text)
exit(0)