From b5d5f6f8931e9e98432836655e2bb4ede194dc97 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Thu, 22 Feb 2024 16:51:35 -0800 Subject: [PATCH] Add Scala 2.12 support (#20) --- .github/workflows/publish-firtool-resolver.yml | 2 +- .github/workflows/test.yml | 3 ++- build.sc | 9 +++++++-- firtool-resolver/test/fetched.sh | 2 +- firtool-resolver/test/firtool_cache.sh | 2 +- firtool-resolver/test/firtool_path.sh | 6 +++--- firtool-resolver/test/installed.sh | 2 +- firtool-resolver/test/negative.sh | 4 ++-- firtool-resolver/test/on_classpath.sh | 2 +- firtool-resolver/test/run_tests.sh | 5 +++-- 10 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish-firtool-resolver.yml b/.github/workflows/publish-firtool-resolver.yml index db82b8b..75ca6db 100644 --- a/.github/workflows/publish-firtool-resolver.yml +++ b/.github/workflows/publish-firtool-resolver.yml @@ -27,7 +27,7 @@ jobs: - name: Publish shell: bash run: | - ./mill -i firtool-resolver.publishSigned + ./mill -i firtool-resolver[_].publishSigned env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1c96e7..0a33a57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,7 @@ jobs: name: Run Tests strategy: matrix: + scala-version: ["2.13", "2.12"] runner: ["ubuntu-20.04", "macos-11", "windows-2019"] include: - runner: ubuntu-20.04 @@ -70,5 +71,5 @@ jobs: run: | # First run of mill is important to set itself up ./mill resolve _ - ./firtool-resolver/test/run_tests.sh ${{ matrix.os }} + ./firtool-resolver/test/run_tests.sh ${{ matrix.os }} ${{ matrix.scala-version }} diff --git a/build.sc b/build.sc index 3ca453d..927a7e5 100644 --- a/build.sc +++ b/build.sc @@ -232,8 +232,13 @@ object `llvm-firtool` extends JavaModule with ChipsAlliancePublishModule { // ******************** WARNING ******************** // This is extremely manual and changing dependencies IN ANY WAY (including bumping version) // requires carefully checking the packages to shade and dynamic ivy deps in the outer project -object `firtool-resolver` extends ScalaModule with ChipsAlliancePublishModule { root => - def scalaVersion = "2.13.11" +object `firtool-resolver` extends Cross[FirtoolResolver]("2.13", "2.12") +trait FirtoolResolver extends CrossScalaModule with ChipsAlliancePublishModule { root => + + override def crossScalaVersion = Map( + "2.13" -> "2.13.11", + "2.12" -> "2.12.18" + )(crossValue) def publishVersion = VcsVersion.vcsState().format(countSep = "+", untaggedSuffix = "-SNAPSHOT") diff --git a/firtool-resolver/test/fetched.sh b/firtool-resolver/test/fetched.sh index 1a3cf13..d7b9e1a 100755 --- a/firtool-resolver/test/fetched.sh +++ b/firtool-resolver/test/fetched.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash FIRTOOL=$( -cs launch --scala 2.13.11 \ +cs launch --scala $SCALA_VERSION \ org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION \ --main firtoolresolver.Main \ -- \ diff --git a/firtool-resolver/test/firtool_cache.sh b/firtool-resolver/test/firtool_cache.sh index a87190d..5d2739d 100755 --- a/firtool-resolver/test/firtool_cache.sh +++ b/firtool-resolver/test/firtool_cache.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash FIRTOOL=$( -cs launch --scala 2.13.11 \ +cs launch --scala $SCALA_VERSION \ org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION \ org.chipsalliance:llvm-firtool:$LLVM_FIRTOOL_VERSION \ --main firtoolresolver.Main \ diff --git a/firtool-resolver/test/firtool_path.sh b/firtool-resolver/test/firtool_path.sh index a271432..54d5bc1 100755 --- a/firtool-resolver/test/firtool_path.sh +++ b/firtool-resolver/test/firtool_path.sh @@ -2,7 +2,7 @@ # From a previous test FIRTOOL_BIN=$( -cs launch --scala 2.13.11 \ +cs launch --scala $SCALA_VERSION \ org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION \ org.chipsalliance:llvm-firtool:$LLVM_FIRTOOL_VERSION \ --main firtoolresolver.Main \ @@ -12,7 +12,7 @@ cs launch --scala 2.13.11 \ export CHISEL_FIRTOOL_PATH=$(dirname $FIRTOOL_BIN) FIRTOOL=$( -cs launch --scala 2.13.11 \ +cs launch --scala $SCALA_VERSION \ org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION \ --main firtoolresolver.Main \ -- \ @@ -30,7 +30,7 @@ $FIRTOOL --version # rather than just going ahead and fetching the dfeault version mv $FIRTOOL_BIN ${FIRTOOL_BIN}_renamed -cs launch --scala 2.13.11 \ +cs launch --scala $SCALA_VERSION \ org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION \ --main firtoolresolver.Main \ -- \ diff --git a/firtool-resolver/test/installed.sh b/firtool-resolver/test/installed.sh index f4d58c9..340ff08 100755 --- a/firtool-resolver/test/installed.sh +++ b/firtool-resolver/test/installed.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash FIRTOOL=$( -cs launch --scala 2.13.11 \ +cs launch --scala $SCALA_VERSION \ org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION \ --main firtoolresolver.Main \ -- \ diff --git a/firtool-resolver/test/negative.sh b/firtool-resolver/test/negative.sh index 9666bc6..4137d7f 100755 --- a/firtool-resolver/test/negative.sh +++ b/firtool-resolver/test/negative.sh @@ -3,5 +3,5 @@ # This test needs to be run before publishLocal # If this test fails when run locally, you may need to wipe your local ivy cache -cs launch --scala 2.13.11 org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION --main firtoolresolver.Main -# CHECK: Resolution error: Error downloading org.chipsalliance:firtool-resolver_2.13:{{.+}} +cs launch --scala $SCALA_VERSION org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION --main firtoolresolver.Main +# CHECK: Can't find a scala version suffix for org.chipsalliance::firtool-resolver:{{.+}} diff --git a/firtool-resolver/test/on_classpath.sh b/firtool-resolver/test/on_classpath.sh index cf73141..18c9568 100755 --- a/firtool-resolver/test/on_classpath.sh +++ b/firtool-resolver/test/on_classpath.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash FIRTOOL=$( -cs launch --scala 2.13.11 \ +cs launch --scala $SCALA_VERSION \ org.chipsalliance::firtool-resolver:$FIRTOOL_RESOLVER_VERSION \ org.chipsalliance:llvm-firtool:$LLVM_FIRTOOL_VERSION \ --main firtoolresolver.Main \ diff --git a/firtool-resolver/test/run_tests.sh b/firtool-resolver/test/run_tests.sh index e721cc5..91a942c 100755 --- a/firtool-resolver/test/run_tests.sh +++ b/firtool-resolver/test/run_tests.sh @@ -5,10 +5,11 @@ set -ex THIS_DIR=$(cd "$(dirname "$0")"; pwd -P) OS=$1 +export SCALA_VERSION=$2 export COURSIER_CACHE="$PWD/coursier_cache" rm -rf $COURSIER_CACHE -export FIRTOOL_RESOLVER_VERSION=$(./mill show firtool-resolver.publishVersion | xargs) +export FIRTOOL_RESOLVER_VERSION=$(./mill show firtool-resolver[$SCALA_VERSION].publishVersion | xargs) export LLVM_FIRTOOL_VERSION=$(./mill show llvm-firtool.publishVersion | xargs) # If there's a -SNAPSHOT in LLVM_FIRTOOL_VERSION, strip it export FIRTOOL_VERSION=${LLVM_FIRTOOL_VERSION%-SNAPSHOT} @@ -18,7 +19,7 @@ $THIS_DIR/negative.sh 2>&1 | FileCheck $THIS_DIR/negative.sh # TODO remove this line, use maven central published versions ./mill llvm-firtool.publishLocal -./mill firtool-resolver.publishLocal +./mill firtool-resolver[$SCALA_VERSION].publishLocal $THIS_DIR/on_classpath.sh 2>&1 | FileCheck -DLLVM_FIRTOOL_VERSION="$LLVM_FIRTOOL_VERSION" -DFIRTOOL_VERSION="$FIRTOOL_VERSION" $THIS_DIR/on_classpath.sh