2018-07-20 04:11:41 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2022-01-05 08:52:21 -05:00
|
|
|
import time
|
2020-04-06 14:25:11 -04:00
|
|
|
import subprocess
|
2020-04-06 20:45:55 -04:00
|
|
|
import shutil
|
2020-05-20 03:04:13 -04:00
|
|
|
import hashlib
|
2021-10-26 08:37:08 -04:00
|
|
|
import argparse
|
2018-07-20 04:11:41 -04:00
|
|
|
|
2020-04-06 19:39:49 -04:00
|
|
|
import urllib.request
|
2018-07-20 04:11:41 -04:00
|
|
|
|
2022-01-05 08:52:21 -05:00
|
|
|
start_time = time.time()
|
2020-02-23 17:58:45 -05:00
|
|
|
current_path = os.path.abspath(os.curdir)
|
2022-01-26 08:49:02 -05:00
|
|
|
python3 = sys.executable
|
2020-02-23 17:58:45 -05:00
|
|
|
|
2022-01-05 08:52:21 -05:00
|
|
|
# Helpers ------------------------------------------------------------------------------------------
|
|
|
|
|
2022-11-03 04:49:51 -04:00
|
|
|
def colorer(s, color="bright"):
|
2022-01-05 08:52:21 -05:00
|
|
|
header = {
|
|
|
|
"bright" : "\x1b[1m",
|
|
|
|
"green" : "\x1b[1m\x1b[32m",
|
|
|
|
"cyan" : "\x1b[1m\x1b[36m",
|
|
|
|
"red" : "\x1b[1m\x1b[31m",
|
|
|
|
"yellow" : "\x1b[1m\x1b[33m",
|
|
|
|
"underline" : "\x1b[1m\x1b[4m"}[color]
|
|
|
|
trailer = "\x1b[0m"
|
|
|
|
return header + str(s) + trailer
|
|
|
|
|
|
|
|
def print_banner():
|
|
|
|
b = []
|
|
|
|
b.append(" __ _ __ _ __ ")
|
|
|
|
b.append(" / / (_) /____ | |/_/ ")
|
|
|
|
b.append(" / /__/ / __/ -_)> < ")
|
|
|
|
b.append(" /____/_/\\__/\\__/_/|_| ")
|
|
|
|
b.append(" Build your hardware, easily! ")
|
|
|
|
b.append(" LiteX Setup utility. ")
|
|
|
|
b.append("")
|
|
|
|
print("\n".join(b))
|
|
|
|
|
2022-01-26 08:20:41 -05:00
|
|
|
def print_status(status, underline=False):
|
2022-01-05 08:52:21 -05:00
|
|
|
exec_time = (time.time() - start_time)
|
|
|
|
print(colorer(f"[{exec_time:8.3f}]", color="green") + " " + colorer(status))
|
2022-01-26 08:20:41 -05:00
|
|
|
if underline:
|
|
|
|
print(colorer(f"[{exec_time:8.3f}]", color="green") + " " + colorer("-"*len(status)))
|
2022-01-05 08:52:21 -05:00
|
|
|
|
|
|
|
def print_error(status):
|
|
|
|
exec_time = (time.time() - start_time)
|
|
|
|
print(colorer(f"[{exec_time:8.3f}]", color="red") + " " + colorer(status))
|
|
|
|
|
|
|
|
class SetupError(Exception):
|
|
|
|
def __init__(self):
|
|
|
|
sys.stderr = None # Error already described, avoid traceback/exception.
|
|
|
|
|
|
|
|
# Git repositories ---------------------------------------------------------------------------------
|
2020-04-07 05:05:14 -04:00
|
|
|
|
2021-10-19 09:47:24 -04:00
|
|
|
# Get SHA1: git rev-parse --short=7 HEAD
|
2021-10-07 13:03:29 -04:00
|
|
|
|
2021-10-26 04:49:34 -04:00
|
|
|
class GitRepo:
|
2022-05-04 11:50:14 -04:00
|
|
|
def __init__(self, url, clone="regular", develop=True, sha1=None, branch="master", tag=None):
|
2021-10-26 04:49:34 -04:00
|
|
|
assert clone in ["regular", "recursive"]
|
|
|
|
self.url = url
|
|
|
|
self.clone = clone
|
|
|
|
self.develop = develop
|
|
|
|
self.sha1 = sha1
|
2021-12-10 12:07:03 -05:00
|
|
|
self.branch = branch
|
2022-05-04 11:50:14 -04:00
|
|
|
self.tag = tag
|
|
|
|
|
2021-10-26 04:49:34 -04:00
|
|
|
|
|
|
|
git_repos = {
|
|
|
|
# HDL.
|
2022-05-25 03:29:23 -04:00
|
|
|
# ----
|
2023-09-08 04:41:30 -04:00
|
|
|
"migen": GitRepo(url="https://github.com/m-labs/", clone="recursive", sha1=0xccaee68e14d3636e1d8fb2e0864dd89b1b1f7384),
|
2021-10-26 04:49:34 -04:00
|
|
|
|
2022-05-25 03:29:23 -04:00
|
|
|
# LiteX SoC builder.
|
|
|
|
# ------------------
|
2021-10-26 05:58:09 -04:00
|
|
|
"pythondata-software-picolibc": GitRepo(url="https://github.com/litex-hub/", clone="recursive"),
|
|
|
|
"pythondata-software-compiler_rt": GitRepo(url="https://github.com/litex-hub/"),
|
2022-05-04 11:50:14 -04:00
|
|
|
"litex": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
2021-10-26 05:58:09 -04:00
|
|
|
|
2021-10-26 04:49:34 -04:00
|
|
|
# LiteX Cores Ecosystem.
|
2022-05-25 03:29:23 -04:00
|
|
|
# ----------------------
|
2023-08-16 03:39:03 -04:00
|
|
|
"liteiclink": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
2022-05-04 11:50:14 -04:00
|
|
|
"liteeth": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
|
|
|
"litedram": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
|
|
|
"litepcie": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
|
|
|
"litesata": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
|
|
|
"litesdcard": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
|
|
|
"litescope": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
|
|
|
"litejesd204b": GitRepo(url="https://github.com/enjoy-digital/", tag=True),
|
2022-06-20 04:53:17 -04:00
|
|
|
"litespi": GitRepo(url="https://github.com/litex-hub/", tag=True),
|
|
|
|
|
|
|
|
# LiteX Misc Cores.
|
|
|
|
# -----------------
|
|
|
|
"valentyusb": GitRepo(url="https://github.com/litex-hub/", branch="hw_cdc_eptri"),
|
2021-10-26 04:49:34 -04:00
|
|
|
|
|
|
|
# LiteX Boards.
|
2022-05-25 03:29:23 -04:00
|
|
|
# -------------
|
2022-05-04 11:50:14 -04:00
|
|
|
"litex-boards": GitRepo(url="https://github.com/litex-hub/", clone="regular", tag=True),
|
2021-10-26 04:49:34 -04:00
|
|
|
|
|
|
|
# LiteX pythondata.
|
2022-05-25 03:29:23 -04:00
|
|
|
# -----------------
|
|
|
|
# Generic.
|
2021-10-26 04:49:34 -04:00
|
|
|
"pythondata-misc-tapcfg": GitRepo(url="https://github.com/litex-hub/"),
|
2024-12-11 06:05:56 -05:00
|
|
|
"pythondata-misc-usb_ohci": GitRepo(url="https://github.com/litex-hub/", clone="recursive"),
|
2022-05-25 03:29:23 -04:00
|
|
|
|
|
|
|
# LM32 CPU(s).
|
2021-10-26 04:49:34 -04:00
|
|
|
"pythondata-cpu-lm32": GitRepo(url="https://github.com/litex-hub/"),
|
2022-05-25 03:29:23 -04:00
|
|
|
|
|
|
|
# OpenRISC CPU(s).
|
2021-10-26 04:49:34 -04:00
|
|
|
"pythondata-cpu-mor1kx": GitRepo(url="https://github.com/litex-hub/"),
|
2022-05-25 03:29:23 -04:00
|
|
|
"pythondata-cpu-marocchino": GitRepo(url="https://github.com/litex-hub/"),
|
|
|
|
|
|
|
|
# OpenPower CPU(s).
|
2022-11-20 23:08:53 -05:00
|
|
|
"pythondata-cpu-microwatt": GitRepo(url="https://github.com/litex-hub/", sha1=0xc69953aff92),
|
2022-05-25 03:29:23 -04:00
|
|
|
|
|
|
|
# RISC-V CPU(s).
|
2021-10-26 04:49:34 -04:00
|
|
|
"pythondata-cpu-blackparrot": GitRepo(url="https://github.com/litex-hub/"),
|
|
|
|
"pythondata-cpu-cv32e40p": GitRepo(url="https://github.com/litex-hub/", clone="recursive"),
|
2022-02-14 16:06:25 -05:00
|
|
|
"pythondata-cpu-cv32e41p": GitRepo(url="https://github.com/litex-hub/", clone="recursive"),
|
2022-05-17 17:10:55 -04:00
|
|
|
"pythondata-cpu-cva5": GitRepo(url="https://github.com/litex-hub/"),
|
2022-05-25 03:29:23 -04:00
|
|
|
"pythondata-cpu-cva6": GitRepo(url="https://github.com/litex-hub/", clone="recursive"),
|
2021-11-16 12:16:05 -05:00
|
|
|
"pythondata-cpu-ibex": GitRepo(url="https://github.com/litex-hub/", clone="recursive", sha1=0xd3d53df),
|
2022-05-25 03:29:23 -04:00
|
|
|
"pythondata-cpu-minerva": GitRepo(url="https://github.com/litex-hub/"),
|
2023-09-14 05:25:02 -04:00
|
|
|
"pythondata-cpu-naxriscv": GitRepo(url="https://github.com/litex-hub/", branch="smp"),
|
2022-05-25 03:29:23 -04:00
|
|
|
"pythondata-cpu-picorv32": GitRepo(url="https://github.com/litex-hub/"),
|
|
|
|
"pythondata-cpu-rocket": GitRepo(url="https://github.com/litex-hub/"),
|
|
|
|
"pythondata-cpu-serv": GitRepo(url="https://github.com/litex-hub/"),
|
2024-03-20 03:09:30 -04:00
|
|
|
"pythondata-cpu-vexiiriscv": GitRepo(url="https://github.com/litex-hub/", branch="main"),
|
2022-05-25 03:29:23 -04:00
|
|
|
"pythondata-cpu-vexriscv": GitRepo(url="https://github.com/litex-hub/"),
|
|
|
|
"pythondata-cpu-vexriscv-smp": GitRepo(url="https://github.com/litex-hub/", clone="recursive"),
|
2021-10-26 04:49:34 -04:00
|
|
|
}
|
2018-07-20 04:11:41 -04:00
|
|
|
|
2022-01-05 07:55:38 -05:00
|
|
|
# Installs -----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Minimal: Only Migen + LiteX.
|
2022-01-05 08:52:21 -05:00
|
|
|
minimal_repos = ["migen", "litex"]
|
2022-01-05 07:55:38 -05:00
|
|
|
|
|
|
|
# Standard: Migen + LiteX + Cores + Software + Popular CPUs (LM32, Mor1kx, SERV, VexRiscv).
|
|
|
|
standard_repos = list(git_repos.keys())
|
|
|
|
standard_repos.remove("pythondata-cpu-blackparrot")
|
|
|
|
standard_repos.remove("pythondata-cpu-cv32e40p")
|
2022-02-15 03:45:23 -05:00
|
|
|
standard_repos.remove("pythondata-cpu-cv32e41p")
|
2022-05-25 09:20:56 -04:00
|
|
|
standard_repos.remove("pythondata-cpu-cva5")
|
2022-05-25 03:29:23 -04:00
|
|
|
standard_repos.remove("pythondata-cpu-cva6")
|
2022-01-05 07:55:38 -05:00
|
|
|
standard_repos.remove("pythondata-cpu-ibex")
|
2022-01-17 03:02:34 -05:00
|
|
|
standard_repos.remove("pythondata-cpu-marocchino")
|
2022-05-25 03:29:23 -04:00
|
|
|
standard_repos.remove("pythondata-cpu-minerva")
|
|
|
|
standard_repos.remove("pythondata-cpu-microwatt")
|
|
|
|
standard_repos.remove("pythondata-cpu-picorv32")
|
|
|
|
standard_repos.remove("pythondata-cpu-rocket")
|
2022-01-05 07:55:38 -05:00
|
|
|
|
|
|
|
# Full: Migen + LiteX + Cores + Software + All CPUs.
|
|
|
|
full_repos = list(git_repos.keys())
|
|
|
|
|
|
|
|
# Installs:
|
|
|
|
install_configs = {
|
|
|
|
"minimal" : minimal_repos,
|
|
|
|
"standard" : standard_repos,
|
|
|
|
"full" : full_repos,
|
|
|
|
}
|
|
|
|
|
2022-01-05 08:52:21 -05:00
|
|
|
# Script location / auto-update --------------------------------------------------------------------
|
2021-10-26 05:36:38 -04:00
|
|
|
|
|
|
|
def litex_setup_location_check():
|
|
|
|
# Check if script is executed inside a cloned LiteX repository or alongside?
|
|
|
|
if os.path.exists(".gitignore"):
|
|
|
|
global current_path
|
|
|
|
current_path = os.path.join(current_path, "../")
|
|
|
|
|
|
|
|
def litex_setup_auto_update():
|
|
|
|
litex_setup_url = "https://raw.githubusercontent.com/enjoy-digital/litex/master/litex_setup.py"
|
|
|
|
current_sha1 = hashlib.sha1(open(os.path.realpath(__file__)).read().encode("utf-8")).hexdigest()
|
2022-01-05 08:52:21 -05:00
|
|
|
print_status("LiteX Setup auto-update...")
|
2021-10-26 05:36:38 -04:00
|
|
|
try:
|
|
|
|
import requests
|
|
|
|
r = requests.get(litex_setup_url)
|
|
|
|
if r.status_code != 404:
|
|
|
|
upstream_sha1 = hashlib.sha1(r.content).hexdigest()
|
|
|
|
if current_sha1 != upstream_sha1:
|
2022-01-05 08:52:21 -05:00
|
|
|
print_status("LiteX Setup is obsolete, updating.")
|
2021-10-26 05:36:38 -04:00
|
|
|
with open(os.path.realpath(__file__), "wb") as f:
|
|
|
|
f.write(r.content)
|
2022-01-26 08:49:02 -05:00
|
|
|
os.execl(python3, python3, *sys.argv)
|
2022-01-05 08:52:21 -05:00
|
|
|
else:
|
|
|
|
print_status("LiteX Setup is up to date.")
|
2021-10-26 05:36:38 -04:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2022-05-04 11:50:14 -04:00
|
|
|
# Git helpers --------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def git_checkout(sha1=None, tag=None):
|
|
|
|
assert not ((sha1 is None) and (tag is None))
|
|
|
|
if sha1 is not None:
|
|
|
|
os.system(f"git checkout {sha1:07x}")
|
|
|
|
if tag is not None:
|
|
|
|
sha1_tag_cmd = ["git", "rev-list", "-n 1", tag]
|
|
|
|
sha1_tag = subprocess.check_output(sha1_tag_cmd).decode("UTF-8")[:-1]
|
|
|
|
os.system(f"git checkout {sha1_tag}")
|
|
|
|
|
2023-01-02 03:01:21 -05:00
|
|
|
def git_tag(tag=None):
|
|
|
|
assert tag is not None
|
|
|
|
os.system(f"git tag {tag}")
|
|
|
|
os.system(f"git push --tags")
|
|
|
|
|
2022-01-05 08:52:21 -05:00
|
|
|
# Git repositories initialization ------------------------------------------------------------------
|
2021-10-26 05:36:38 -04:00
|
|
|
|
2022-05-04 11:50:14 -04:00
|
|
|
def litex_setup_init_repos(config="standard", tag=None, dev_mode=False):
|
2022-01-26 08:20:41 -05:00
|
|
|
print_status("Initializing Git repositories...", underline=True)
|
2022-01-05 07:55:38 -05:00
|
|
|
for name in install_configs[config]:
|
|
|
|
repo = git_repos[name]
|
2021-10-26 05:36:38 -04:00
|
|
|
os.chdir(os.path.join(current_path))
|
|
|
|
if not os.path.exists(name):
|
|
|
|
# Clone Repo.
|
2022-01-05 08:52:21 -05:00
|
|
|
print_status(f"Cloning {name} Git repository...")
|
2022-01-05 04:07:35 -05:00
|
|
|
repo_url = repo.url
|
|
|
|
if dev_mode:
|
|
|
|
repo_url = repo_url.replace("https://github.com/", "git@github.com:")
|
2021-10-26 05:36:38 -04:00
|
|
|
subprocess.check_call("git clone {url} {options}".format(
|
2022-01-05 04:07:35 -05:00
|
|
|
url = repo_url + name + ".git",
|
2021-10-26 05:36:38 -04:00
|
|
|
options = "--recursive" if repo.clone == "recursive" else ""
|
|
|
|
), shell=True)
|
2022-05-04 11:50:14 -04:00
|
|
|
os.chdir(os.path.join(current_path, name))
|
2022-06-20 04:43:30 -04:00
|
|
|
# Use specific Branch.
|
|
|
|
subprocess.check_call("git checkout " + repo.branch, shell=True)
|
2022-05-04 11:50:14 -04:00
|
|
|
# Use specific Tag (Optional).
|
|
|
|
if repo.tag is not None:
|
|
|
|
# Priority to passed tag (if specified).
|
|
|
|
if tag is not None:
|
|
|
|
git_checkout(tag=tag)
|
|
|
|
continue
|
|
|
|
# Else fallback to repo tag (if specified).
|
|
|
|
if isinstance(repo.tag, str):
|
|
|
|
git_checkout(tag=tag)
|
|
|
|
continue
|
2021-10-26 05:36:38 -04:00
|
|
|
# Use specific SHA1 (Optional).
|
|
|
|
if repo.sha1 is not None:
|
2022-05-04 11:50:14 -04:00
|
|
|
git_checkout(sha1=repo.sha1)
|
2022-01-05 08:52:21 -05:00
|
|
|
else:
|
|
|
|
print_status(f"{name} Git Repo already present.")
|
2020-04-06 19:39:49 -04:00
|
|
|
|
2022-01-05 08:52:21 -05:00
|
|
|
# Git repositories update --------------------------------------------------------------------------
|
2021-10-26 05:36:38 -04:00
|
|
|
|
2022-05-04 11:50:14 -04:00
|
|
|
def litex_setup_update_repos(config="standard", tag=None):
|
2022-01-26 08:20:41 -05:00
|
|
|
print_status("Updating Git repositories...", underline=True)
|
2022-01-05 07:55:38 -05:00
|
|
|
for name in install_configs[config]:
|
|
|
|
repo = git_repos[name]
|
2021-10-26 05:36:38 -04:00
|
|
|
os.chdir(os.path.join(current_path))
|
|
|
|
# Check if Repo is present.
|
|
|
|
if not os.path.exists(name):
|
2022-01-05 08:52:21 -05:00
|
|
|
print_error(f"{name} Git repository is not initialized, please run --init first.")
|
|
|
|
raise SetupError
|
2021-10-26 05:36:38 -04:00
|
|
|
# Update Repo.
|
2022-01-05 08:52:21 -05:00
|
|
|
print_status(f"Updating {name} Git repository...")
|
2021-10-26 05:36:38 -04:00
|
|
|
os.chdir(os.path.join(current_path, name))
|
2021-12-10 12:07:03 -05:00
|
|
|
subprocess.check_call("git checkout " + repo.branch, shell=True)
|
2021-10-26 05:36:38 -04:00
|
|
|
subprocess.check_call("git pull --ff-only", shell=True)
|
|
|
|
# Recursive Update (Optional).
|
|
|
|
if repo.clone == "recursive":
|
|
|
|
subprocess.check_call("git submodule update --init --recursive", shell=True)
|
2022-05-04 11:50:14 -04:00
|
|
|
# Use specific Tag (Optional).
|
|
|
|
if repo.tag is not None:
|
|
|
|
# Priority to passed tag (if specified).
|
|
|
|
if tag is not None:
|
|
|
|
git_checkout(tag=tag)
|
|
|
|
continue
|
|
|
|
# Else fallback to repo tag (if specified).
|
|
|
|
if isinstance(repo.tag, str):
|
|
|
|
git_checkout(tag=tag)
|
|
|
|
continue
|
2021-10-26 05:36:38 -04:00
|
|
|
# Use specific SHA1 (Optional).
|
|
|
|
if repo.sha1 is not None:
|
2022-05-04 11:50:14 -04:00
|
|
|
git_checkout(sha1=repo.sha1)
|
2021-10-26 05:36:38 -04:00
|
|
|
|
2022-01-05 08:52:21 -05:00
|
|
|
# Git repositories install -------------------------------------------------------------------------
|
2021-10-26 05:36:38 -04:00
|
|
|
|
2022-01-05 07:55:38 -05:00
|
|
|
def litex_setup_install_repos(config="standard", user_mode=False):
|
2022-01-26 08:20:41 -05:00
|
|
|
print_status("Installing Git repositories...", underline=True)
|
2022-01-05 07:55:38 -05:00
|
|
|
for name in install_configs[config]:
|
|
|
|
repo = git_repos[name]
|
2021-10-26 05:36:38 -04:00
|
|
|
os.chdir(os.path.join(current_path))
|
|
|
|
# Install Repo.
|
|
|
|
if repo.develop:
|
2022-01-05 08:52:21 -05:00
|
|
|
print_status(f"Installing {name} Git repository...")
|
2021-10-26 05:36:38 -04:00
|
|
|
os.chdir(os.path.join(current_path, name))
|
2022-05-19 14:50:50 -04:00
|
|
|
subprocess.check_call("\"{python3}\" -m pip install --editable . {options}".format(
|
2022-01-26 08:49:02 -05:00
|
|
|
python3 = sys.executable,
|
|
|
|
options = "--user" if user_mode else "",
|
2021-10-26 05:36:38 -04:00
|
|
|
), shell=True)
|
|
|
|
if user_mode:
|
|
|
|
if ".local/bin" not in os.environ.get("PATH", ""):
|
2022-01-05 08:52:21 -05:00
|
|
|
print_status("Make sure that ~/.local/bin is in your PATH")
|
2023-02-08 12:53:50 -05:00
|
|
|
print_status("export PATH=$PATH:~/.local/bin # temporary (limited to the current terminal)")
|
|
|
|
print_status("or add the previous line into your ~/.bashrc to permanently update PATH")
|
2021-10-19 08:41:42 -04:00
|
|
|
|
2022-03-08 12:12:11 -05:00
|
|
|
# Git repositories freeze --------------------------------------------------------------------------
|
2022-01-26 08:44:04 -05:00
|
|
|
|
2022-03-08 12:12:11 -05:00
|
|
|
def litex_setup_freeze_repos(config="standard"):
|
|
|
|
print_status("Freezing config of Git repositories...", underline=True)
|
|
|
|
r = "git_repos = {\n"
|
2022-01-26 08:44:04 -05:00
|
|
|
for name in install_configs[config]:
|
|
|
|
repo = git_repos[name]
|
|
|
|
os.chdir(os.path.join(current_path, name))
|
|
|
|
git_sha1_cmd = ["git", "rev-parse", "--short=7", "HEAD"]
|
2022-03-08 12:12:11 -05:00
|
|
|
git_sha1 = subprocess.check_output(git_sha1_cmd).decode("UTF-8")[:-1]
|
|
|
|
git_url_cmd = ["git", "remote", "get-url", "origin"]
|
|
|
|
git_url = subprocess.check_output(git_url_cmd).decode("UTF-8")[:-1]
|
|
|
|
git_url = git_url.replace(f"{name}.git", "")
|
|
|
|
r += " "*4
|
|
|
|
r += f'"{name}" : GitRepo(url="{git_url}",\n'
|
|
|
|
r += f'{" "*8}clone = "{repo.clone}",\n'
|
|
|
|
r += f'{" "*8}develop = {repo.develop},\n'
|
|
|
|
r += f'{" "*8}sha1 = 0x{git_sha1},\n'
|
|
|
|
r += f'{" "*8}branch = "{repo.branch}"'
|
|
|
|
r += f'\n{" "*4}),\n'
|
|
|
|
r += "}\n"
|
|
|
|
print(r)
|
2022-01-26 08:44:04 -05:00
|
|
|
|
2023-01-02 03:01:21 -05:00
|
|
|
# Git repositories release -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def litex_setup_release_repos(tag):
|
|
|
|
print_status(f"Making release {tag}...", underline=True)
|
|
|
|
confirm = input("Please confirm by pressing Y:")
|
|
|
|
if confirm.upper() == "Y":
|
|
|
|
for name in install_configs["full"]:
|
|
|
|
if name in ["migen"]:
|
|
|
|
continue
|
|
|
|
repo = git_repos[name]
|
|
|
|
os.chdir(os.path.join(current_path, name))
|
|
|
|
# Tag Repo.
|
|
|
|
print_status(f"Tagging {name} Git repository as {tag}...")
|
|
|
|
git_tag(tag=tag)
|
|
|
|
else:
|
|
|
|
print_status(f"Not confirmed, exiting.")
|
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
# GCC toolchains install ---------------------------------------------------------------------------
|
2021-10-26 06:35:55 -04:00
|
|
|
|
2021-10-26 05:36:38 -04:00
|
|
|
# RISC-V toolchain.
|
|
|
|
# -----------------
|
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
def riscv_gcc_install():
|
|
|
|
# Linux.
|
|
|
|
# ------
|
|
|
|
if sys.platform.startswith("linux"):
|
2021-11-26 08:20:55 -05:00
|
|
|
os_release = (open("/etc/os-release").read()).lower()
|
2022-11-21 03:15:27 -05:00
|
|
|
# Fedora.
|
2021-11-26 08:20:55 -05:00
|
|
|
if "fedora" in os_release:
|
2022-11-21 03:15:27 -05:00
|
|
|
os.system("dnf install gcc-riscv64-linux-gnu")
|
2023-01-10 16:41:35 -05:00
|
|
|
# Arch.
|
|
|
|
elif "arch" in os_release:
|
|
|
|
os.system("pacman -S riscv64-linux-gnu-gcc")
|
2024-10-08 14:46:38 -04:00
|
|
|
# Alpine.
|
|
|
|
elif "alpine" in os_release:
|
|
|
|
os.system("apk add gcc-cross-embedded")
|
2022-11-21 03:15:27 -05:00
|
|
|
# Ubuntu.
|
2021-11-26 08:20:55 -05:00
|
|
|
else:
|
2023-07-30 09:37:51 -04:00
|
|
|
os.system("apt install gcc-riscv64-unknown-elf")
|
2021-11-26 08:20:55 -05:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
# Mac OS.
|
|
|
|
# -------
|
2020-04-07 05:05:14 -04:00
|
|
|
elif sys.platform.startswith("darwin"):
|
2022-11-21 03:15:27 -05:00
|
|
|
os.system("brew install riscv-tools")
|
2020-04-06 19:39:49 -04:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
# Manual installation.
|
|
|
|
# --------------------
|
|
|
|
else:
|
|
|
|
NotImplementedError(f"RISC-V GCC requires manual installation on {sys.platform}.")
|
2021-10-19 08:41:42 -04:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
# PowerPC toolchain.
|
|
|
|
# -----------------
|
2021-10-19 08:41:42 -04:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
def powerpc_gcc_install():
|
|
|
|
# Linux.
|
|
|
|
# ------
|
|
|
|
if sys.platform.startswith("linux"):
|
|
|
|
os_release = (open("/etc/os-release").read()).lower()
|
|
|
|
# Fedora.
|
|
|
|
if "fedora" in os_release:
|
|
|
|
os.system("dnf install gcc-powerpc64le-linux-gnu") # FIXME: binutils-multiarch?
|
2023-01-11 18:48:17 -05:00
|
|
|
# Arch (AUR repository).
|
|
|
|
elif "arch" in os_release:
|
|
|
|
os.system("yay -S powerpc64le-linux-gnu-gcc")
|
2024-10-08 14:46:38 -04:00
|
|
|
# Alpine.
|
|
|
|
elif "alpine" in os_release:
|
|
|
|
os.system("apk add gcc binutils-ppc64le")
|
2022-11-21 03:15:27 -05:00
|
|
|
# Ubuntu.
|
|
|
|
else:
|
|
|
|
os.system("apt install gcc-powerpc64le-linux-gnu binutils-multiarch")
|
2021-10-19 08:41:42 -04:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
# Manual installation.
|
|
|
|
# --------------------
|
|
|
|
else:
|
|
|
|
NotImplementedError(f"PowerPC GCC requires manual installation on {sys.platform}.")
|
2021-10-19 08:41:42 -04:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
# OpenRISC toolchain.
|
|
|
|
# -------------------
|
2021-10-19 08:41:42 -04:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
def openrisc_gcc_install():
|
|
|
|
# Linux.
|
|
|
|
# ------
|
|
|
|
if sys.platform.startswith("linux"):
|
|
|
|
os_release = (open("/etc/os-release").read()).lower()
|
|
|
|
# Fedora.
|
|
|
|
if "fedora" in os_release:
|
|
|
|
os.system("dnf install gcc-or1k-elf")
|
2023-01-10 16:41:35 -05:00
|
|
|
# Arch.
|
|
|
|
elif "arch" in os_release:
|
|
|
|
os.system("pacman -S or1k-elf-gcc")
|
2024-10-08 14:46:38 -04:00
|
|
|
# Alpine.
|
|
|
|
elif "alpine" in os_release:
|
|
|
|
os.system("apk add gcc-cross-embedded")
|
2022-11-21 03:15:27 -05:00
|
|
|
# Ubuntu.
|
|
|
|
else:
|
|
|
|
os.system("apt install gcc-or1k-elf")
|
2021-10-19 08:41:42 -04:00
|
|
|
|
2022-11-21 03:15:27 -05:00
|
|
|
# Manual installation.
|
|
|
|
# --------------------
|
|
|
|
else:
|
|
|
|
NotImplementedError(f"OpenRISC GCC requires manual installation on {sys.platform}.")
|
2021-10-26 05:36:38 -04:00
|
|
|
|
|
|
|
# Run ----------------------------------------------------------------------------------------------
|
2020-04-07 05:05:14 -04:00
|
|
|
|
2021-10-26 08:37:08 -04:00
|
|
|
def main():
|
2022-01-05 08:52:21 -05:00
|
|
|
print_banner()
|
|
|
|
parser = argparse.ArgumentParser()
|
2021-10-26 09:04:50 -04:00
|
|
|
|
|
|
|
# Git Repositories.
|
2022-01-05 08:52:21 -05:00
|
|
|
parser.add_argument("--init", action="store_true", help="Initialize Git repositories.")
|
|
|
|
parser.add_argument("--update", action="store_true", help="Update Git repositories.")
|
|
|
|
parser.add_argument("--install", action="store_true", help="Install Git repositories.")
|
2021-10-26 08:37:08 -04:00
|
|
|
parser.add_argument("--user", action="store_true", help="Install in User-Mode.")
|
2022-01-05 07:55:38 -05:00
|
|
|
parser.add_argument("--config", default="standard", help="Install config (minimal, standard, full).")
|
2022-05-04 11:50:14 -04:00
|
|
|
parser.add_argument("--tag", default=None, help="Use version from release tag.")
|
2021-10-26 09:04:50 -04:00
|
|
|
|
|
|
|
# GCC toolchains.
|
2022-11-21 03:15:27 -05:00
|
|
|
parser.add_argument("--gcc", default=None, help="Install GCC Toolchain (riscv, powerpc or openrisc).")
|
2021-10-26 09:04:50 -04:00
|
|
|
|
|
|
|
# Development mode.
|
2023-01-02 03:01:21 -05:00
|
|
|
parser.add_argument("--dev", action="store_true", help="Development-Mode (no Auto-Update of litex_setup.py / Switch to git@github.com URLs).")
|
|
|
|
parser.add_argument("--freeze", action="store_true", help="Freeze and display current config.")
|
|
|
|
parser.add_argument("--release", default=None, help="Make release.")
|
2021-10-26 09:04:50 -04:00
|
|
|
|
|
|
|
# Retro-compatibility.
|
2021-10-26 09:16:43 -04:00
|
|
|
parser.add_argument("compat_args", nargs="*", help="Retro-Compatibility arguments (init, update, install or gcc).")
|
2021-10-26 08:37:08 -04:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Handle compat_args.
|
2021-10-26 09:16:43 -04:00
|
|
|
if args.compat_args is not None:
|
|
|
|
for arg in args.compat_args:
|
|
|
|
if arg in ["init", "update", "install"]:
|
|
|
|
setattr(args, arg, True)
|
|
|
|
if arg in ["gcc"]:
|
|
|
|
args.gcc = "riscv"
|
2021-10-26 08:37:08 -04:00
|
|
|
|
|
|
|
# Location/Auto-Update.
|
|
|
|
litex_setup_location_check()
|
2021-10-26 09:16:43 -04:00
|
|
|
if not args.dev:
|
2021-10-26 08:37:08 -04:00
|
|
|
litex_setup_auto_update()
|
|
|
|
|
|
|
|
# Init.
|
|
|
|
if args.init:
|
2023-09-18 03:20:48 -04:00
|
|
|
ci_run = (os.environ.get("GITHUB_ACTIONS") == "true")
|
|
|
|
dev_mode = args.dev and (not ci_run)
|
|
|
|
litex_setup_init_repos(config=args.config, tag=args.tag, dev_mode=dev_mode)
|
2021-10-26 08:37:08 -04:00
|
|
|
|
|
|
|
# Update.
|
|
|
|
if args.update:
|
2022-05-04 11:50:14 -04:00
|
|
|
litex_setup_update_repos(config=args.config, tag=args.tag)
|
2021-10-26 08:37:08 -04:00
|
|
|
|
|
|
|
# Install.
|
|
|
|
if args.install:
|
2022-01-05 07:55:38 -05:00
|
|
|
litex_setup_install_repos(config=args.config, user_mode=args.user)
|
2021-10-26 08:37:08 -04:00
|
|
|
|
2022-03-08 12:12:11 -05:00
|
|
|
# Freeze.
|
|
|
|
if args.freeze:
|
|
|
|
litex_setup_freeze_repos(config=args.config)
|
2022-01-26 08:44:04 -05:00
|
|
|
|
2023-01-02 03:01:21 -05:00
|
|
|
# Release.
|
|
|
|
if args.release:
|
|
|
|
litex_setup_release_repos(tag=args.release)
|
|
|
|
|
2021-10-26 08:37:08 -04:00
|
|
|
# GCC.
|
2021-10-26 09:04:50 -04:00
|
|
|
os.chdir(os.path.join(current_path))
|
|
|
|
if args.gcc == "riscv":
|
2022-11-21 03:15:27 -05:00
|
|
|
riscv_gcc_install()
|
2021-10-26 09:04:50 -04:00
|
|
|
if args.gcc == "powerpc":
|
2022-11-21 03:15:27 -05:00
|
|
|
powerpc_gcc_install()
|
2021-10-26 09:04:50 -04:00
|
|
|
if args.gcc == "openrisc":
|
2022-11-21 03:15:27 -05:00
|
|
|
openrisc_gcc_install()
|
2021-10-26 08:37:08 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-01-10 16:42:49 -05:00
|
|
|
main()
|
2023-02-08 12:53:50 -05:00
|
|
|
|