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 url
, need_recursive
, need_develop
= repos
[name
]
101 # clone repo (recursive if needed)
102 print("[cloning " + name
+ "]...")
103 full_url
= url
+ name
104 opts
= "--recursive" if need_recursive
else ""
105 subprocess
.check_call(
106 "git clone " + full_url
+ " " + opts
,
109 # Repositories installation
110 if "install" in sys
.argv
[1:]:
111 for name
in repos
.keys():
112 url
, need_recursive
, need_develop
= repos
[name
]
114 print("[installing " + name
+ "]...")
116 os
.chdir(os
.path
.join(current_path
, name
))
117 if "--user" in sys
.argv
[1:]:
118 subprocess
.check_call(
119 "python3 setup.py develop --user",
122 subprocess
.check_call(
123 "python3 setup.py develop",
125 os
.chdir(os
.path
.join(current_path
))
127 if "--user" in sys
.argv
[1:]:
128 if ".local/bin" not in os
.environ
.get("PATH", ""):
129 print("Make sure that ~/.local/bin is in your PATH")
130 print("export PATH=$PATH:~/.local/bin")
132 # Repositories update
133 if "update" in sys
.argv
[1:]:
134 for name
in repos
.keys():
136 print("[updating " + name
+ "]...")
137 os
.chdir(os
.path
.join(current_path
, name
))
138 subprocess
.check_call(
139 "git pull --ff-only",
141 os
.chdir(os
.path
.join(current_path
))
143 # RISC-V GCC installation
144 if "gcc" in sys
.argv
[1:]:
145 sifive_riscv_download()
146 if "riscv64" not in os
.environ
.get("PATH", ""):
147 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
148 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")