src/Pure/System/platform.scala
author wenzelm
Wed Jun 02 11:09:26 2010 +0200 (2010-06-02 ago)
changeset 37251 72c7e636067b
parent 36786 b7a62e7dec00
child 41381 77990a6cd558
permissions -rw-r--r--
normalize and postprocess proof body in a separate future, taking care of platforms without multithreading (greately improves parallelization in general without the overhead of promised proofs, cf. usedir -q 0);
     1 /*  Title:      Pure/System/platform.scala
     2     Author:     Makarius
     3 
     4 Raw platform identification.
     5 */
     6 
     7 package isabelle
     8 
     9 import javax.swing.UIManager
    10 
    11 import scala.util.matching.Regex
    12 
    13 
    14 object Platform
    15 {
    16   /* main OS variants */
    17 
    18   val is_macos = System.getProperty("os.name") == "Mac OS X"
    19   val is_windows = System.getProperty("os.name").startsWith("Windows")
    20 
    21 
    22   /* Platform identifiers */
    23 
    24   private val Solaris = new Regex("SunOS|Solaris")
    25   private val Linux = new Regex("Linux")
    26   private val Darwin = new Regex("Mac OS X")
    27   private val Windows = new Regex("Windows.*")
    28 
    29   private val X86 = new Regex("i.86|x86")
    30   private val X86_64 = new Regex("amd64|x86_64")
    31   private val Sparc = new Regex("sparc")
    32   private val PPC = new Regex("PowerPC|ppc")
    33 
    34   lazy val jvm_platform: String =
    35   {
    36     val arch =
    37       java.lang.System.getProperty("os.arch") match {
    38         case X86() => "x86"
    39         case X86_64() => "x86_64"
    40         case Sparc() => "sparc"
    41         case PPC() => "ppc"
    42         case _ => error("Failed to determine CPU architecture")
    43       }
    44     val os =
    45       java.lang.System.getProperty("os.name") match {
    46         case Solaris() => "solaris"
    47         case Linux() => "linux"
    48         case Darwin() => "darwin"
    49         case Windows() => "windows"
    50         case _ => error("Failed to determine operating system platform")
    51       }
    52     arch + "-" + os
    53   }
    54 
    55 
    56   /* Swing look-and-feel */
    57 
    58   private def find_laf(name: String): Option[String] =
    59     UIManager.getInstalledLookAndFeels().find(_.getName == name).map(_.getClassName)
    60 
    61   def get_laf(): String =
    62   {
    63     if (is_windows || is_macos) UIManager.getSystemLookAndFeelClassName()
    64     else
    65       find_laf("Nimbus") orElse find_laf("GTK+") getOrElse
    66       UIManager.getCrossPlatformLookAndFeelClassName()
    67   }
    68 
    69   def init_laf(): Unit = UIManager.setLookAndFeel(get_laf())
    70 }
    71