litex_setup: add litespi core
[litex.git] / litex_setup.py
1 #!/usr/bin/env python3
2
3 import os
4 import sys
5 from collections import OrderedDict
6
7
8 current_path = os.path.dirname(os.path.realpath(__file__))
9
10 # name, (url, recursive clone, develop)
11 repos = [
12 # HDL
13 ("migen", ("https://github.com/m-labs/", True, True)),
14
15 # LiteX SoC builder
16 ("litex", ("https://github.com/enjoy-digital/", True, True)),
17
18 # LiteX cores ecosystem
19 ("liteeth", ("https://github.com/enjoy-digital/", False, True)),
20 ("litedram", ("https://github.com/enjoy-digital/", False, True)),
21 ("litepcie", ("https://github.com/enjoy-digital/", False, True)),
22 ("litesata", ("https://github.com/enjoy-digital/", False, True)),
23 ("litesdcard", ("https://github.com/enjoy-digital/", False, True)),
24 ("liteiclink", ("https://github.com/enjoy-digital/", False, True)),
25 ("litevideo", ("https://github.com/enjoy-digital/", False, True)),
26 ("litescope", ("https://github.com/enjoy-digital/", False, True)),
27 ("litejesd204b", ("https://github.com/enjoy-digital/", False, True)),
28 ("litespi", ("https://github.com/litex-hub/", False, True)),
29
30 # LiteX boards support
31 ("litex-boards", ("https://github.com/litex-hub/", False, True)),
32 ]
33 repos = OrderedDict(repos)
34
35 if len(sys.argv) < 2:
36 print("Available commands:")
37 print("- init")
38 print("- install (add --user to install to user directory)")
39 print("- update")
40 exit()
41
42 if "init" in sys.argv[1:]:
43 for name in repos.keys():
44 url, need_recursive, need_develop = repos[name]
45 # clone repo (recursive if needed)
46 print("[cloning " + name + "]...")
47 full_url = url + name
48 opts = "--recursive" if need_recursive else ""
49 os.system("git clone " + full_url + " " + opts)
50
51 if "install" in sys.argv[1:]:
52 for name in repos.keys():
53 url, need_recursive, need_develop = repos[name]
54 # develop if needed
55 print("[installing " + name + "]...")
56 if need_develop:
57 os.chdir(os.path.join(current_path, name))
58 if "--user" in sys.argv[1:]:
59 os.system("python3 setup.py develop --user")
60 else:
61 os.system("python3 setup.py develop")
62
63 if "update" in sys.argv[1:]:
64 for name in repos.keys():
65 # update
66 print("[updating " + name + "]...")
67 os.chdir(os.path.join(current_path, name))
68 os.system("git pull")