Skip to content

Introduce libexec folder in the distribution #21427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions dist/bin-native-overrides/cli-common-platform

This file was deleted.

3 changes: 0 additions & 3 deletions dist/bin-native-overrides/cli-common-platform.bat

This file was deleted.

4 changes: 2 additions & 2 deletions dist/bin/scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ if [ -z "${PROG_HOME-}" ] ; then
cd "$saveddir"
fi

source "$PROG_HOME/bin/common-shared"
source "$PROG_HOME/bin/cli-common-platform"
source "$PROG_HOME/libexec/common-shared"
source "$PROG_HOME/libexec/cli-common-platform"

SCALA_VERSION=""
# iterate through lines in VERSION_SRC
Expand Down
4 changes: 2 additions & 2 deletions dist/bin/scala.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ for %%f in ("%~dp0.") do (
@rem get rid of the trailing slash
set "_PROG_HOME=!_PROG_HOME:~0,-1!"
)
call "%_PROG_HOME%\bin\common.bat"
call "%_PROG_HOME%\libexec\common.bat"
if not %_EXITCODE%==0 goto end

@rem #########################################################################
@rem ## Main

call :setScalaOpts

call "%_PROG_HOME%\bin\cli-common-platform.bat"
call "%_PROG_HOME%\libexec\cli-common-platform.bat"

@rem SCALA_CLI_CMD_WIN is an array, set in cli-common-platform.bat.
@rem WE NEED TO PASS '--skip-cli-updates' for JVM launchers but we actually don't need it for native launchers
Expand Down
2 changes: 1 addition & 1 deletion dist/bin/scala_legacy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [ -z "${PROG_HOME-}" ] ; then
cd "$saveddir"
fi

source "$PROG_HOME/bin/common"
source "$PROG_HOME/libexec/common"

while [[ $# -gt 0 ]]; do
case "$1" in
Expand Down
2 changes: 1 addition & 1 deletion dist/bin/scalac
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [ -z "${PROG_HOME-}" ] ; then
cd "$saveddir"
fi

source "$PROG_HOME/bin/common"
source "$PROG_HOME/libexec/common"

[ -z "$PROG_NAME" ] && PROG_NAME=$CompilerMain

Expand Down
2 changes: 1 addition & 1 deletion dist/bin/scalac.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for %%f in ("%~dp0.") do (
@rem get rid of the trailing slash
set "_PROG_HOME=!_PROG_HOME:~0,-1!"
)
call "%_PROG_HOME%\bin\common.bat"
call "%_PROG_HOME%\libexec\common.bat"
if not %_EXITCODE%==0 goto end

call :args %*
Expand Down
2 changes: 1 addition & 1 deletion dist/bin/scaladoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if [ -z "${PROG_HOME-}" ] ; then
cd "$saveddir"
fi

source "$PROG_HOME/bin/common"
source "$PROG_HOME/libexec/common"
default_java_opts="-Xmx768m -Xms768m"
withCompiler=true

Expand Down
2 changes: 1 addition & 1 deletion dist/bin/scaladoc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for %%f in ("%~dp0.") do (
@rem get rid of the trailing slash
set "_PROG_HOME=!_PROG_HOME:~0,-1!"
)
call "%_PROG_HOME%\bin\common.bat"
call "%_PROG_HOME%\libexec\common.bat"
if not %_EXITCODE%==0 goto end

set _DEFAULT_JAVA_OPTS=-Xmx768m -Xms768m
Expand Down
3 changes: 3 additions & 0 deletions dist/libexec-native-overrides/cli-common-platform
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

SCALA_CLI_CMD_BASH=("\"$PROG_HOME/libexec/scala-cli\"")
3 changes: 3 additions & 0 deletions dist/libexec-native-overrides/cli-common-platform.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

set SCALA_CLI_CMD_WIN="%_PROG_HOME%\libexec\scala-cli.exe"
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dist/bin/common → dist/libexec/common
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

source "$PROG_HOME/bin/common-shared"
source "$PROG_HOME/libexec/common-shared"

#/*--------------------------------------------------
# * The code below is for Dotty
Expand Down
File renamed without changes.
File renamed without changes.
25 changes: 13 additions & 12 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2137,9 +2137,10 @@ object Build {
Universal / packageBin := (Universal / packageBin).dependsOn(republish).value,
Universal / packageZipTarball := (Universal / packageZipTarball).dependsOn(republish).value,
// ========
Universal / mappings ++= directory(republishRepo.value / "bin"),
Universal / mappings ++= directory(dist.base / "bin"),
Universal / mappings ++= directory(republishRepo.value / "maven2"),
Universal / mappings ++= directory(republishRepo.value / "lib"),
Universal / mappings ++= directory(republishRepo.value / "libexec"),
Universal / mappings += (republishRepo.value / "VERSION") -> "VERSION",
// ========
republishCommandLibs += ("scala" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core")),
Expand All @@ -2150,7 +2151,7 @@ object Build {
lazy val dist = project.asDist(Bootstrapped)
.settings(packageName := "scala3-" + dottyVersion)
.settings(
republishBinDir := baseDirectory.value / "bin",
republishLibexecDir := baseDirectory.value / "libexec",
republishCoursier +=
("coursier.jar" -> s"https://github.com/coursier/coursier/releases/download/v$coursierJarVersion/coursier.jar"),
republishLaunchers +=
Expand All @@ -2160,8 +2161,8 @@ object Build {
lazy val `dist-mac-x86_64` = project.in(file("dist/mac-x86_64")).asDist(Bootstrapped)
.settings(packageName := (dist / packageName).value + "-x86_64-apple-darwin")
.settings(
republishBinDir := (dist / republishBinDir).value,
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
republishLibexecDir := (dist / republishLibexecDir).value,
republishLibexecOverrides += (dist / baseDirectory).value / "libexec-native-overrides",
republishFetchCoursier := (dist / republishFetchCoursier).value,
republishLaunchers +=
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-x86_64-apple-darwin.gz")
Expand All @@ -2170,8 +2171,8 @@ object Build {
lazy val `dist-mac-aarch64` = project.in(file("dist/mac-aarch64")).asDist(Bootstrapped)
.settings(packageName := (dist / packageName).value + "-aarch64-apple-darwin")
.settings(
republishBinDir := (dist / republishBinDir).value,
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
republishLibexecDir := (dist / republishLibexecDir).value,
republishLibexecOverrides += (dist / baseDirectory).value / "libexec-native-overrides",
republishFetchCoursier := (dist / republishFetchCoursier).value,
republishLaunchers +=
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-aarch64-apple-darwin.gz")
Expand All @@ -2181,8 +2182,8 @@ object Build {
.enablePlugins(WindowsPlugin) // TO GENERATE THE `.msi` installer
.settings(packageName := (dist / packageName).value + "-x86_64-pc-win32")
.settings(
republishBinDir := (dist / republishBinDir).value,
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
republishLibexecDir := (dist / republishLibexecDir).value,
republishLibexecOverrides += (dist / baseDirectory).value / "libexec-native-overrides",
republishFetchCoursier := (dist / republishFetchCoursier).value,
republishLaunchers +=
("scala-cli.exe" -> s"zip+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-x86_64-pc-win32.zip!/scala-cli.exe")
Expand All @@ -2204,8 +2205,8 @@ object Build {
lazy val `dist-linux-x86_64` = project.in(file("dist/linux-x86_64")).asDist(Bootstrapped)
.settings(packageName := (dist / packageName).value + "-x86_64-pc-linux")
.settings(
republishBinDir := (dist / republishBinDir).value,
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
republishLibexecDir := (dist / republishLibexecDir).value,
republishLibexecOverrides += (dist / baseDirectory).value / "libexec-native-overrides",
republishFetchCoursier := (dist / republishFetchCoursier).value,
republishLaunchers +=
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-x86_64-pc-linux.gz")
Expand All @@ -2214,8 +2215,8 @@ object Build {
lazy val `dist-linux-aarch64` = project.in(file("dist/linux-aarch64")).asDist(Bootstrapped)
.settings(packageName := (dist / packageName).value + "-aarch64-pc-linux")
.settings(
republishBinDir := (dist / republishBinDir).value,
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
republishLibexecDir := (dist / republishLibexecDir).value,
republishLibexecOverrides += (dist / baseDirectory).value / "libexec-native-overrides",
republishFetchCoursier := (dist / republishFetchCoursier).value,
republishLaunchers +=
("scala-cli" -> s"gz+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-aarch64-pc-linux.gz")
Expand Down
20 changes: 9 additions & 11 deletions project/RepublishPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ object RepublishPlugin extends AutoPlugin {
val republishFetchCoursier = taskKey[File]("cache the coursier.jar for resolving the local maven repo.")
val republishPrepareBin = taskKey[File]("prepare the bin directory, including launchers and scripts.")
val republishWriteExtraProps = taskKey[Option[File]]("write extra properties for the launchers.")
val republishBinDir = settingKey[File]("where to find static files for the bin dir.")
val republishLibexecDir = settingKey[File]("where to find static files for the `libexec` dir.")
val republishCoursierDir = settingKey[File]("where to download the coursier launcher jar.")
val republishBinOverrides = settingKey[Seq[File]]("files to override those in bin-dir.")
val republishLibexecOverrides = settingKey[Seq[File]]("files to override those in libexec-dir.")
val republishCommandLibs = settingKey[Seq[(String, List[String])]]("libraries needed for each command.")
val republish = taskKey[File]("cache the dependencies and download launchers for the distribution")
val republishPack = taskKey[File]("do the pack command")
Expand Down Expand Up @@ -405,7 +405,7 @@ object RepublishPlugin extends AutoPlugin {
republishCoursierDir := republishRepo.value / "coursier",
republishLaunchers := Seq.empty,
republishCoursier := Seq.empty,
republishBinOverrides := Seq.empty,
republishLibexecOverrides := Seq.empty,
republishExtraProps := Seq.empty,
republishCommandLibs := Seq.empty,
republishLocalResolved / republishProjectRefs := {
Expand Down Expand Up @@ -489,16 +489,14 @@ object RepublishPlugin extends AutoPlugin {
},
republishPrepareBin := {
val baseDir = baseDirectory.value
val srcBin = republishBinDir.value
val overrides = republishBinOverrides.value
val srcLibexec = republishLibexecDir.value
val overrides = republishLibexecOverrides.value
val repoDir = republishRepo.value

val targetBin = repoDir / "bin"
IO.copyDirectory(srcBin, targetBin)
overrides.foreach { dir =>
IO.copyDirectory(dir, targetBin, overwrite = true)
}
targetBin
val targetLibexec = repoDir / "libexec"
IO.copyDirectory(srcLibexec, targetLibexec)
overrides.foreach(IO.copyDirectory(_, targetLibexec, overwrite = true))
targetLibexec
},
republishWriteExtraProps := {
val s = streams.value
Expand Down
Loading