| author | wenzelm | 
| Thu, 08 Aug 2013 23:52:35 +0200 | |
| changeset 52926 | 6415d95bf7a2 | 
| parent 51617 | 4e49bba9772d | 
| child 53582 | 8533b4cb8dd7 | 
| 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: 
45667 
diff
changeset
 | 
2  | 
Module: PIDE  | 
| 31825 | 3  | 
Author: Makarius  | 
4  | 
||
5  | 
Raw platform identification.  | 
|
6  | 
*/  | 
|
7  | 
||
8  | 
package isabelle  | 
|
9  | 
||
| 
43520
 
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
 
wenzelm 
parents: 
41381 
diff
changeset
 | 
10  | 
import java.lang.System  | 
| 31828 | 11  | 
|
| 31825 | 12  | 
import scala.util.matching.Regex  | 
13  | 
||
14  | 
||
15  | 
object Platform  | 
|
16  | 
{
 | 
|
| 31828 | 17  | 
/* main OS variants */  | 
18  | 
||
| 31825 | 19  | 
  val is_macos = System.getProperty("os.name") == "Mac OS X"
 | 
20  | 
  val is_windows = System.getProperty("os.name").startsWith("Windows")
 | 
|
21  | 
||
| 31828 | 22  | 
|
| 
36195
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
23  | 
/* Platform identifiers */  | 
| 31828 | 24  | 
|
| 31825 | 25  | 
  private val Solaris = new Regex("SunOS|Solaris")
 | 
26  | 
  private val Linux = new Regex("Linux")
 | 
|
27  | 
  private val Darwin = new Regex("Mac OS X")
 | 
|
| 
36195
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
28  | 
  private val Windows = new Regex("Windows.*")
 | 
| 31825 | 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  | 
||
| 
36205
 
e86d9a10e982
check JVM platform at most once -- still non-strict to prevent potential failure during initialization of object Platform;
 
wenzelm 
parents: 
36195 
diff
changeset
 | 
35  | 
lazy val jvm_platform: String =  | 
| 31825 | 36  | 
  {
 | 
| 
36195
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
37  | 
val arch =  | 
| 
43520
 
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
 
wenzelm 
parents: 
41381 
diff
changeset
 | 
38  | 
      System.getProperty("os.arch") match {
 | 
| 
36195
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
39  | 
case X86() => "x86"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
40  | 
case X86_64() => "x86_64"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
41  | 
case Sparc() => "sparc"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
42  | 
case PPC() => "ppc"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
43  | 
        case _ => error("Failed to determine CPU architecture")
 | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
44  | 
}  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
45  | 
val os =  | 
| 
43520
 
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
 
wenzelm 
parents: 
41381 
diff
changeset
 | 
46  | 
      System.getProperty("os.name") match {
 | 
| 
36195
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
47  | 
case Solaris() => "solaris"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
48  | 
case Linux() => "linux"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
49  | 
case Darwin() => "darwin"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
50  | 
case Windows() => "windows"  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
51  | 
        case _ => error("Failed to determine operating system platform")
 | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
52  | 
}  | 
| 
 
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
 
wenzelm 
parents: 
35002 
diff
changeset
 | 
53  | 
arch + "-" + os  | 
| 31825 | 54  | 
}  | 
| 31828 | 55  | 
|
56  | 
||
| 41381 | 57  | 
/* JVM name */  | 
58  | 
||
| 
43520
 
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
 
wenzelm 
parents: 
41381 
diff
changeset
 | 
59  | 
  val jvm_name: String = System.getProperty("java.vm.name")
 | 
| 31825 | 60  | 
}  | 
61  |