litex/litex_setup.py
Tim 'mithro' Ansell dd59dac571 litex_setup: Use subprocess so failures are noticed.
os.system doesn't report if any of the commands fail. This means that if
something goes wrong it happily reports success making it hard to debug
issues.
2020-04-06 11:27:40 -07:00

77 lines
2.6 KiB
Python
Executable file

#!/usr/bin/env python3
import os
import sys
import subprocess
from collections import OrderedDict
current_path = os.path.dirname(os.path.realpath(__file__))
# name, (url, recursive clone, develop)
repos = [
# HDL
("migen", ("https://github.com/m-labs/", True, True)),
# LiteX SoC builder
("litex", ("https://github.com/enjoy-digital/", True, True)),
# LiteX cores ecosystem
("liteeth", ("https://github.com/enjoy-digital/", False, True)),
("litedram", ("https://github.com/enjoy-digital/", False, True)),
("litepcie", ("https://github.com/enjoy-digital/", False, True)),
("litesata", ("https://github.com/enjoy-digital/", False, True)),
("litesdcard", ("https://github.com/enjoy-digital/", False, True)),
("liteiclink", ("https://github.com/enjoy-digital/", False, True)),
("litevideo", ("https://github.com/enjoy-digital/", False, True)),
("litescope", ("https://github.com/enjoy-digital/", False, True)),
("litejesd204b", ("https://github.com/enjoy-digital/", False, True)),
("litespi", ("https://github.com/litex-hub/", False, True)),
# LiteX boards support
("litex-boards", ("https://github.com/litex-hub/", False, True)),
]
repos = OrderedDict(repos)
if len(sys.argv) < 2:
print("Available commands:")
print("- init")
print("- install (add --user to install to user directory)")
print("- update")
exit()
if "init" in sys.argv[1:]:
for name in repos.keys():
url, need_recursive, need_develop = repos[name]
# clone repo (recursive if needed)
print("[cloning " + name + "]...")
full_url = url + name
opts = "--recursive" if need_recursive else ""
subprocess.check_call(
"git clone " + full_url + " " + opts,
shell=True)
if "install" in sys.argv[1:]:
for name in repos.keys():
url, need_recursive, need_develop = repos[name]
# develop if needed
print("[installing " + name + "]...")
if need_develop:
os.chdir(os.path.join(current_path, name))
if "--user" in sys.argv[1:]:
subprocess.check_call(
"python3 setup.py develop --user",
shell=True)
else:
subprocess.check_call(
"python3 setup.py develop",
shell=True)
if "update" in sys.argv[1:]:
for name in repos.keys():
# update
print("[updating " + name + "]...")
os.chdir(os.path.join(current_path, name))
subprocess.check_call(
"git pull",
shell=True)