-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup_params.py
executable file
·167 lines (137 loc) · 5.49 KB
/
setup_params.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
from __future__ import print_function, unicode_literals
from pyfiglet import Figlet
import subprocess
import argparse
import os
import regex
#import PyInquirer
from PyInquirer import style_from_dict, Token, prompt, Validator, ValidationError
from pprint import pprint
style = style_from_dict({
Token.QuestionMark: '#E91E63 bold',
Token.Selected: '#673AB7 bold',
Token.Instruction: '', # default
Token.Answer: '#2196f3 bold',
Token.Question: '',
})
'''
class directoryValidator(Validator):
def validate(self, document):
if not document.text=='':
if not os.path.isdir("/home/el"):
raise ValidationError(
message='Please enter valid directory for galapagos path',
cursor_position=len(document.text)
)
'''
f = Figlet(font='slant')
print(f.renderText('Welcome to Galapagos Setup'))
parser = argparse.ArgumentParser(description='Galapagos Menu')
parser.add_argument("-d", "--dir", help="absolute path where galapagos directory is located", default='')
parser.add_argument("-vd", "--vit_dir", help="absolute path of vitis", default='')
parser.add_argument("-hd", "--hls_dir", help="absolute path of vitis_hls", default='')
args = parser.parse_args()
questions = []
path_q = {
'type': 'input',
'name': 'galapagos_dir',
'message': 'What is the absolute path where the galapagos directory is located? (default=$PWD)',
}
vit_path_q = {
'type': 'input',
'name': 'vitis_dir',
'message': 'What is the directory vitis is located? (default=/mnt/shares/tools/Xilinx/Vitis)',
}
hls_path_q = {
'type': 'input',
'name': 'hls_dir',
'message': 'What is the directory vitis_hls is located? (default=/mnt/shares/tools/Xilinx/Vitis)',
}
if(args.dir ==''):
questions.append(path_q)
galapagos_dir = ''
else:
galapagos_dir = args.dir
if(args.vit_dir == ''):
questions.append(vit_path_q)
vitis_dir = ''
else:
vitis_dir = args.vit_dir
if(args.hls_dir == ''):
questions.append(hls_path_q)
hls_dir = ''
else:
hls_dir = args.hls_dir
vitis_ver = '2023.1'
hls_ver = '2023.1'
answers = prompt(questions, style=style)
if answers['galapagos_dir'] == '':
answers['galapagos_dir']=os.getcwd()
if answers['vitis_dir'] == '':
answers['vitis_dir'] = '/mnt/shares/tools/Xilinx/Vitis'
if answers['hls_dir'] == '':
answers['hls_dir'] = '/mnt/shares/tools/Xilinx/Vitis'
print('ENVIRONMENT VARIABLES SET:')
env_var = {'GALAPAGOS_PATH': answers['galapagos_dir'],
'GALAPAGOS_VITIS_PATH' : answers['vitis_dir'],
'GALAPAGOS_HLS_PATH' : answers['hls_dir'],
'GALAPAGOS_VITIS_VERSION' : '2023.1',
'GALAPAGOS_HLS_VERSION' : '2023.1'
}
pprint(env_var)
env_reset_file = open("environmental_reset.sh","w")
env_reset_file.write("source init_params.sh " + answers['galapagos_dir'] + ' ' + answers['vitis_dir'] + ' ' + answers['hls_dir'] + ' 2023.1 2023.1 ' + '\n')
out_file = open("my_init.sh", "w")
invalid = True
answer = "n"
while invalid:
invalid = False
if ((answer == "yes") or (answer == "y")):
while ((answer == "yes") or (answer == "y")):
print('What is the board name you want to install? or type CANCEL to cancel board instalation\n')
print('options: sidewinder, u200, u250, u280, vck5000')
board_name = str(input()).strip().lower()
running = True
if board_name == "cancel":
running = False
print("aborting board install, just installing parameters")
out_file.close()
out_file = open("my_init.sh","w")
out_file.write("source init_params.sh " + answers['galapagos_dir'] + ' ' + answers['vitis_dir'] + ' ' + answers['hls_dir'] + ' 2023.1 2023.1 ' + '\n')
answer = "n"
elif board_name == "sidewinder":
answers['boa_name'] = 'sidewinder'
answers['par_name'] = 'xczu19eg-ffvc1760-2-i'
elif board_name == "u200":
answers['boa_name'] = 'u200'
answers['par_name'] = 'xcu200-fsgd2104-2-e'
elif board_name == "u250":
answers['boa_name'] = 'u250'
answers['par_name'] = 'xcu250-figd2104-2l-e'
elif board_name == "u280":
answers['boa_name'] = 'u280'
answers['par_name'] = 'xcu280-fsvh2892-2l-e'
elif board_name == "vck5000":
answers['boa_name'] = 'vck5000'
answers['par_name'] = 'xcvc1902-vsvd1760-2mp-e-s'
else:
print("Unrecongnized board name, try again\n")
running=False
if running:
print("Installing board "+answers['boa_name']+" which is part "+answers['par_name']+"\n Is this correct (Y/N)?")
confirmation = str(input()).strip().lower()
if ((confirmation == "no") or (confirmation == "n")):
running = False
if running:
out_file.write("source init.sh " + answers['galapagos_dir'] + ' ' + answers['vitis_dir'] + ' ' + answers['hls_dir'] + ' 2023.1 2023.1 ' + answers['par_name'] + ' ' + answers['boa_name'] +'\n')
out_file.write("make hlsmiddleware\n")
print("Are there other boards you wish to install in this project? (Y/N)")
answer = str(input()).strip().lower()
while ((answer not in ['y','yes','n','no'])):
print("invalid answer, please enter y or n")
answer = str(input()).strip().lower()
elif ((answer == "no") or (answer == "n")):
out_file.write("")
else:
print("<"+answer + "> is invalid, please enter y or n")
out_file.close()