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-misc-tapcfg', ("https://github.com/litex-hub/", False, True))
48 repos
= OrderedDict(repos
)
50 # RISC-V toolchain download ------------------------------------------------------------------------
52 def sifive_riscv_download():
53 base_url
= "https://static.dev.sifive.com/dev-tools/"
54 base_file
= "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
57 if (sys
.platform
.startswith("win") or sys
.platform
.startswith("cygwin")):
58 end_file
= "w64-mingw32.zip"
60 elif sys
.platform
.startswith("linux"):
61 end_file
= "linux-ubuntu14.tar.gz"
63 elif sys
.platform
.startswith("darwin"):
64 end_file
= "apple-darwin.tar.gz"
66 raise NotImplementedError(sys
.platform
)
67 fn
= base_file
+ end_file
69 if not os
.path
.exists(fn
):
71 print("Downloading", url
, "to", fn
)
72 urllib
.request
.urlretrieve(url
, fn
)
74 print("Using existing file", fn
)
76 print("Extracting", fn
)
77 shutil
.unpack_archive(fn
)
79 # Setup --------------------------------------------------------------------------------------------
81 if os
.environ
.get("TRAVIS", "") == "true":
82 # Ignore `ssl.SSLCertVerificationError` on CI.
84 ssl
._create
_default
_https
_context
= ssl
._create
_unverified
_context
87 print("Available commands:")
89 print("- install (add --user to install to user directory)")
94 # Repositories cloning
95 if "init" in sys
.argv
[1:]:
96 os
.chdir(os
.path
.join(current_path
))
97 for name
in repos
.keys():
98 url
, need_recursive
, need_develop
= repos
[name
]
99 # clone repo (recursive if needed)
100 print("[cloning " + name
+ "]...")
101 full_url
= url
+ name
102 opts
= "--recursive" if need_recursive
else ""
103 subprocess
.check_call(
104 "git clone " + full_url
+ " " + opts
,
107 # Repositories installation
108 if "install" in sys
.argv
[1:]:
109 for name
in repos
.keys():
110 url
, need_recursive
, need_develop
= repos
[name
]
112 print("[installing " + name
+ "]...")
114 os
.chdir(os
.path
.join(current_path
, name
))
115 if "--user" in sys
.argv
[1:]:
116 subprocess
.check_call(
117 "python3 setup.py develop --user",
120 subprocess
.check_call(
121 "python3 setup.py develop",
123 os
.chdir(os
.path
.join(current_path
))
125 if "--user" in sys
.argv
[1:]:
126 if ".local/bin" not in os
.environ
.get("PATH", ""):
127 print("Make sure that ~/.local/bin is in your PATH")
128 print("export PATH=$PATH:~/.local/bin")
130 # Repositories update
131 if "update" in sys
.argv
[1:]:
132 for name
in repos
.keys():
134 print("[updating " + name
+ "]...")
135 os
.chdir(os
.path
.join(current_path
, name
))
136 subprocess
.check_call(
139 os
.chdir(os
.path
.join(current_path
))
141 # RISC-V GCC installation
142 if "gcc" in sys
.argv
[1:]:
143 sifive_riscv_download()
144 if "riscv64" not in os
.environ
.get("PATH", ""):
145 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
146 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")