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)),
22 ("pythondata-software-compiler_rt", ("https://github.com/litex-hub/", False, True)),
23 ("litex", ("https://github.com/enjoy-digital/", False, True)),
25 # LiteX cores ecosystem
26 ("liteeth", ("https://github.com/enjoy-digital/", False, True)),
27 ("litedram", ("https://github.com/enjoy-digital/", False, True)),
28 ("litepcie", ("https://github.com/enjoy-digital/", False, True)),
29 ("litesata", ("https://github.com/enjoy-digital/", False, True)),
30 ("litesdcard", ("https://github.com/enjoy-digital/", False, True)),
31 ("liteiclink", ("https://github.com/enjoy-digital/", False, True)),
32 ("litevideo", ("https://github.com/enjoy-digital/", False, True)),
33 ("litescope", ("https://github.com/enjoy-digital/", False, True)),
34 ("litejesd204b", ("https://github.com/enjoy-digital/", False, True)),
35 ("litespi", ("https://github.com/litex-hub/", False, True)),
37 # LiteX boards support
38 ("litex-boards", ("https://github.com/litex-hub/", False, True)),
41 ("pythondata-cpu-blackparrot", ("https://github.com/litex-hub/", False, True)),
42 ("pythondata-cpu-mor1kx", ("https://github.com/litex-hub/", False, True)),
43 ("pythondata-cpu-lm32", ("https://github.com/litex-hub/", False, True)),
44 ("pythondata-cpu-microwatt", ("https://github.com/litex-hub/", False, True)),
45 ("pythondata-cpu-picorv32", ("https://github.com/litex-hub/", False, True)),
46 ("pythondata-cpu-rocket", ("https://github.com/litex-hub/", False, True)),
47 ("pythondata-cpu-vexriscv", ("https://github.com/litex-hub/", False, True)),
48 ("pythondata-misc-tapcfg", ("https://github.com/litex-hub/", False, True)),
50 repos
= OrderedDict(repos
)
52 # RISC-V toolchain download ------------------------------------------------------------------------
54 def sifive_riscv_download():
55 base_url
= "https://static.dev.sifive.com/dev-tools/"
56 base_file
= "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
59 if (sys
.platform
.startswith("win") or sys
.platform
.startswith("cygwin")):
60 end_file
= "w64-mingw32.zip"
62 elif sys
.platform
.startswith("linux"):
63 end_file
= "linux-ubuntu14.tar.gz"
65 elif sys
.platform
.startswith("darwin"):
66 end_file
= "apple-darwin.tar.gz"
68 raise NotImplementedError(sys
.platform
)
69 fn
= base_file
+ end_file
71 if not os
.path
.exists(fn
):
73 print("Downloading", url
, "to", fn
)
74 urllib
.request
.urlretrieve(url
, fn
)
76 print("Using existing file", fn
)
78 print("Extracting", fn
)
79 shutil
.unpack_archive(fn
)
81 # Setup --------------------------------------------------------------------------------------------
83 if os
.environ
.get("TRAVIS", "") == "true":
84 # Ignore `ssl.SSLCertVerificationError` on CI.
86 ssl
._create
_default
_https
_context
= ssl
._create
_unverified
_context
89 print("Available commands:")
91 print("- install (add --user to install to user directory)")
96 # Repositories cloning
97 if "init" in sys
.argv
[1:]:
98 os
.chdir(os
.path
.join(current_path
))
99 for name
in repos
.keys():
100 if not os
.path
.exists(name
):
101 url
, need_recursive
, need_develop
= repos
[name
]
102 # clone repo (recursive if needed)
103 print("[cloning " + name
+ "]...")
104 full_url
= url
+ name
105 opts
= "--recursive" if need_recursive
else ""
106 subprocess
.check_call(
107 "git clone " + full_url
+ " " + opts
,
110 # Repositories installation
111 if "install" in sys
.argv
[1:]:
112 for name
in repos
.keys():
113 url
, need_recursive
, need_develop
= repos
[name
]
115 print("[installing " + name
+ "]...")
117 os
.chdir(os
.path
.join(current_path
, name
))
118 if "--user" in sys
.argv
[1:]:
119 subprocess
.check_call(
120 "python3 setup.py develop --user",
123 subprocess
.check_call(
124 "python3 setup.py develop",
126 os
.chdir(os
.path
.join(current_path
))
128 if "--user" in sys
.argv
[1:]:
129 if ".local/bin" not in os
.environ
.get("PATH", ""):
130 print("Make sure that ~/.local/bin is in your PATH")
131 print("export PATH=$PATH:~/.local/bin")
133 # Repositories update
134 if "update" in sys
.argv
[1:]:
135 for name
in repos
.keys():
136 if not os
.path
.exists(name
):
137 raise Exception("{} not initialized, please (re)-run init and install first.".format(name
))
139 print("[updating " + name
+ "]...")
140 os
.chdir(os
.path
.join(current_path
, name
))
141 subprocess
.check_call(
142 "git pull --ff-only",
144 os
.chdir(os
.path
.join(current_path
))
146 # RISC-V GCC installation
147 if "gcc" in sys
.argv
[1:]:
148 sifive_riscv_download()
149 if "riscv64" not in os
.environ
.get("PATH", ""):
150 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
151 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")