Merge pull request #452 from mithro/riscv-download
Add GCC downloading via litex_setup.py
This commit is contained in:
commit
447e8d948c
10
.travis.yml
10
.travis.yml
|
@ -5,7 +5,7 @@ python: "3.6"
|
|||
install:
|
||||
# Get Migen / LiteX / Cores
|
||||
- cd ~/
|
||||
- wget https://raw.githubusercontent.com/enjoy-digital/litex/master/litex_setup.py
|
||||
- cp $TRAVIS_BUILD_DIR/litex_setup.py .
|
||||
- python3 litex_setup.py init install
|
||||
# Install the LiteX version being tested.
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
|
@ -13,8 +13,10 @@ install:
|
|||
|
||||
before_script:
|
||||
# Get RISC-V toolchain
|
||||
- wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14.tar.gz
|
||||
- tar -xvf riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14.tar.gz
|
||||
- cd ~/
|
||||
- python3 litex_setup.py gcc
|
||||
- export PATH=$PATH:$PWD/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14/bin/
|
||||
|
||||
script: python setup.py test
|
||||
script:
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
- python setup.py test
|
||||
|
|
|
@ -3,18 +3,20 @@
|
|||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
from collections import OrderedDict
|
||||
|
||||
import urllib.request
|
||||
|
||||
current_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
# name, (url, recursive clone, develop)
|
||||
repos = [
|
||||
# HDL
|
||||
("migen", ("https://github.com/m-labs/", True, True)),
|
||||
("migen", ("https://github.com/m-labs/", True, True)),
|
||||
|
||||
# LiteX SoC builder
|
||||
("litex", ("https://github.com/enjoy-digital/", True, True)),
|
||||
("litex", ("https://github.com/enjoy-digital/", True, True)),
|
||||
|
||||
# LiteX cores ecosystem
|
||||
("liteeth", ("https://github.com/enjoy-digital/", False, True)),
|
||||
|
@ -29,18 +31,52 @@ repos = [
|
|||
("litespi", ("https://github.com/litex-hub/", False, True)),
|
||||
|
||||
# LiteX boards support
|
||||
("litex-boards", ("https://github.com/litex-hub/", False, True)),
|
||||
("litex-boards", ("https://github.com/litex-hub/", False, True)),
|
||||
]
|
||||
repos = OrderedDict(repos)
|
||||
|
||||
|
||||
def sifive_riscv_download():
|
||||
base_url = "https://static.dev.sifive.com/dev-tools/"
|
||||
base_file = "riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-"
|
||||
|
||||
is_windows = (
|
||||
sys.platform.startswith('win') or sys.platform.startswith('cygwin'))
|
||||
if is_windows:
|
||||
end_file = 'w64-mingw32.zip'
|
||||
elif sys.platform.startswith('linux'):
|
||||
end_file = 'linux-ubuntu14.tar.gz'
|
||||
elif sys.platform.startswith('darwin'):
|
||||
end_file = 'apple-darwin.tar.gz'
|
||||
else:
|
||||
raise NotImplementedError(sys.platform)
|
||||
fn = base_file + end_file
|
||||
|
||||
if not os.path.exists(fn):
|
||||
url = base_url+fn
|
||||
print("Downloading", url, "to", fn)
|
||||
urllib.request.urlretrieve(url, fn)
|
||||
else:
|
||||
print("Using existing file", fn)
|
||||
|
||||
print("Extracting", fn)
|
||||
shutil.unpack_archive(fn)
|
||||
|
||||
if os.environ.get('TRAVIS', '') == 'true':
|
||||
# Ignore `ssl.SSLCertVerificationError` on CI.
|
||||
import ssl
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Available commands:")
|
||||
print("- init")
|
||||
print("- install (add --user to install to user directory)")
|
||||
print("- update")
|
||||
print("- gcc")
|
||||
exit()
|
||||
|
||||
if "init" in sys.argv[1:]:
|
||||
os.chdir(os.path.join(current_path))
|
||||
for name in repos.keys():
|
||||
url, need_recursive, need_develop = repos[name]
|
||||
# clone repo (recursive if needed)
|
||||
|
@ -66,6 +102,10 @@ if "install" in sys.argv[1:]:
|
|||
subprocess.check_call(
|
||||
"python3 setup.py develop",
|
||||
shell=True)
|
||||
os.chdir(os.path.join(current_path))
|
||||
|
||||
if "gcc" in sys.argv[1:]:
|
||||
sifive_riscv_download()
|
||||
|
||||
if "update" in sys.argv[1:]:
|
||||
for name in repos.keys():
|
||||
|
@ -75,3 +115,12 @@ if "update" in sys.argv[1:]:
|
|||
subprocess.check_call(
|
||||
"git pull",
|
||||
shell=True)
|
||||
os.chdir(os.path.join(current_path))
|
||||
|
||||
if "--user" in sys.argv[1:]:
|
||||
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")
|
||||
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("export PATH=$PATH:$(echo $PWD/riscv64-*/bin/)")
|
||||
|
|
Loading…
Reference in New Issue