-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
141 additions
and
141 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
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 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
12 changes: 12 additions & 0 deletions
12
...me-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/ExecCommand.scala
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,12 @@ | ||
package org.enso.runtimeversionmanager.runner | ||
|
||
import org.enso.runtimeversionmanager.components.Engine | ||
|
||
/** Executable command used to trigger a Runner. Can be either a Java command or a native image executable. | ||
*/ | ||
trait ExecCommand { | ||
// Path to executable | ||
def path: String | ||
def cmdArguments(engine: Engine, jvmSettings: JVMSettings): Seq[String] | ||
def javaHome: Option[String] | ||
} |
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
32 changes: 0 additions & 32 deletions
32
...me-version-manager/src/main/scala/org/enso/runtimeversionmanager/runner/JavaCommand.scala
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
...ersion-manager/src/main/scala/org/enso/runtimeversionmanager/runner/JavaExecCommand.scala
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,69 @@ | ||
package org.enso.runtimeversionmanager.runner | ||
|
||
import org.enso.runtimeversionmanager.components.{Engine, GraalRuntime} | ||
import org.enso.runtimeversionmanager.components.Manifest.JVMOptionsContext | ||
|
||
/** Represents a way of launching the JVM. | ||
* | ||
* @param executableName name of the `java` executable to run | ||
* @param javaHomeOverride if set, asks to override the JAVA_HOME environment | ||
* variable when launching the JVM | ||
*/ | ||
class JavaExecCommand( | ||
val executableName: String, | ||
val javaHome: Option[String] | ||
) extends ExecCommand { | ||
def path: String = executableName | ||
|
||
override def cmdArguments( | ||
engine: Engine, | ||
jvmSettings: JVMSettings | ||
): Seq[String] = { | ||
def translateJVMOption( | ||
option: (String, String), | ||
standardOption: Boolean | ||
): String = { | ||
val name = option._1 | ||
val value = option._2 | ||
if (standardOption) s"-D$name=$value" else s"--$name=$value" | ||
} | ||
|
||
val context = JVMOptionsContext(enginePackagePath = engine.path) | ||
|
||
val manifestOptions = | ||
engine.defaultJVMOptions | ||
.filter(_.isRelevant) | ||
.map(_.substitute(context)) | ||
val commandLineOptions = jvmSettings.jvmOptions.map( | ||
translateJVMOption(_, standardOption = true) | ||
) ++ jvmSettings.extraOptions.map( | ||
translateJVMOption(_, standardOption = false) | ||
) | ||
val componentPath = engine.componentDirPath.toAbsolutePath.normalize | ||
val modulePathOptions = | ||
Seq( | ||
"--module-path", | ||
componentPath.toString, | ||
"-m", | ||
"org.enso.runner/org.enso.runner.Main" | ||
) | ||
|
||
manifestOptions ++ commandLineOptions ++ modulePathOptions | ||
} | ||
} | ||
|
||
object JavaExecCommand { | ||
|
||
/** The [[JavaExecCommand]] representing the system-configured JVM. | ||
*/ | ||
def defaultSystem: JavaExecCommand = new JavaExecCommand("java", None) | ||
|
||
/** The [[JavaExecCommand]] representing a managed [[GraalRuntime]]. | ||
*/ | ||
def forRuntime(runtime: GraalRuntime): JavaExecCommand = | ||
new JavaExecCommand( | ||
executableName = runtime.javaExecutable.toAbsolutePath.normalize.toString, | ||
javaHome = Some(runtime.javaHome.toAbsolutePath.normalize.toString) | ||
) | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...sion-manager/src/main/scala/org/enso/runtimeversionmanager/runner/NativeExecCommand.scala
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,32 @@ | ||
package org.enso.runtimeversionmanager.runner | ||
|
||
import org.enso.cli.OS | ||
import org.enso.distribution.{DistributionManager, Environment} | ||
import org.enso.runtimeversionmanager.components.Engine | ||
|
||
import java.nio.file.Path | ||
|
||
case class NativeExecCommand(executablePath: Path) extends ExecCommand { | ||
override def path: String = executablePath.toString | ||
|
||
override def cmdArguments( | ||
engine: Engine, | ||
jvmSettings: JVMSettings | ||
): Seq[String] = | ||
Seq("-Dcom.oracle.graalvm.isaot=true") | ||
|
||
override def javaHome: Option[String] = None | ||
} | ||
|
||
object NativeExecCommand { | ||
def apply(version: String): Option[NativeExecCommand] = { | ||
val env = new Environment() {} | ||
val dm = new DistributionManager(env) | ||
val execName = OS.executableName("enso") | ||
val fullExecPath = | ||
dm.paths.engines.resolve(version).resolve("bin").resolve(execName) | ||
|
||
if (fullExecPath.toFile.exists()) Some(NativeExecCommand(fullExecPath)) | ||
else None | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
...sion-manager/src/main/scala/org/enso/runtimeversionmanager/runner/NativeJavaCommand.scala
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
Oops, something went wrong.