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 url
, need_recursive
, need_develop
= repos
[name
]
89 # clone repo (recursive if needed)
90 print("[cloning " + name
+ "]...")
92 opts
= "--recursive" if need_recursive
else ""
93 subprocess
.check_call(
94 "git clone " + full_url
+ " " + opts
,
97 # Repositories installation
98 if "install" in sys
.argv
[1:]:
99 for name
in repos
.keys():
100 url
, need_recursive
, need_develop
= repos
[name
]
102 print("[installing " + name
+ "]...")
104 os
.chdir(os
.path
.join(current_path
, name
))
105 if "--user" in sys
.argv
[1:]:
106 subprocess
.check_call(
107 "python3 setup.py develop --user",
110 subprocess
.check_call(
111 "python3 setup.py develop",
113 os
.chdir(os
.path
.join(current_path
))
115 if "--user" in sys
.argv
[1:]:
116 if ".local/bin" not in os
.environ
.get("PATH", ""):
117 print("Make sure that ~/.local/bin is in your PATH")
118 print("export PATH=$PATH:~/.local/bin")
120 # Repositories update
121 if "update" in sys
.argv
[1:]:
122 for name
in repos
.keys():
124 print("[updating " + name
+ "]...")
125 os
.chdir(os
.path
.join(current_path
, name
))
126 subprocess
.check_call(
129 os
.chdir(os
.path
.join(current_path
))
131 # RISC-V GCC installation
132 if "gcc" in sys
.argv
[1:]:
133 sifive_riscv_download()
134 if "riscv64" not in os
.environ
.get("PATH", ""):
135 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
136 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")