mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 10:51:54 +03:00
9b2f611402
- Close #10622 - Changes `project-manager` and `ensoup` launcher to run the engine/language-server with working directory set to the directory containing currently running project. - If the working directory is _not_ "the directory containing currently running project", a warning is written to logs. This can happen if the raw `/bin/enso` engine runner is used in a different directory. - In the Cloud, the `File.new` interprets relative paths as cloud paths relative to the Cloud directory containing the current project. Absolute paths are unaffected.
67 lines
2.0 KiB
Scala
67 lines
2.0 KiB
Scala
import sbt.singleFileFinder
|
|
|
|
import java.io.File
|
|
|
|
object Platform {
|
|
|
|
/** Returns true if the build system is running on Windows.
|
|
*/
|
|
def isWindows: Boolean =
|
|
sys.props("os.name").toLowerCase().contains("windows")
|
|
|
|
/** Returns true if the build system is running on Linux.
|
|
*/
|
|
def isLinux: Boolean =
|
|
sys.props("os.name").toLowerCase().contains("linux")
|
|
|
|
/** Returns true if the build system is running on macOS.
|
|
*/
|
|
def isMacOS: Boolean =
|
|
sys.props("os.name").toLowerCase().contains("mac")
|
|
|
|
def isAmd64: Boolean = {
|
|
val arch = sys.props("os.arch").toLowerCase()
|
|
arch.contains("amd64") || arch.contains("x86_64")
|
|
}
|
|
|
|
def isArm64: Boolean =
|
|
sys.props("os.arch").toLowerCase().contains("aarch64")
|
|
|
|
/** Returns the dynamic library file name on the current platform.
|
|
*
|
|
* @param libraryName the library name
|
|
* @return the file name of provided library on the current platform
|
|
*/
|
|
def dynamicLibraryFileName(libraryName: String): String = {
|
|
if (isMacOS) s"lib$libraryName.dylib"
|
|
else if (isWindows) s"$libraryName.dll"
|
|
else if (isLinux) s"lib$libraryName.so"
|
|
else {
|
|
throw new RuntimeException(s"Unknown platform [${sys.props("os.name")}].")
|
|
}
|
|
}
|
|
|
|
/** Returns the executable file name on the current platform.
|
|
*
|
|
* @param name the executable name
|
|
* @return the file name of provided executable on the current platform
|
|
*/
|
|
def executableFileName(name: String): String = {
|
|
if (isWindows) s".\\$name.bat" else name
|
|
}
|
|
|
|
/** Returns the executable file on the current platform.
|
|
*
|
|
* @param file the generic executable path
|
|
* @return the file corresponding to the provided executable on the current platform
|
|
*/
|
|
def executableFile(file: File): String =
|
|
if (isWindows) {
|
|
val parent = file.getParentFile
|
|
if (parent == null) s".\\${file.getName}.bat"
|
|
else if (parent.isAbsolute)
|
|
new File(parent, s"${file.getName}.bat").getPath
|
|
else s".\\${parent.getPath}${file.getPath}.bat"
|
|
} else file.getPath
|
|
}
|