7 from collections
import OrderedDict
11 current_path
= os
.path
.dirname(os
.path
.realpath(__file__
))
13 # name, (url, recursive clone, develop)
16 ("migen", ("https://github.com/m-labs/", True, True)),
19 ("litex", ("https://github.com/enjoy-digital/", True, True)),
21 # LiteX cores ecosystem
22 ("liteeth", ("https://github.com/enjoy-digital/", False, True)),
23 ("litedram", ("https://github.com/enjoy-digital/", False, True)),
24 ("litepcie", ("https://github.com/enjoy-digital/", False, True)),
25 ("litesata", ("https://github.com/enjoy-digital/", False, True)),
26 ("litesdcard", ("https://github.com/enjoy-digital/", False, True)),
27 ("liteiclink", ("https://github.com/enjoy-digital/", False, True)),
28 ("litevideo", ("https://github.com/enjoy-digital/", False, True)),
29 ("litescope", ("https://github.com/enjoy-digital/", False, True)),
30 ("litejesd204b", ("https://github.com/enjoy-digital/", False, True)),
31 ("litespi", ("https://github.com/litex-hub/", False, True)),
33 # LiteX boards support
34 ("litex-boards", ("https://github.com/litex-hub/", False, True)),
36 repos
= OrderedDict(repos
)
39 def sifive_riscv_download():
40 base_url
= "https://static.dev.sifive.com/dev-tools/"
41 base_file
= "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
44 sys
.platform
.startswith('win') or sys
.platform
.startswith('cygwin'))
46 end_file
= 'w64-mingw32.zip'
47 elif sys
.platform
.startswith('linux'):
48 end_file
= 'linux-ubuntu14.tar.gz'
49 elif sys
.platform
.startswith('darwin'):
50 end_file
= 'apple-darwin.tar.gz'
52 raise NotImplementedError(sys
.platform
)
53 fn
= base_file
+ end_file
55 if not os
.path
.exists(fn
):
57 print("Downloading", url
, "to", fn
)
58 urllib
.request
.urlretrieve(url
, fn
)
60 print("Using existing file", fn
)
62 print("Extracting", fn
)
63 shutil
.unpack_archive(fn
)
65 if os
.environ
.get('TRAVIS', '') == 'true':
66 # Ignore `ssl.SSLCertVerificationError` on CI.
68 ssl
._create
_default
_https
_context
= ssl
._create
_unverified
_context
71 print("Available commands:")
73 print("- install (add --user to install to user directory)")
78 if "init" in sys
.argv
[1:]:
79 os
.chdir(os
.path
.join(current_path
))
80 for name
in repos
.keys():
81 url
, need_recursive
, need_develop
= repos
[name
]
82 # clone repo (recursive if needed)
83 print("[cloning " + name
+ "]...")
85 opts
= "--recursive" if need_recursive
else ""
86 subprocess
.check_call(
87 "git clone " + full_url
+ " " + opts
,
90 if "install" in sys
.argv
[1:]:
91 for name
in repos
.keys():
92 url
, need_recursive
, need_develop
= repos
[name
]
94 print("[installing " + name
+ "]...")
96 os
.chdir(os
.path
.join(current_path
, name
))
97 if "--user" in sys
.argv
[1:]:
98 subprocess
.check_call(
99 "python3 setup.py develop --user",
102 subprocess
.check_call(
103 "python3 setup.py develop",
105 os
.chdir(os
.path
.join(current_path
))
107 if "gcc" in sys
.argv
[1:]:
108 sifive_riscv_download()
110 if "update" in sys
.argv
[1:]:
111 for name
in repos
.keys():
113 print("[updating " + name
+ "]...")
114 os
.chdir(os
.path
.join(current_path
, name
))
115 subprocess
.check_call(
118 os
.chdir(os
.path
.join(current_path
))
120 if "--user" in sys
.argv
[1:]:
121 if ".local/bin" not in os
.environ
.get("PATH", ""):
122 print("Make sure that ~/.local/bin is in your PATH")
123 print("export PATH=$PATH:~/.local/bin")
124 if "gcc" in sys
.argv
[1:] and 'riscv64' not in os
.environ
.get("PATH", ""):
125 print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
126 print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")