7 from collections
import OrderedDict
11 current_path
= os
.path
.abspath(os
.curdir
)
14 # Repositories -------------------------------------------------------------------------------------
16 # name, (url, recursive clone, develop)
19 ("migen", ("https://github.com/m-labs/", True, True)),
20 ("nmigen", ("https://github.com/nmigen/", True, True)),
23 ("pythondata-software-compiler_rt", ("https://github.com/litex-hub/", False, True)),
24 ("litex", ("https://github.com/enjoy-digital/", False, True)),
26 # LiteX cores ecosystem
27 ("liteeth", ("https://github.com/enjoy-digital/", False, True)),
28 ("litedram", ("https://github.com/enjoy-digital/", False, True)),
29 ("litepcie", ("https://github.com/enjoy-digital/", False, True)),
30 ("litesata", ("https://github.com/enjoy-digital/", False, True)),
31 ("litesdcard", ("https://github.com/enjoy-digital/", False, True)),
32 ("liteiclink", ("https://github.com/enjoy-digital/", False, True)),
33 ("litevideo", ("https://github.com/enjoy-digital/", False, True)),
34 ("litescope", ("https://github.com/enjoy-digital/", False, True)),
35 ("litejesd204b", ("https://github.com/enjoy-digital/", False, True)),
36 ("litespi", ("https://github.com/litex-hub/", False, True)),
38 # LiteX boards support
39 ("litex-boards", ("https://github.com/litex-hub/", False, True)),
42 ("pythondata-misc-tapcfg", ("https://github.com/litex-hub/", False, True)),
43 ("pythondata-cpu-lm32", ("https://github.com/litex-hub/", False, True)),
44 ("pythondata-cpu-mor1kx", ("https://github.com/litex-hub/", False, True)),
45 ("pythondata-cpu-picorv32", ("https://github.com/litex-hub/", False, True)),
46 ("pythondata-cpu-serv", ("https://github.com/litex-hub/", False, True)),
47 ("pythondata-cpu-vexriscv", ("https://github.com/litex-hub/", False, True)),
48 ("pythondata-cpu-rocket", ("https://github.com/litex-hub/", False, True)),
49 ("pythondata-cpu-minerva", ("https://github.com/litex-hub/", False, True)),
50 ("pythondata-cpu-microwatt", ("https://github.com/litex-hub/", False, True)),
51 ("pythondata-cpu-blackparrot", ("https://github.com/litex-hub/", False, True)),
54 repos
= OrderedDict(repos
)
56 # RISC-V toolchain download ------------------------------------------------------------------------
58 def sifive_riscv_download():
59 base_url
= "https://static.dev.sifive.com/dev-tools/"
60 base_file
= "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
63 if (sys
.platform
.startswith("win") or sys
.platform
.startswith("cygwin")):
64 end_file
= "w64-mingw32.zip"
66 elif sys
.platform
.startswith("linux"):
67 end_file
= "linux-ubuntu14.tar.gz"
69 elif sys
.platform
.startswith("darwin"):
70 end_file
= "apple-darwin.tar.gz"
72 raise NotImplementedError(sys
.platform
)
73 fn
= base_file
+ end_file
75 if not os
.path
.exists(fn
):
77 print("Downloading", url
, "to", fn
)
78 urllib
.request
.urlretrieve(url
, fn
)
80 print("Using existing file", fn
)
82 print("Extracting", fn
)
83 shutil
.unpack_archive(fn
)
85 # Setup --------------------------------------------------------------------------------------------
87 if os
.environ
.get("TRAVIS", "") == "true":
88 # Ignore `ssl.SSLCertVerificationError` on CI.
90 ssl
._create
_default
_https
_context
= ssl
._create
_unverified
_context
93 print("Available commands:")
95 print("- install (add --user to install to user directory)")
100 # Repositories cloning
101 if "init" in sys
.argv
[1:]:
102 os
.chdir(os
.path
.join(current_path
))
103 for name
in repos
.keys():
104 if not os
.path
.exists(name
):
105 url
, need_recursive
, need_develop
= repos
[name
]
106 # clone repo (recursive if needed)
107 print("[cloning " + name
+ "]...")
108 full_url
= url
+ name
109 opts
= "--recursive" if need_recursive
else ""
110 subprocess
.check_call(
111 "git clone " + full_url
+ " " + opts
,
114 # Repositories installation
115 if "install" in sys
.argv
[1:]:
116 for name
in repos
.keys():
117 url
, need_recursive
, need_develop
= repos
[name
]
119 print("[installing " + name
+ "]...")
121 os
.chdir(os
.path
.join(current_path
, name
))
122 if "--user" in sys
.argv
[1:]:
123 subprocess
.check_call(
124 "python3 setup.py develop --user",
127 subprocess
.check_call(
128 "python3 setup.py develop",
130 os
.chdir(os
.path
.join(current_path
))
132 if "--user" in sys
.argv
[1:]:
133 if ".local/bin" not in os
.environ
.get("PATH", ""):
134 print("Make sure that ~/.local/bin is in your PATH")
135 print("export PATH=$PATH:~/.local/bin")
137 # Repositories update
138 if "update" in sys
.argv
[1:]:
139 for name
in repos
.keys():
140 if not os
.path
.exists(name
):
141 raise Exception("{} not initialized, please (re)-run init and install first.".format(name
))
143 print("[updating " + name
+ "]...")
144 os
.chdir(os
.path
.join(current_path
, name
))
145 subprocess
.check_call(
146 "git pull --ff-only",
148 os
.chdir(os
.path
.join(current_path
))
150 # RISC-V GCC installation
151 if "gcc" in sys
.argv
[1:]:
152 sifive_riscv_download()
153 if "riscv64" not in os
.environ
.get("PATH", ""):
154 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
155 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")