src/Pure/System/platform.scala
author wenzelm
Wed Jan 04 15:41:18 2012 +0100 (2012-01-04)
changeset 46117 edd50ec8d471
parent 45673 cd41e3903fbf
child 51617 4e49bba9772d
permissions -rw-r--r--
updated version information;
discontinued somewhat obsolete hotspot check: OpenJDK 1.7 works reasonably well, and final bundling provides certain tested JDK/JRE versions;
     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 import javax.swing.UIManager
    12 
    13 import scala.util.matching.Regex
    14 
    15 
    16 object Platform
    17 {
    18   /* main OS variants */
    19 
    20   val is_macos = System.getProperty("os.name") == "Mac OS X"
    21   val is_windows = System.getProperty("os.name").startsWith("Windows")
    22 
    23 
    24   /* Platform identifiers */
    25 
    26   private val Solaris = new Regex("SunOS|Solaris")
    27   private val Linux = new Regex("Linux")
    28   private val Darwin = new Regex("Mac OS X")
    29   private val Windows = new Regex("Windows.*")
    30 
    31   private val X86 = new Regex("i.86|x86")
    32   private val X86_64 = new Regex("amd64|x86_64")
    33   private val Sparc = new Regex("sparc")
    34   private val PPC = new Regex("PowerPC|ppc")
    35 
    36   lazy val jvm_platform: String =
    37   {
    38     val arch =
    39       System.getProperty("os.arch") match {
    40         case X86() => "x86"
    41         case X86_64() => "x86_64"
    42         case Sparc() => "sparc"
    43         case PPC() => "ppc"
    44         case _ => error("Failed to determine CPU architecture")
    45       }
    46     val os =
    47       System.getProperty("os.name") match {
    48         case Solaris() => "solaris"
    49         case Linux() => "linux"
    50         case Darwin() => "darwin"
    51         case Windows() => "windows"
    52         case _ => error("Failed to determine operating system platform")
    53       }
    54     arch + "-" + os
    55   }
    56 
    57 
    58   /* JVM name */
    59 
    60   val jvm_name: String = System.getProperty("java.vm.name")
    61 
    62 
    63   /* Swing look-and-feel */
    64 
    65   private def find_laf(name: String): Option[String] =
    66     UIManager.getInstalledLookAndFeels().find(_.getName == name).map(_.getClassName)
    67 
    68   def get_laf(): String =
    69   {
    70     if (is_windows || is_macos) UIManager.getSystemLookAndFeelClassName()
    71     else
    72       find_laf("Nimbus") orElse find_laf("GTK+") getOrElse
    73       UIManager.getCrossPlatformLookAndFeelClassName()
    74   }
    75 
    76   def init_laf(): Unit = UIManager.setLookAndFeel(get_laf())
    77 }
    78