From 95029de1637c5f8e03dc909a6689ac97f823a787 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Tue, 18 Feb 2020 12:04:26 +1100 Subject: [PATCH] Use mill by default Signed-off-by: Anton Blanchard --- .travis.yml | 2 +- Makefile | 4 ++-- README.md | 10 ---------- build.sc | 2 +- scripts/mill | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 52 insertions(+), 14 deletions(-) create mode 100755 scripts/mill diff --git a/.travis.yml b/.travis.yml index f681303..b78fa8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ services: docker before_install: docker pull verilator/verilator:latest script: - docker run --rm -t -v `pwd`:/build -w /build --entrypoint /bin/bash verilator/verilator:latest -c "apt update && apt install -y default-jre-headless gnupg python3-pexpect && apt update && echo 'deb https://dl.bintray.com/sbt/debian /' | tee -a /etc/apt/sources.list.d/sbt.list && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823 && apt update && apt install -y sbt && make && make check && ./scripts/test_micropython_long.py" + docker run --rm -t -v `pwd`:/build -w /build --entrypoint /bin/bash verilator/verilator:latest -c "apt update && apt install -y default-jre-headless python3-pexpect curl && make && make check && ./scripts/test_micropython_long.py" diff --git a/Makefile b/Makefile index d56c8a4..46b522b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ verilog_files = Core.v MemoryBlackBox.v verilator_binary = chiselwatt $(verilog_files): $(scala_files) - sbt 'runMain CoreObj' + scripts/mill chiselwatt.run $(verilator_binary): $(verilog_files) chiselwatt.cpp uart.c # Warnings disabled until we fix the Chisel issues @@ -24,7 +24,7 @@ clean: @rm -f LoadStoreInsns.hex MemoryBlackBoxInsns.hex scala_tests: $(verilator_binary) - sbt testOnly + scripts/mill chiselwatt.test tests = $(sort $(patsubst tests/%.out,%,$(wildcard tests/*.out))) diff --git a/README.md b/README.md index 3855992..755ca1c 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,6 @@ A tiny POWER Open ISA soft processor written in Chisel. ## Simulation using verilator -* Chisel uses `sbt` (the scala build tool), but unfortunately most of the -distros package an ancient version. On Fedora you can install an upstream -version using: - -```sh -$ sudo dnf remove sbt -$ sudo curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo -$ sudo dnf --enablerepo=bintray--sbt-rpm install sbt -``` - * Chiselwatt uses `verilator` for simulation. Either install this from your distro or build it. On Fedora you can install the distro version using: diff --git a/build.sc b/build.sc index f6460a5..8ddcff5 100644 --- a/build.sc +++ b/build.sc @@ -47,5 +47,5 @@ trait HasMacroParadise extends ScalaModule { object chiselwatt extends CrossSbtModule with HasChisel3 with HasChiselTests with HasXsource211 with HasMacroParadise { override def millSourcePath = super.millSourcePath def crossScalaVersion = "2.12.10" + def mainClass = Some("CoreObj") } - diff --git a/scripts/mill b/scripts/mill new file mode 100755 index 0000000..b2daad8 --- /dev/null +++ b/scripts/mill @@ -0,0 +1,48 @@ +#!/usr/bin/env sh + +# This is a wrapper script, that automatically download mill from GitHub release pages +# You can give the required mill version with MILL_VERSION env variable +# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION +DEFAULT_MILL_VERSION=0.6.0 + +set -e + +if [ -z "$MILL_VERSION" ] ; then + if [ -f ".mill-version" ] ; then + MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" + elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then + MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) + else + MILL_VERSION=$DEFAULT_MILL_VERSION + fi +fi + +if [ "x${XDG_CACHE_HOME}" != "x" ] ; then + MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download" +else + MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download" +fi +MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}" + +version_remainder="$MILL_VERSION" +MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" +MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" + +if [ ! -x "$MILL_EXEC_PATH" ] ; then + mkdir -p $MILL_DOWNLOAD_PATH + if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then + ASSEMBLY="-assembly" + fi + DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download + MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}" + curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" + chmod +x "$DOWNLOAD_FILE" + mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" + unset DOWNLOAD_FILE + unset MILL_DOWNLOAD_URL +fi + +unset MILL_DOWNLOAD_PATH +unset MILL_VERSION + +exec $MILL_EXEC_PATH "$@"