-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bundle scala cli in scala command (#20351)
fixes #20098 Proposed changes to zip/targz archive: - in the `/bin` directory store an extra launcher for Scala CLI (either JAR, or native per platform). - `/bin/scala[.bat]` is modified to invoke Scala CLI stored in `/bin` - new `/maven2` directory, which stores all the Jars and POM files necessary (in maven repo style) for scala-cli to invoke scala compiler offline (using the `-r` launcher option). - CHOICE: either replace jar files in `/lib` by aliases to the corresponding jar in `/maven2`, OR delete `/lib` and update references from scripts. (Looks like symlinks are not portable, so probably we should encode the classpath in a file, or adjust slightly how we build the toolchain) - add platform specific suffixes to artefacts: - e.g. `scala-3.5.0-x86_64-pc-linux.tar.gz` (for the artefact that bundles the x64 linux launcher) --------- Co-authored-by: Hamza REMMAL <[email protected]>
- Loading branch information
1 parent
dea3d10
commit f7ab683
Showing
60 changed files
with
1,423 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Test CLI Launchers on all the platforms | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
linux-x86_64: | ||
name: Deploy and Test on Linux x64 architecture | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
- name: Build and test launcher command | ||
run: ./project/scripts/native-integration/bashTests | ||
env: | ||
LAUNCHER_EXPECTED_PROJECT: "dist-linux-x86_64" | ||
|
||
linux-aarch64: | ||
name: Deploy and Test on Linux ARM64 architecture | ||
runs-on: macos-latest | ||
if: ${{ false }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
# https://github.com/actions/runner-images/issues/9369 | ||
- name: Install sbt | ||
run: brew install sbt | ||
- name: Build and test launcher command | ||
run: ./project/scripts/native-integration/bashTests | ||
env: | ||
LAUNCHER_EXPECTED_PROJECT: "dist-linux-aarch64" | ||
|
||
mac-x86_64: | ||
name: Deploy and Test on Mac x64 architecture | ||
runs-on: macos-13 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
# https://github.com/actions/runner-images/issues/9369 | ||
- name: Install sbt | ||
run: brew install sbt | ||
- name: Build and test launcher command | ||
run: ./project/scripts/native-integration/bashTests | ||
env: | ||
LAUNCHER_EXPECTED_PROJECT: "dist-mac-x86_64" | ||
|
||
mac-aarch64: | ||
name: Deploy and Test on Mac ARM64 architecture | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
# https://github.com/actions/runner-images/issues/9369 | ||
- name: Install sbt | ||
run: brew install sbt | ||
- name: Build and test launcher command | ||
run: ./project/scripts/native-integration/bashTests | ||
env: | ||
LAUNCHER_EXPECTED_PROJECT: "dist-mac-aarch64" | ||
|
||
win-x86_64: | ||
name: Deploy and Test on Windows x64 architecture | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
- name: Build the launcher command | ||
run: sbt "dist-win-x86_64/pack" | ||
- name: Run the launcher command tests | ||
run: './project/scripts/native-integration/winTests.bat' | ||
shell: cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
unset cygwin mingw msys darwin | ||
|
||
# COLUMNS is used together with command line option '-pageWidth'. | ||
if command -v tput >/dev/null 2>&1; then | ||
export COLUMNS="$(tput -Tdumb cols)" | ||
fi | ||
|
||
case "`uname`" in | ||
CYGWIN*) cygwin=true | ||
;; | ||
MINGW*) mingw=true | ||
;; | ||
MSYS*) msys=true | ||
;; | ||
Darwin*) darwin=true | ||
;; | ||
esac | ||
|
||
unset DIST_PROJECT DIST_DIR | ||
|
||
if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then | ||
DIST_PROJECT="dist-win-x86_64" | ||
DIST_DIR="dist/win-x86_64" | ||
else | ||
# OS and arch logic taken from https://github.com/VirtusLab/scala-cli/blob/main/scala-cli.sh | ||
unset arch ARCH_NORM | ||
arch=$(uname -m) | ||
if [[ "$arch" == "aarch64" ]] || [[ "$arch" == "x86_64" ]]; then | ||
ARCH_NORM="$arch" | ||
elif [[ "$arch" == "amd64" ]]; then | ||
ARCH_NORM="x86_64" | ||
elif [[ "$arch" == "arm64" ]]; then | ||
ARCH_NORM="aarch64" | ||
else | ||
ARCH_NORM="unknown" | ||
fi | ||
|
||
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then | ||
if [[ "$ARCH_NORM" == "unknown" ]]; then | ||
echo >&2 "unknown Linux CPU architecture, defaulting to JVM launcher" | ||
DIST_PROJECT="dist" | ||
DIST_DIR="dist" | ||
else | ||
DIST_PROJECT="dist-linux-$ARCH_NORM" | ||
DIST_DIR="dist/linux-$ARCH_NORM" | ||
fi | ||
elif [ "$(uname)" == "Darwin" ]; then | ||
if [[ "$ARCH_NORM" == "unknown" ]]; then | ||
echo >&2 "unknown Darwin CPU architecture, defaulting to JVM launcher" | ||
DIST_PROJECT="dist" | ||
DIST_DIR="dist" | ||
else | ||
DIST_PROJECT="dist-mac-$ARCH_NORM" | ||
DIST_DIR="dist/mac-$ARCH_NORM" | ||
fi | ||
else | ||
echo >&2 "unknown OS, defaulting to JVM launcher" | ||
DIST_PROJECT="dist" | ||
DIST_DIR="dist" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...st-resources/scripting/classpathReport.sc → ...ces/scripting/classpathReport_scalacli.sc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
// this file is intended to be ran as an argument to the dotty.tools.scripting.ScriptingDriver class | ||
|
||
def main(args: Array[String]): Unit = | ||
println("Hello " + util.Properties.propOrNull("key")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This file is a Scala CLI script. | ||
|
||
println("Hello " + util.Properties.propOrNull("key")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env scala | ||
#!/usr/bin/env fake-program-to-test-hashbang-removal | ||
# comment | ||
STUFF=nada | ||
!# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.