| author | wenzelm | 
| Thu, 18 Feb 2016 23:10:28 +0100 | |
| changeset 62359 | 6709e51d5c11 | 
| parent 61001 | ea38a1922a0b | 
| child 64370 | 865b39487b5d | 
| permissions | -rw-r--r-- | 
| 31825 | 1 | /* Title: Pure/System/platform.scala | 
| 45673 
cd41e3903fbf
separate compilation of PIDE vs. Pure sources, which enables independent Scala library;
 wenzelm parents: 
45667diff
changeset | 2 | Module: PIDE | 
| 31825 | 3 | Author: Makarius | 
| 4 | ||
| 5 | Raw platform identification. | |
| 6 | */ | |
| 7 | ||
| 8 | package isabelle | |
| 9 | ||
| 31828 | 10 | |
| 31825 | 11 | import scala.util.matching.Regex | 
| 12 | ||
| 13 | ||
| 14 | object Platform | |
| 15 | {
 | |
| 31828 | 16 | /* main OS variants */ | 
| 17 | ||
| 53582 | 18 |   val is_macos = System.getProperty("os.name", "") == "Mac OS X"
 | 
| 19 |   val is_windows = System.getProperty("os.name", "").startsWith("Windows")
 | |
| 31825 | 20 | |
| 31828 | 21 | |
| 36195 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 22 | /* Platform identifiers */ | 
| 31828 | 23 | |
| 31825 | 24 |   private val Solaris = new Regex("SunOS|Solaris")
 | 
| 25 |   private val Linux = new Regex("Linux")
 | |
| 26 |   private val Darwin = new Regex("Mac OS X")
 | |
| 36195 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 27 |   private val Windows = new Regex("Windows.*")
 | 
| 31825 | 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 | ||
| 36205 
e86d9a10e982
check JVM platform at most once -- still non-strict to prevent potential failure during initialization of object Platform;
 wenzelm parents: 
36195diff
changeset | 34 | lazy val jvm_platform: String = | 
| 31825 | 35 |   {
 | 
| 36195 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 36 | val arch = | 
| 53582 | 37 |       System.getProperty("os.arch", "") match {
 | 
| 36195 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 38 | case X86() => "x86" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 39 | case X86_64() => "x86_64" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 40 | case Sparc() => "sparc" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 41 | case PPC() => "ppc" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 42 |         case _ => error("Failed to determine CPU architecture")
 | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 43 | } | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 44 | val os = | 
| 53582 | 45 |       System.getProperty("os.name", "") match {
 | 
| 36195 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 46 | case Solaris() => "solaris" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 47 | case Linux() => "linux" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 48 | case Darwin() => "darwin" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 49 | case Windows() => "windows" | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 50 |         case _ => error("Failed to determine operating system platform")
 | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 51 | } | 
| 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 wenzelm parents: 
35002diff
changeset | 52 | arch + "-" + os | 
| 31825 | 53 | } | 
| 31828 | 54 | |
| 55 | ||
| 61001 | 56 | /* JVM version */ | 
| 57 | ||
| 58 |   private val Version = new Regex("""1\.(\d+)\.0_(\d+)""")
 | |
| 59 | lazy val jvm_version = | |
| 60 |     System.getProperty("java.version") match {
 | |
| 61 | case Version(a, b) => a + "u" + b | |
| 62 | case a => a | |
| 63 | } | |
| 64 | ||
| 65 | ||
| 41381 | 66 | /* JVM name */ | 
| 67 | ||
| 53582 | 68 |   val jvm_name: String = System.getProperty("java.vm.name", "")
 | 
| 31825 | 69 | } |