Skip to content

Commit 3ce2577

Browse files
committed
PR review
1 parent 6e8c05b commit 3ce2577

File tree

19 files changed

+141
-141
lines changed

19 files changed

+141
-141
lines changed

engine/launcher/src/main/scala/org/enso/launcher/components/LauncherRunner.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class LauncherRunner(
3333
configurationManager,
3434
editionManager,
3535
environment,
36-
loggerConnection,
37-
false
36+
loggerConnection
3837
) {
3938

4039
/** Creates [[RunSettings]] for launching the REPL.

engine/launcher/src/test/scala/org/enso/launcher/components/LauncherRunnerSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class LauncherRunnerSpec extends RuntimeVersionManagerTest with FlakySpec {
7070
val jvmOptions = Seq(("locally-added-options", "value1"))
7171
val runnerEntryPoint = "org.enso.runner/org.enso.runner.Main"
7272

73-
def checkCommandLine(command: Command): Unit = {
73+
def checkCommandLine(command: RawCommand): Unit = {
7474
val arguments = command.command.tail
7575
val javaArguments = arguments.takeWhile(_ != "-jar")
7676
val appArguments = arguments.dropWhile(_ != runnerEntryPoint).tail

lib/scala/project-manager/src/main/scala/org/enso/projectmanager/boot/Cli.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ object Cli {
1212
val NO_LOG_MASKING = "no-log-masking"
1313
val VERBOSE_OPTION = "verbose"
1414
val VERSION_OPTION = "version"
15-
val NATIVE_OPTION = "native-language-server"
1615
val PROFILING_PATH = "profiling-path"
1716
val PROFILING_TIME = "profiling-time"
1817
val PROJECTS_DIRECTORY = "projects-directory"
@@ -46,13 +45,6 @@ object Cli {
4645
.desc("Checks the version of the Enso executable.")
4746
.build()
4847

49-
val native: cli.Option = cli.Option.builder
50-
.longOpt(NATIVE_OPTION)
51-
.desc(
52-
"(experimental) Attempts to use the native-image of any subprocess."
53-
)
54-
.build()
55-
5648
val json: cli.Option = cli.Option.builder
5749
.longOpt(JSON_OPTION)
5850
.desc("Switches the --version option to JSON output.")
@@ -172,7 +164,6 @@ object Cli {
172164
.addOption(option.version)
173165
.addOption(option.json)
174166
.addOption(option.noLogMasking)
175-
.addOption(option.native)
176167
.addOption(option.profilingPath)
177168
.addOption(option.profilingTime)
178169
.addOption(option.projectsDirectory)

lib/scala/project-manager/src/main/scala/org/enso/projectmanager/boot/ProjectManager.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ object ProjectManager extends ZIOAppDefault with LazyLogging {
296296
logLevel <- setupLogging(verbosity, logMasking)
297297
procConf = MainProcessConfig(
298298
logLevel,
299-
options.hasOption(Cli.NATIVE_OPTION),
300299
opts.profilingPath,
301300
opts.profilingTime
302301
)

lib/scala/project-manager/src/main/scala/org/enso/projectmanager/boot/configuration.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ object configuration {
1919
*/
2020
case class MainProcessConfig(
2121
logLevel: Level,
22-
nativeImage: Boolean,
2322
profilingPath: Option[Path],
2423
profilingTime: Option[FiniteDuration]
2524
)

lib/scala/project-manager/src/main/scala/org/enso/projectmanager/infrastructure/languageserver/ExecutorWithUnlimitedPool.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ object ExecutorWithUnlimitedPool extends LanguageServerExecutor {
100100
globalConfigurationManager = configurationManager,
101101
editionManager = distributionConfiguration.editionManager,
102102
environment = distributionConfiguration.environment,
103-
loggerConnection = descriptor.deferredLoggingServiceEndpoint,
104-
nativeImage = descriptor.nativeImage
103+
loggerConnection = descriptor.deferredLoggingServiceEndpoint
105104
)
106105
val profilingPathArguments =
107106
descriptor.profilingPath.toSeq

lib/scala/project-manager/src/main/scala/org/enso/projectmanager/infrastructure/languageserver/LanguageServerController.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ class LanguageServerController(
8989
profilingPath = processConfig.profilingPath,
9090
profilingTime = processConfig.profilingTime,
9191
deferredLoggingServiceEndpoint = loggingServiceDescriptor.getEndpoint,
92-
skipGraalVMUpdater = bootloaderConfig.skipGraalVMUpdater,
93-
nativeImage = processConfig.nativeImage
92+
skipGraalVMUpdater = bootloaderConfig.skipGraalVMUpdater
9493
)
9594

9695
override def supervisorStrategy: SupervisorStrategy =

lib/scala/project-manager/src/main/scala/org/enso/projectmanager/infrastructure/languageserver/LanguageServerDescriptor.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ case class LanguageServerDescriptor(
4343
engineVersion: SemVer,
4444
jvmSettings: JVMSettings,
4545
discardOutput: Boolean,
46-
nativeImage: Boolean,
4746
profilingPath: Option[Path],
4847
profilingTime: Option[FiniteDuration],
4948
deferredLoggingServiceEndpoint: Future[Option[URI]],

lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/ProjectCreationService.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class ProjectCreationService[
5252
globalConfigurationManager = configurationManager,
5353
editionManager = distributionConfiguration.editionManager,
5454
environment = distributionConfiguration.environment,
55-
loggerConnection = loggingServiceDescriptor.getEndpoint,
56-
nativeImage = false
55+
loggerConnection = loggingServiceDescriptor.getEndpoint
5756
)
5857

5958
val settings =

lib/scala/project-manager/src/test/scala/org/enso/projectmanager/BaseServerSpec.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
9393
val processConfig: MainProcessConfig =
9494
MainProcessConfig(
9595
logLevel = if (debugLogs) Level.TRACE else Level.ERROR,
96-
nativeImage = false,
9796
profilingPath = profilingPath,
9897
profilingTime = None
9998
)

lib/scala/project-manager/src/test/scala/org/enso/projectmanager/TestDistributionConfiguration.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.enso.runtimeversionmanager.releases.{
2525
ReleaseProvider,
2626
SimpleReleaseProvider
2727
}
28-
import org.enso.runtimeversionmanager.runner.{JVMSettings, JavaCommand}
28+
import org.enso.runtimeversionmanager.runner.{JVMSettings, JavaExecCommand}
2929
import org.enso.runtimeversionmanager.test.{
3030
FakeEnvironment,
3131
TestLocalLockManager
@@ -94,7 +94,7 @@ class TestDistributionConfiguration(
9494
override def defaultJVMSettings: JVMSettings = {
9595
val currentProcess =
9696
ProcessHandle.current().info().command().toScala.getOrElse("java")
97-
val javaCommand = new JavaCommand(currentProcess, None)
97+
val javaCommand = new JavaExecCommand(currentProcess, None)
9898
new JVMSettings(
9999
javaCommandOverride = Some(javaCommand),
100100
jvmOptions = Seq(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.enso.runtimeversionmanager.runner
2+
3+
import org.enso.runtimeversionmanager.components.Engine
4+
5+
/** Executable command used to trigger a Runner. Can be either a Java command or a native image executable.
6+
*/
7+
trait ExecCommand {
8+
// Path to executable
9+
def path: String
10+
def cmdArguments(engine: Engine, jvmSettings: JVMSettings): Seq[String]
11+
def javaHome: Option[String]
12+
}

lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/JVMSettings.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package org.enso.runtimeversionmanager.runner
1010
* @param extraOptions extra options that should be added to the launched JVM
1111
*/
1212
case class JVMSettings(
13-
javaCommandOverride: Option[JavaCommand],
13+
javaCommandOverride: Option[JavaExecCommand],
1414
jvmOptions: Seq[(String, String)],
1515
extraOptions: Seq[(String, String)],
1616
nativeImage: Boolean
@@ -32,7 +32,7 @@ object JVMSettings {
3232
nativeImage: Boolean = false
3333
): JVMSettings =
3434
new JVMSettings(
35-
if (useSystemJVM) Some(JavaCommand.systemJavaCommand) else None,
35+
if (useSystemJVM) Some(JavaExecCommand.defaultSystem) else None,
3636
jvmOptions,
3737
extraOptions,
3838
nativeImage

lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/JavaCommand.scala

Lines changed: 0 additions & 32 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.enso.runtimeversionmanager.runner
2+
3+
import org.enso.runtimeversionmanager.components.{Engine, GraalRuntime}
4+
import org.enso.runtimeversionmanager.components.Manifest.JVMOptionsContext
5+
6+
/** Represents a way of launching the JVM.
7+
*
8+
* @param executableName name of the `java` executable to run
9+
* @param javaHomeOverride if set, asks to override the JAVA_HOME environment
10+
* variable when launching the JVM
11+
*/
12+
class JavaExecCommand(
13+
val executableName: String,
14+
val javaHome: Option[String]
15+
) extends ExecCommand {
16+
def path: String = executableName
17+
18+
override def cmdArguments(
19+
engine: Engine,
20+
jvmSettings: JVMSettings
21+
): Seq[String] = {
22+
def translateJVMOption(
23+
option: (String, String),
24+
standardOption: Boolean
25+
): String = {
26+
val name = option._1
27+
val value = option._2
28+
if (standardOption) s"-D$name=$value" else s"--$name=$value"
29+
}
30+
31+
val context = JVMOptionsContext(enginePackagePath = engine.path)
32+
33+
val manifestOptions =
34+
engine.defaultJVMOptions
35+
.filter(_.isRelevant)
36+
.map(_.substitute(context))
37+
val commandLineOptions = jvmSettings.jvmOptions.map(
38+
translateJVMOption(_, standardOption = true)
39+
) ++ jvmSettings.extraOptions.map(
40+
translateJVMOption(_, standardOption = false)
41+
)
42+
val componentPath = engine.componentDirPath.toAbsolutePath.normalize
43+
val modulePathOptions =
44+
Seq(
45+
"--module-path",
46+
componentPath.toString,
47+
"-m",
48+
"org.enso.runner/org.enso.runner.Main"
49+
)
50+
51+
manifestOptions ++ commandLineOptions ++ modulePathOptions
52+
}
53+
}
54+
55+
object JavaExecCommand {
56+
57+
/** The [[JavaExecCommand]] representing the system-configured JVM.
58+
*/
59+
def defaultSystem: JavaExecCommand = new JavaExecCommand("java", None)
60+
61+
/** The [[JavaExecCommand]] representing a managed [[GraalRuntime]].
62+
*/
63+
def forRuntime(runtime: GraalRuntime): JavaExecCommand =
64+
new JavaExecCommand(
65+
executableName = runtime.javaExecutable.toAbsolutePath.normalize.toString,
66+
javaHome = Some(runtime.javaHome.toAbsolutePath.normalize.toString)
67+
)
68+
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.enso.runtimeversionmanager.runner
2+
3+
import org.enso.cli.OS
4+
import org.enso.distribution.{DistributionManager, Environment}
5+
import org.enso.runtimeversionmanager.components.Engine
6+
7+
import java.nio.file.Path
8+
9+
case class NativeExecCommand(executablePath: Path) extends ExecCommand {
10+
override def path: String = executablePath.toString
11+
12+
override def cmdArguments(
13+
engine: Engine,
14+
jvmSettings: JVMSettings
15+
): Seq[String] =
16+
Seq("-Dcom.oracle.graalvm.isaot=true")
17+
18+
override def javaHome: Option[String] = None
19+
}
20+
21+
object NativeExecCommand {
22+
def apply(version: String): Option[NativeExecCommand] = {
23+
val env = new Environment() {}
24+
val dm = new DistributionManager(env)
25+
val execName = OS.executableName("enso")
26+
val fullExecPath =
27+
dm.paths.engines.resolve(version).resolve("bin").resolve(execName)
28+
29+
if (fullExecPath.toFile.exists()) Some(NativeExecCommand(fullExecPath))
30+
else None
31+
}
32+
}

lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/NativeJavaCommand.scala

Lines changed: 0 additions & 20 deletions
This file was deleted.

lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/Command.scala renamed to lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/RawCommand.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import scala.util.{Failure, Try}
1313
* @param extraEnv environment variables that should be overridden
1414
* @param workingDirectory the working directory in which the command should be executed (if None, the working directory is not overridden and is inherited instead)
1515
*/
16-
case class Command(
16+
case class RawCommand(
1717
command: Seq[String],
1818
extraEnv: Seq[(String, String)],
1919
workingDirectory: Option[Path]
2020
) {
21-
private val logger = Logger[Command]
21+
private val logger = Logger[RawCommand]
2222

2323
/** Runs the command and returns its exit code.
2424
*

0 commit comments

Comments
 (0)