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-data-software-compiler_rt', ("https://github.com/litex-hub/", False, True)),
22 ("litex", ("https://github.com/enjoy-digital/", False, True)),
24 # LiteX cores ecosystem
25 ("liteeth", ("https://github.com/enjoy-digital/", False, True)),
26 ("litedram", ("https://github.com/enjoy-digital/", False, True)),
27 ("litepcie", ("https://github.com/enjoy-digital/", False, True)),
28 ("litesata", ("https://github.com/enjoy-digital/", False, True)),
29 ("litesdcard", ("https://github.com/enjoy-digital/", False, True)),
30 ("liteiclink", ("https://github.com/enjoy-digital/", False, True)),
31 ("litevideo", ("https://github.com/enjoy-digital/", False, True)),
32 ("litescope", ("https://github.com/enjoy-digital/", False, True)),
33 ("litejesd204b", ("https://github.com/enjoy-digital/", False, True)),
34 ("litespi", ("https://github.com/litex-hub/", False, True)),
36 # LiteX boards support
37 ("litex-boards", ("https://github.com/litex-hub/", False, True)),
40 ("litex-data-cpu-blackparrot", ("https://github.com/litex-hub/", False, True)),
41 ("litex-data-cpu-mor1kx", ("https://github.com/litex-hub/", False, True)),
42 ("litex-data-cpu-lm32", ("https://github.com/litex-hub/", False, True)),
43 ("litex-data-cpu-microwatt", ("https://github.com/litex-hub/", False, True)),
44 ("litex-data-cpu-picorv32", ("https://github.com/litex-hub/", False, True)),
45 ("litex-data-cpu-rocket", ("https://github.com/litex-hub/", False, True)),
46 ("litex-data-cpu-vexriscv", ("https://github.com/litex-hub/", False, True)),
47 ("litex-data-misc-tapcfg", ("https://github.com/litex-hub/", False, True)),
49 repos
= OrderedDict(repos
)
51 # RISC-V toolchain download ------------------------------------------------------------------------
53 def sifive_riscv_download():
54 base_url
= "https://static.dev.sifive.com/dev-tools/"
55 base_file
= "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
58 if (sys
.platform
.startswith("win") or sys
.platform
.startswith("cygwin")):
59 end_file
= "w64-mingw32.zip"
61 elif sys
.platform
.startswith("linux"):
62 end_file
= "linux-ubuntu14.tar.gz"
64 elif sys
.platform
.startswith("darwin"):
65 end_file
= "apple-darwin.tar.gz"
67 raise NotImplementedError(sys
.platform
)
68 fn
= base_file
+ end_file
70 if not os
.path
.exists(fn
):
72 print("Downloading", url
, "to", fn
)
73 urllib
.request
.urlretrieve(url
, fn
)
75 print("Using existing file", fn
)
77 print("Extracting", fn
)
78 shutil
.unpack_archive(fn
)
80 # Setup --------------------------------------------------------------------------------------------
82 if os
.environ
.get("TRAVIS", "") == "true":
83 # Ignore `ssl.SSLCertVerificationError` on CI.
85 ssl
._create
_default
_https
_context
= ssl
._create
_unverified
_context
88 print("Available commands:")
90 print("- install (add --user to install to user directory)")
95 # Repositories cloning
96 if "init" in sys
.argv
[1:]:
97 os
.chdir(os
.path
.join(current_path
))
98 for name
in repos
.keys():
99 url
, need_recursive
, need_develop
= repos
[name
]
100 # clone repo (recursive if needed)
101 print("[cloning " + name
+ "]...")
102 full_url
= url
+ name
103 opts
= "--recursive" if need_recursive
else ""
104 subprocess
.check_call(
105 "git clone " + full_url
+ " " + opts
,
108 # Repositories installation
109 if "install" in sys
.argv
[1:]:
110 for name
in repos
.keys():
111 url
, need_recursive
, need_develop
= repos
[name
]
113 print("[installing " + name
+ "]...")
115 os
.chdir(os
.path
.join(current_path
, name
))
116 if "--user" in sys
.argv
[1:]:
117 subprocess
.check_call(
118 "python3 setup.py develop --user",
121 subprocess
.check_call(
122 "python3 setup.py develop",
124 os
.chdir(os
.path
.join(current_path
))
126 if "--user" in sys
.argv
[1:]:
127 if ".local/bin" not in os
.environ
.get("PATH", ""):
128 print("Make sure that ~/.local/bin is in your PATH")
129 print("export PATH=$PATH:~/.local/bin")
131 # Repositories update
132 if "update" in sys
.argv
[1:]:
133 for name
in repos
.keys():
135 print("[updating " + name
+ "]...")
136 os
.chdir(os
.path
.join(current_path
, name
))
137 subprocess
.check_call(
140 os
.chdir(os
.path
.join(current_path
))
142 # RISC-V GCC installation
143 if "gcc" in sys
.argv
[1:]:
144 sifive_riscv_download()
145 if "riscv64" not in os
.environ
.get("PATH", ""):
146 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
147 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")