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;
     1 /*  Title:      Pure/System/platform.scala
     2     Module:     PIDE
     3     Author:     Makarius
     4 
     5 Raw platform identification.
     6 */
     7 
     8 package isabelle
     9 
    10 import java.lang.System
    11 
    12 import scala.util.matching.Regex
    13 
    14 
    15 object Platform
    16 {
    17   /* main OS variants */
    18 
    19   val is_macos = System.getProperty("os.name") == "Mac OS X"
    20   val is_windows = System.getProperty("os.name").startsWith("Windows")
    21 
    22 
    23   /* Platform identifiers */
    24 
    25   private val Solaris = new Regex("SunOS|Solaris")
    26   private val Linux = new Regex("Linux")
    27   private val Darwin = new Regex("Mac OS X")
    28   private val Windows = new Regex("Windows.*")
    29 
    30   private val X86 = new Regex("i.86|x86")
    31   private val X86_64 = new Regex("amd64|x86_64")
    32   private val Sparc = new Regex("sparc")
    33   private val PPC = new Regex("PowerPC|ppc")
    34 
    35   lazy val jvm_platform: String =
    36   {
    37     val arch =
    38       System.getProperty("os.arch") match {
    39         case X86() => "x86"
    40         case X86_64() => "x86_64"
    41         case Sparc() => "sparc"
    42         case PPC() => "ppc"
    43         case _ => error("Failed to determine CPU architecture")
    44       }
    45     val os =
    46       System.getProperty("os.name") match {
    47         case Solaris() => "solaris"
    48         case Linux() => "linux"
    49         case Darwin() => "darwin"
    50         case Windows() => "windows"
    51         case _ => error("Failed to determine operating system platform")
    52       }
    53     arch + "-" + os
    54   }
    55 
    56 
    57   /* JVM name */
    58 
    59   val jvm_name: String = System.getProperty("java.vm.name")
    60 }
    61