From 70fc58167d1952b0e51470cb92bec811ea22ec70 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Tue, 2 Jul 2024 11:35:58 +0200 Subject: [PATCH] Adapt the scripts to sbt-native-packager --- .github/workflows/ci.yaml | 8 +-- README.md | 2 +- bin/common | 6 +-- .../tools/scripting/ClasspathTests.scala | 2 +- .../dotty/tools/scripting/ScriptTestEnv.scala | 8 +-- project/DistributionPlugin.scala | 50 ------------------- project/scripts/bootstrappedOnlyCmdTests | 10 ++-- project/scripts/buildScalaBinary | 2 +- project/scripts/cmdScaladocTests | 2 +- project/scripts/winCmdTests | 2 +- project/scripts/winCmdTests.bat | 2 +- 11 files changed, 22 insertions(+), 72 deletions(-) delete mode 100644 project/DistributionPlugin.scala diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e1d9e17c908d..833434bf54e8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,8 +87,8 @@ jobs: run: cp -vf .github/workflows/repositories /root/.sbt/ ; true - name: Test - # DON'T add dist/pack! - # Adding dist/pack bootstraps the compiler + # DON'T add dist/Universal/stage! + # Adding dist/Universal/stage bootstraps the compiler # which undermines the point of these tests: # to quickly run the tests without the cost of bootstrapping # and also to run tests when the compiler doesn't bootstrap @@ -231,7 +231,7 @@ jobs: shell: cmd - name: build binary - run: sbt "dist-win-x86_64/pack" & bash -version + run: sbt "dist-win-x86_64/Universal/stage" & bash -version shell: cmd - name: cygwin tests @@ -271,7 +271,7 @@ jobs: uses: actions/checkout@v4 - name: build binary - run: sbt "dist-win-x86_64/pack" + run: sbt "dist-win-x86_64/Universal/stage" shell: cmd - name: Test diff --git a/README.md b/README.md index 7a2bda3f8073..7410c914a898 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ To try it in your project see also the [Getting Started User Guide](https://docs Building a Local Distribution ============================= -1. `sbt dist/packArchive` +1. `sbt dist/Universal/packageBin` 2. Find the newly-built distributions in `dist/target/` Code of Conduct diff --git a/bin/common b/bin/common index 37b2ebd1ff93..ad179412f590 100755 --- a/bin/common +++ b/bin/common @@ -13,14 +13,14 @@ shift # Mutates $@ by deleting the first element ($1) source "$ROOT/bin/common-platform" # Marker file used to obtain the date of latest call to sbt-back -version="$ROOT/$DIST_DIR/target/pack/VERSION" +version="$ROOT/$DIST_DIR/target/universal/stage/VERSION" # Create the target if absent or if file changed in ROOT/compiler new_files="$(find "$ROOT/compiler" \( -iname "*.scala" -o -iname "*.java" \) -newer "$version" 2> /dev/null)" if [ ! -f "$version" ] || [ ! -z "$new_files" ]; then echo "Building Dotty..." - (cd $ROOT && sbt "$DIST_PROJECT/pack") + (cd $ROOT && sbt "$DIST_PROJECT/Universal/stage") fi -"$ROOT/$DIST_DIR/target/pack/bin/$target" "$@" +"$ROOT/$DIST_DIR/target/universal/stage/bin/$target" "$@" diff --git a/compiler/test/dotty/tools/scripting/ClasspathTests.scala b/compiler/test/dotty/tools/scripting/ClasspathTests.scala index a946e509aeb3..0244e208af3c 100755 --- a/compiler/test/dotty/tools/scripting/ClasspathTests.scala +++ b/compiler/test/dotty/tools/scripting/ClasspathTests.scala @@ -67,7 +67,7 @@ class ClasspathTests: (hashbangJars.toSet -- packlibJars.toSet , "only in hashbang classpath") } // verify that the script hasbang classpath setting was effective at supplementing the classpath - // (a minimal subset of jars below dist*/target/pack/lib are always be in the classpath) + // (a minimal subset of jars below dist*/target/universal/stage/lib are always be in the classpath) val missingClasspathEntries = if hashbangClasspathJars.size != packlibJars.size then printf("packlib dir [%s]\n", packlibDir) printf("hashbangClasspathJars: %s\n", hashbangJars.map { _.relpath.norm }.mkString("\n ", "\n ", "")) diff --git a/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala b/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala index dd1cc04bb58a..771c3ba14af0 100644 --- a/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala +++ b/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala @@ -16,7 +16,7 @@ import scala.jdk.CollectionConverters.* /** * Common Code for supporting scripting tests. * To override the path to the bash executable, set TEST_BASH= - * To specify where `dist[*]/target/pack/bin` resides, set TEST_CWD= + * To specify where `dist[*]/target/universal/stage/bin` resides, set TEST_CWD= * Test scripts run in a bash env, so paths are converted to forward slash via .norm. */ object ScriptTestEnv { @@ -48,7 +48,7 @@ object ScriptTestEnv { } lazy val nativePackDir: Option[String] = { - def nativeDir(os: String, arch: String) = Some(s"dist/$os-$arch/target/pack") + def nativeDir(os: String, arch: String) = Some(s"dist/$os-$arch/target/universal/stage") def nativeOs(os: String) = archNorm match case arch @ ("aarch64" | "x86_64") => nativeDir(os, arch) case _ => None @@ -61,7 +61,7 @@ object ScriptTestEnv { def jvmPackDir() = println("warning: unknown OS architecture combination, defaulting to JVM launcher.") - "dist/target/pack" + "dist/target/universal/stage" def packDir: String = nativePackDir.getOrElse(jvmPackDir()) @@ -302,7 +302,7 @@ object ScriptTestEnv { // use optional TEST_BASH if defined, otherwise, bash must be in PATH // envScalaHome is: - // dist[*]/target/pack, if present + // dist[*]/target/universal/stage, if present // else, SCALA_HOME if defined // else, not defined lazy val envScalaHome = diff --git a/project/DistributionPlugin.scala b/project/DistributionPlugin.scala deleted file mode 100644 index 473ecd8378af..000000000000 --- a/project/DistributionPlugin.scala +++ /dev/null @@ -1,50 +0,0 @@ -import com.typesafe.sbt.packager.Keys.stage -import com.typesafe.sbt.packager.universal.UniversalPlugin -import com.typesafe.sbt.packager.universal.UniversalPlugin.autoImport.Universal -import sbt.* - -/** - * @author Hamza REMMAL (https://github.com/hamzaremmal/) - */ -object DistributionPlugin extends AutoPlugin { - - override def trigger = allRequirements - - override def requires = - super.requires && UniversalPlugin // Require the Universal Plugin to - - object autoImport { - val `universal_project` = settingKey[Project]("???") - val `linux-aarch64_project` = settingKey[Project]("???") - val `linux-x86_64_project` = settingKey[Project]("???") - val `mac-aarch64_project` = settingKey[Project]("???") - val `win-x86_64_project` = settingKey[Project]("???") - - - // ========================== TASKS TO GENERATE THE FOLDER PACKAGE ============================ - val `pack-universal` = - taskKey[File]("Generate the package with the universal binaries (folder)") - val `pack_linux-aarch64` = - taskKey[File]("Generate the package with the linux-aarch64 binaries (folder)") - val `pack_linux-x86_64` = - taskKey[File]("Generate the package with the linux-x86_64 binaries (folder)") - val `pack_mac-aarch64` = - taskKey[File]("Generate the package with the mac-aarch64 binaries (folder)") - val `pack_mac-x86_64` = - taskKey[File]("Generate the package with the mac-x86_64 binaries (folder)") - val `pack_win-x86_64` = - taskKey[File]("Generate the package with the linux-x86_64 binaries (folder)") - } - - import autoImport.* - - override def projectSettings = Def.settings( - `pack-universal` := (`universal_project` / Universal./(stage)).value , - `pack_linux-aarch64` := ???, - `pack_linux-x86_64` := ???, - `pack_mac-aarch64` := ???, - `pack_mac-x86_64` := ???, - `pack_win-x86_64` := ??? - ) - -} diff --git a/project/scripts/bootstrappedOnlyCmdTests b/project/scripts/bootstrappedOnlyCmdTests index 11c35a7028cc..93263baa122a 100755 --- a/project/scripts/bootstrappedOnlyCmdTests +++ b/project/scripts/bootstrappedOnlyCmdTests @@ -15,13 +15,13 @@ echo "testing scala.quoted.Expr.run from sbt scala" grep -qe "val a: scala.Int = 3" "$tmp" # setup for `scalac`/`scala` script tests -"$SBT" "$DIST_PROJECT/pack" +"$SBT" "$DIST_PROJECT/universal/stage" -echo "capturing scala version from $DIST_DIR/target/pack/VERSION" -IFS=':=' read -ra versionProps < "$ROOT/$DIST_DIR/target/pack/VERSION" # temporarily set IFS to ':=' to split versionProps +echo "capturing scala version from $DIST_DIR/target/universal/stage/VERSION" +IFS=':=' read -ra versionProps < "$ROOT/$DIST_DIR/target/universal/stage/VERSION" # temporarily set IFS to ':=' to split versionProps [ ${#versionProps[@]} -eq 3 ] && \ [ ${versionProps[0]} = "version" ] && \ - [ -n ${versionProps[2]} ] || die "Expected non-empty 'version' property in $ROOT/$DIST_DIR/target/pack/VERSION" + [ -n ${versionProps[2]} ] || die "Expected non-empty 'version' property in $ROOT/$DIST_DIR/target/universal/stage/VERSION" scala_version=${versionProps[2]} # check that `scalac` compiles and `scala` runs it @@ -77,7 +77,7 @@ echo "testing sbt scalac with suspension" clear_out "$OUT" "$SBT" "scala3-compiler-bootstrapped/scalac -d $OUT tests/pos-macros/macros-in-same-project-1/Bar.scala tests/pos-macros/macros-in-same-project-1/Foo.scala" > "$tmp" -# echo ":quit" | ./$DIST_DIR/target/pack/bin/scala # not supported by CI +# echo ":quit" | ./$DIST_DIR/target/universal/stage/bin/scala # not supported by CI echo "testing ./bin/scaladoc" clear_out "$OUT1" diff --git a/project/scripts/buildScalaBinary b/project/scripts/buildScalaBinary index 7fc5275e5d8d..9451dbdd2a07 100755 --- a/project/scripts/buildScalaBinary +++ b/project/scripts/buildScalaBinary @@ -9,4 +9,4 @@ SBT="$ROOT/project/scripts/sbt" # if run on CI source "$ROOT/bin/common-platform" # build the scala/scalac/scaladoc binary, where scala is native for the current platform. -"$SBT" "$DIST_PROJECT/pack" +"$SBT" "$DIST_PROJECT/Universal/stage" diff --git a/project/scripts/cmdScaladocTests b/project/scripts/cmdScaladocTests index 06353af693f1..b54789032ad2 100755 --- a/project/scripts/cmdScaladocTests +++ b/project/scripts/cmdScaladocTests @@ -20,7 +20,7 @@ SOURCE_LINKS_REPOSITORY="scala/scala3" SOURCE_LINKS_VERSION="${GITHUB_SHA:-$DOTTY_BOOTSTRAPPED_VERSION}" "$SBT" "scaladoc/generateTestcasesDocumentation" > "$tmp" 2>&1 || echo "generated testcases project with sbt" -dist/target/pack/bin/scaladoc \ +dist/target/universal/stage/bin/scaladoc \ -d "$OUT1" \ -project "scaladoc testcases" \ -source-links:out/bootstrap/scala2-library-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/scala-library-src=github://scala/scala/v"${STDLIB_VERSION}"#src/library \ diff --git a/project/scripts/winCmdTests b/project/scripts/winCmdTests index fe6a43c7f68f..dbdaed218558 100644 --- a/project/scripts/winCmdTests +++ b/project/scripts/winCmdTests @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -PREFIX="dist/win-x86_64/target/pack" +PREFIX="dist/win-x86_64/target/universal/stage" SOURCE="tests/pos/HelloWorld.scala" $PREFIX/bin/scalac @project/scripts/options "$SOURCE" $PREFIX/bin/scalac -d out "$SOURCE" diff --git a/project/scripts/winCmdTests.bat b/project/scripts/winCmdTests.bat index 903f74d7ab98..097c05839205 100644 --- a/project/scripts/winCmdTests.bat +++ b/project/scripts/winCmdTests.bat @@ -2,7 +2,7 @@ setlocal @rem paths are relative to the root project directory -set "_PREFIX=dist\win-x86_64\target\pack" +set "_PREFIX=dist\win-x86_64\target\universal\stage" set "_SOURCE=tests\pos\HelloWorld.scala" set "_OUT_DIR=out" set "_SITE_DIR=_site"