litex_setup: reorganize a bit, add separators/comments.

This commit is contained in:
Florent Kermarrec 2020-04-07 11:05:14 +02:00
parent 926f961bf3
commit 3f1159fa0b
1 changed files with 30 additions and 20 deletions

View File

@ -10,6 +10,8 @@ import urllib.request
current_path = os.path.dirname(os.path.realpath(__file__)) current_path = os.path.dirname(os.path.realpath(__file__))
# Repositories -------------------------------------------------------------------------------------
# name, (url, recursive clone, develop) # name, (url, recursive clone, develop)
repos = [ repos = [
# HDL # HDL
@ -35,19 +37,21 @@ repos = [
] ]
repos = OrderedDict(repos) repos = OrderedDict(repos)
# RISC-V toolchain download ------------------------------------------------------------------------
def sifive_riscv_download(): def sifive_riscv_download():
base_url = "https://static.dev.sifive.com/dev-tools/" base_url = "https://static.dev.sifive.com/dev-tools/"
base_file = "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-" base_file = "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
is_windows = ( # Windows
sys.platform.startswith('win') or sys.platform.startswith('cygwin')) if (sys.platform.startswith("win") or sys.platform.startswith("cygwin")):
if is_windows: end_file = "w64-mingw32.zip"
end_file = 'w64-mingw32.zip' # Linux
elif sys.platform.startswith('linux'): elif sys.platform.startswith("linux"):
end_file = 'linux-ubuntu14.tar.gz' end_file = "linux-ubuntu14.tar.gz"
elif sys.platform.startswith('darwin'): # Mac OS
end_file = 'apple-darwin.tar.gz' elif sys.platform.startswith("darwin"):
end_file = "apple-darwin.tar.gz"
else: else:
raise NotImplementedError(sys.platform) raise NotImplementedError(sys.platform)
fn = base_file + end_file fn = base_file + end_file
@ -62,7 +66,9 @@ def sifive_riscv_download():
print("Extracting", fn) print("Extracting", fn)
shutil.unpack_archive(fn) shutil.unpack_archive(fn)
if os.environ.get('TRAVIS', '') == 'true': # Setup --------------------------------------------------------------------------------------------
if os.environ.get("TRAVIS", "") == "true":
# Ignore `ssl.SSLCertVerificationError` on CI. # Ignore `ssl.SSLCertVerificationError` on CI.
import ssl import ssl
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
@ -75,6 +81,7 @@ if len(sys.argv) < 2:
print("- gcc") print("- gcc")
exit() exit()
# Repositories cloning
if "init" in sys.argv[1:]: if "init" in sys.argv[1:]:
os.chdir(os.path.join(current_path)) os.chdir(os.path.join(current_path))
for name in repos.keys(): for name in repos.keys():
@ -87,6 +94,7 @@ if "init" in sys.argv[1:]:
"git clone " + full_url + " " + opts, "git clone " + full_url + " " + opts,
shell=True) shell=True)
# Repositories installation
if "install" in sys.argv[1:]: if "install" in sys.argv[1:]:
for name in repos.keys(): for name in repos.keys():
url, need_recursive, need_develop = repos[name] url, need_recursive, need_develop = repos[name]
@ -104,9 +112,12 @@ if "install" in sys.argv[1:]:
shell=True) shell=True)
os.chdir(os.path.join(current_path)) os.chdir(os.path.join(current_path))
if "gcc" in sys.argv[1:]: if "--user" in sys.argv[1:]:
sifive_riscv_download() if ".local/bin" not in os.environ.get("PATH", ""):
print("Make sure that ~/.local/bin is in your PATH")
print("export PATH=$PATH:~/.local/bin")
# Repositories update
if "update" in sys.argv[1:]: if "update" in sys.argv[1:]:
for name in repos.keys(): for name in repos.keys():
# update # update
@ -117,10 +128,9 @@ if "update" in sys.argv[1:]:
shell=True) shell=True)
os.chdir(os.path.join(current_path)) os.chdir(os.path.join(current_path))
if "--user" in sys.argv[1:]: # RISC-V GCC installation
if ".local/bin" not in os.environ.get("PATH", ""): if "gcc" in sys.argv[1:]:
print("Make sure that ~/.local/bin is in your PATH") sifive_riscv_download()
print("export PATH=$PATH:~/.local/bin") if "riscv64" not in os.environ.get("PATH", ""):
if "gcc" in sys.argv[1:] and 'riscv64' not in os.environ.get("PATH", ""):
print("Make sure that the downloaded RISC-V compiler is in your $PATH.") print("Make sure that the downloaded RISC-V compiler is in your $PATH.")
print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)") print("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")