src/Pure/System/platform.scala
author wenzelm
Mon Jul 15 10:25:35 2013 +0200 (2013-07-15 ago)
changeset 52655 3b2b1ef13979
parent 51617 4e49bba9772d
child 53582 8533b4cb8dd7
permissions -rw-r--r--
more careful termination of removed execs, leaving running execs undisturbed;
wenzelm@31825
     1
/*  Title:      Pure/System/platform.scala
wenzelm@45673
     2
    Module:     PIDE
wenzelm@31825
     3
    Author:     Makarius
wenzelm@31825
     4
wenzelm@31825
     5
Raw platform identification.
wenzelm@31825
     6
*/
wenzelm@31825
     7
wenzelm@31825
     8
package isabelle
wenzelm@31825
     9
wenzelm@43520
    10
import java.lang.System
wenzelm@31828
    11
wenzelm@31825
    12
import scala.util.matching.Regex
wenzelm@31825
    13
wenzelm@31825
    14
wenzelm@31825
    15
object Platform
wenzelm@31825
    16
{
wenzelm@31828
    17
  /* main OS variants */
wenzelm@31828
    18
wenzelm@31825
    19
  val is_macos = System.getProperty("os.name") == "Mac OS X"
wenzelm@31825
    20
  val is_windows = System.getProperty("os.name").startsWith("Windows")
wenzelm@31825
    21
wenzelm@31828
    22
wenzelm@36195
    23
  /* Platform identifiers */
wenzelm@31828
    24
wenzelm@31825
    25
  private val Solaris = new Regex("SunOS|Solaris")
wenzelm@31825
    26
  private val Linux = new Regex("Linux")
wenzelm@31825
    27
  private val Darwin = new Regex("Mac OS X")
wenzelm@36195
    28
  private val Windows = new Regex("Windows.*")
wenzelm@31825
    29
wenzelm@31825
    30
  private val X86 = new Regex("i.86|x86")
wenzelm@31825
    31
  private val X86_64 = new Regex("amd64|x86_64")
wenzelm@31825
    32
  private val Sparc = new Regex("sparc")
wenzelm@31825
    33
  private val PPC = new Regex("PowerPC|ppc")
wenzelm@31825
    34
wenzelm@36205
    35
  lazy val jvm_platform: String =
wenzelm@31825
    36
  {
wenzelm@36195
    37
    val arch =
wenzelm@43520
    38
      System.getProperty("os.arch") match {
wenzelm@36195
    39
        case X86() => "x86"
wenzelm@36195
    40
        case X86_64() => "x86_64"
wenzelm@36195
    41
        case Sparc() => "sparc"
wenzelm@36195
    42
        case PPC() => "ppc"
wenzelm@36195
    43
        case _ => error("Failed to determine CPU architecture")
wenzelm@36195
    44
      }
wenzelm@36195
    45
    val os =
wenzelm@43520
    46
      System.getProperty("os.name") match {
wenzelm@36195
    47
        case Solaris() => "solaris"
wenzelm@36195
    48
        case Linux() => "linux"
wenzelm@36195
    49
        case Darwin() => "darwin"
wenzelm@36195
    50
        case Windows() => "windows"
wenzelm@36195
    51
        case _ => error("Failed to determine operating system platform")
wenzelm@36195
    52
      }
wenzelm@36195
    53
    arch + "-" + os
wenzelm@31825
    54
  }
wenzelm@31828
    55
wenzelm@31828
    56
wenzelm@41381
    57
  /* JVM name */
wenzelm@41381
    58
wenzelm@43520
    59
  val jvm_name: String = System.getProperty("java.vm.name")
wenzelm@31825
    60
}
wenzelm@31825
    61