Skip to content

Commit

Permalink
Adapt the scripts to sbt-native-packager
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaremmal committed Jul 2, 2024
1 parent 1e2be00 commit 70fc581
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 72 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions bin/common
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@"
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/scripting/ClasspathTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ", ""))
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/dotty/tools/scripting/ScriptTestEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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=<path-to-bash.exe>
* To specify where `dist[*]/target/pack/bin` resides, set TEST_CWD=<working-directory>
* To specify where `dist[*]/target/universal/stage/bin` resides, set TEST_CWD=<working-directory>
* Test scripts run in a bash env, so paths are converted to forward slash via .norm.
*/
object ScriptTestEnv {
Expand Down Expand Up @@ -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
Expand All @@ -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())

Expand Down Expand Up @@ -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 =
Expand Down
50 changes: 0 additions & 50 deletions project/DistributionPlugin.scala

This file was deleted.

10 changes: 5 additions & 5 deletions project/scripts/bootstrappedOnlyCmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion project/scripts/buildScalaBinary
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion project/scripts/cmdScaladocTests
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion project/scripts/winCmdTests
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion project/scripts/winCmdTests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 70fc581

Please sign in to comment.