Hi all,
Just wanted to share a little build script I wrote for gem5. It presents a
table with all the architectures and optimization levels. You can navigate
and select which versions you want to build and then it will build all of
those binaries for you. Your previous selections are saved in a little db
file, so you can just call the script and hit "enter" on subsequent runs.
It pulls the architecture list from the build_opts/ directory, so it will
stay up to date.
Run inside the gem5 base dir. Arrow keys to navigate, space_bar to toggle a
selection, enter_key to proceed, "q" to exit and discard changes.
Cheers!
Ryan Gambord
<[email protected]>
#!/usr/bin/env python3
import shelve
import sys
import signal
import curses
import multiprocessing
import subprocess
import os
arch_list = os.listdir('./build_opts')
var_list=['debug', 'opt', 'fast', 'prof', 'perf']
build_lines=[]
def print_table(scr, arch_list, var_list):
v_len = max([len(s) for s in var_list])
var_list = [" "*(v_len-len(s)) + s for s in var_list]
h_len = max([len(s) for s in arch_list])
arch_list = [" "*(h_len-len(s)) + s for s in arch_list]
for y in range(v_len):
scr.addstr(y,h_len, '│' + '│'.join([s[y] for s in var_list]) + '│')
for i,s in enumerate(arch_list):
scr.addstr(v_len + i*2, 0, '─'*h_len + '┼─'*len(var_list) + '┤')
scr.addstr(v_len + 1 + i*2, 0, s + '│ '*len(var_list) + '│')
scr.addstr(v_len+len(arch_list)*2,0, '─'*h_len + '┴─'*len(var_list) + '┘')
return v_len, h_len
def main(stdscr):
curses.use_default_colors()
attributes = {}
curses.init_pair(1, -1, -1)
attributes['normal'] = curses.color_pair(1)
stdscr.bkgd(' ', attributes['normal'])
attributes['highlighted'] = curses.color_pair(1) | curses.A_REVERSE
v_off, h_off = print_table(stdscr, arch_list, var_list)
with shelve.open('build_state.db') as db:
selection=db.get('selection', set())
for (y,x) in selection:
stdscr.addch(v_off + 1 + y*2, h_off + 1 + x*2, 'X')
s_x=db.get('s_x', 0)
s_y=db.get('s_y', 0)
while True:
stdscr.move(v_off + 1 + s_y*2, h_off + 1 + s_x*2)
c = stdscr.getch()
if c == curses.KEY_LEFT and s_x > 0:
s_x -= 1
elif c == curses.KEY_RIGHT and s_x < len(var_list)-1:
s_x += 1
elif c == curses.KEY_UP and s_y > 0:
s_y -= 1
elif c == curses.KEY_DOWN and s_y < len(arch_list)-1:
s_y+=1
elif c == ord(' '):
if (s_y,s_x) in selection:
stdscr.addch(" ")
selection.remove((s_y,s_x))
else:
stdscr.addch("X")
selection.add((s_y,s_x))
elif c == ord('\n'):
break
elif c == ord('q'):
exit(1)
db['selection'] = selection
db['s_x'] = s_x
db['s_y'] = s_y
for (y,x) in selection:
build_lines.append("build/" + arch_list[y] + "/gem5." + var_list[x])
curses.wrapper(main)
if build_lines:
build_str = "python3 `which scons` \'" + '\' \''.join(build_lines) + '\' -j' + str(multiprocessing.cpu_count()-1)
print(build_str)
try:
p = subprocess.Popen(build_str, shell=True, executable="/bin/bash")
p.wait()
except KeyboardInterrupt:
p.terminate()
_______________________________________________
gem5-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s