7 from collections
import OrderedDict
11 current_path
= os
.path
.dirname(os
.path
.realpath(__file__
))
13 # Repositories -------------------------------------------------------------------------------------
15 # name, (url, recursive clone, develop)
18 ("migen", ("https://github.com/m-labs/", True, True)),
21 ("litex", ("https://github.com/enjoy-digital/", True, True)),
23 # LiteX cores ecosystem
24 ("liteeth", ("https://github.com/enjoy-digital/", False, True)),
25 ("litedram", ("https://github.com/enjoy-digital/", False, True)),
26 ("litepcie", ("https://github.com/enjoy-digital/", False, True)),
27 ("litesata", ("https://github.com/enjoy-digital/", False, True)),
28 ("litesdcard", ("https://github.com/enjoy-digital/", False, True)),
29 ("liteiclink", ("https://github.com/enjoy-digital/", False, True)),
30 ("litevideo", ("https://github.com/enjoy-digital/", False, True)),
31 ("litescope", ("https://github.com/enjoy-digital/", False, True)),
32 ("litejesd204b", ("https://github.com/enjoy-digital/", False, True)),
33 ("litespi", ("https://github.com/litex-hub/", False, True)),
35 # LiteX boards support
36 ("litex-boards", ("https://github.com/litex-hub/", False, True)),
38 repos
= OrderedDict(repos
)
40 # RISC-V toolchain download ------------------------------------------------------------------------
42 def sifive_riscv_download():
43 base_url
= "https://static.dev.sifive.com/dev-tools/"
44 base_file
= "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
47 if (sys
.platform
.startswith("win") or sys
.platform
.startswith("cygwin")):
48 end_file
= "w64-mingw32.zip"
50 elif sys
.platform
.startswith("linux"):
51 end_file
= "linux-ubuntu14.tar.gz"
53 elif sys
.platform
.startswith("darwin"):
54 end_file
= "apple-darwin.tar.gz"
56 raise NotImplementedError(sys
.platform
)
57 fn
= base_file
+ end_file
59 if not os
.path
.exists(fn
):
61 print("Downloading", url
, "to", fn
)
62 urllib
.request
.urlretrieve(url
, fn
)
64 print("Using existing file", fn
)
66 print("Extracting", fn
)
67 shutil
.unpack_archive(fn
)
69 # Setup --------------------------------------------------------------------------------------------
71 if os
.environ
.get("TRAVIS", "") == "true":
72 # Ignore `ssl.SSLCertVerificationError` on CI.
74 ssl
._create
_default
_https
_context
= ssl
._create
_unverified
_context
77 print("Available commands:")
79 print("- install (add --user to install to user directory)")
84 # Repositories cloning
85 if "init" in sys
.argv
[1:]:
86 os
.chdir(os
.path
.join(current_path
))
87 for name
in repos
.keys():
88 if not os
.path
.exists(name
):
89 url
, need_recursive
, need_develop
= repos
[name
]
90 # clone repo (recursive if needed)
91 print("[cloning " + name
+ "]...")
93 opts
= "--recursive" if need_recursive
else ""
94 subprocess
.check_call(
95 "git clone " + full_url
+ " " + opts
,
98 # Repositories installation
99 if "install" in sys
.argv
[1:]:
100 for name
in repos
.keys():
101 url
, need_recursive
, need_develop
= repos
[name
]
103 print("[installing " + name
+ "]...")
105 os
.chdir(os
.path
.join(current_path
, name
))
106 if "--user" in sys
.argv
[1:]:
107 subprocess
.check_call(
108 "python3 setup.py develop --user",
111 subprocess
.check_call(
112 "python3 setup.py develop",
114 os
.chdir(os
.path
.join(current_path
))
116 if "--user" in sys
.argv
[1:]:
117 if ".local/bin" not in os
.environ
.get("PATH", ""):
118 print("Make sure that ~/.local/bin is in your PATH")
119 print("export PATH=$PATH:~/.local/bin")
121 # Repositories update
122 if "update" in sys
.argv
[1:]:
123 for name
in repos
.keys():
124 if not os
.path
.exists(name
):
125 raise Exception("{} not initialized, please (re)-run init and install first.".format(name
))
127 print("[updating " + name
+ "]...")
128 os
.chdir(os
.path
.join(current_path
, name
))
129 subprocess
.check_call(
132 os
.chdir(os
.path
.join(current_path
))
134 # RISC-V GCC installation
135 if "gcc" in sys
.argv
[1:]:
136 sifive_riscv_download()
137 if "riscv64" not in os
.environ
.get("PATH", ""):
138 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
139 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")