-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolchain.py
More file actions
51 lines (35 loc) · 1.33 KB
/
toolchain.py
File metadata and controls
51 lines (35 loc) · 1.33 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
import os
import click
import json
additions = """
#define RED {0}
enum project_modes{{BASIC, LOWERCOMP, UPPERCOMP, SKILLS, NOAUTONOMOUS, UNITTEST}};
#define PROJECT_MODE {1}
"""
print("Joe's toolchain for easy stuff")
@click.group()
def cli():
pass
def build(color, mode, slot):
"""Builds, and uploads the program of the specified type"""
file_text = open(os.path.join("src", "main.cpp"), 'r').read()
modes = {'Lower Comp': 'LOWERCOMP', 'Upper Comp': 'UPPERCOMP', 'Basic Comp': 'BASIC', 'No Auto': 'NOAUTONOMOUS',
'Skills': 'SKILLS'}
specific_additions = additions.format('true' if color == 'red' else 'false', modes[mode])
open(os.path.join("src", "main.cpp"), 'w+').write(specific_additions + file_text)
os.system('prosv5 make')
os.system('prosv5 upload --slot {} --name "{}"'.format(slot, color.upper() + ' ' + mode))
open(os.path.join("src", "main.cpp"), 'w+').write(file_text)
@cli.command('fullbuild')
def full_build():
"""Builds, and uploads all of the programs"""
build('red', 'Lower Comp', '1')
build('red', 'Upper Comp', '2')
build('red', 'Basic Comp', '3')
build('blue', 'Lower Comp', '5')
build('blue', 'Upper Comp', '6')
build('blue', 'Basic Comp', '7')
build('red', 'No Auto', '4')
build('red', 'Skills', '8')
if __name__ == '__main__':
cli()