add litex_setup script to clone and install Migen, LiteX and LiteX's cores
[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 ("migen", ("http://github.com/m-labs/", True, True)),
13 ("litex", ("http://github.com/enjoy-digital/", True, True)),
14 ("liteeth", ("http://github.com/enjoy-digital/", False, True)),
15 ("liteusb", ("http://github.com/enjoy-digital/", False, True)),
16 ("litedram", ("http://github.com/enjoy-digital/", False, True)),
17 ("litepcie", ("http://github.com/enjoy-digital/", False, True)),
18 ("litesdcard", ("http://github.com/enjoy-digital/", False, True)),
19 ("liteiclink", ("http://github.com/enjoy-digital/", False, True)),
20 ("litevideo", ("http://github.com/enjoy-digital/", False, True)),
21 ("litescope", ("http://github.com/enjoy-digital/", False, True)),
22 ]
23 repos = OrderedDict(repos)
24
25 if len(sys.argv) < 2:
26 print("Available commands:")
27 print("- init")
28 print("- install")
29 print("- update")
30 exit()
31
32 if "init" in sys.argv[1:]:
33 for name in repos.keys():
34 url, need_recursive, need_develop = repos[name]
35 # clone repo (recursive if needed)
36 print("[cloning " + name + "]...")
37 full_url = url + name
38 opts = "--recursive" if need_recursive else ""
39 os.system("git clone " + full_url + " " + opts)
40
41 if "install" in sys.argv[1:]:
42 for name in repos.keys():
43 url, need_recursive, need_develop = repos[name]
44 # develop if needed
45 print("[installing " + name + "]...")
46 if need_develop:
47 os.chdir(os.path.join(current_path, name))
48 os.system("python3 setup.py develop")
49
50 if "update" in sys.argv[1:]:
51 for name in repos.keys():
52 # update
53 print("[updating " + name + "]...")
54 os.chdir(os.path.join(current_path, name))
55 os.system("git pull")