author | wenzelm |
Wed, 03 Oct 2018 12:27:39 +0200 | |
changeset 69112 | 5b749aa452c6 |
parent 64493 | a2eebcc8bb69 |
child 69410 | c071fcec4323 |
permissions | -rw-r--r-- |
31825 | 1 |
/* Title: Pure/System/platform.scala |
2 |
Author: Makarius |
|
3 |
||
69112 | 4 |
System platform identification. |
31825 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
31828 | 9 |
|
31825 | 10 |
object Platform |
11 |
{ |
|
69112 | 12 |
/* platform family */ |
31828 | 13 |
|
64493 | 14 |
val is_linux = System.getProperty("os.name", "") == "Linux" |
53582 | 15 |
val is_macos = System.getProperty("os.name", "") == "Mac OS X" |
16 |
val is_windows = System.getProperty("os.name", "").startsWith("Windows") |
|
31825 | 17 |
|
31828 | 18 |
|
69112 | 19 |
/* platform identifiers */ |
31828 | 20 |
|
69112 | 21 |
private val Linux = """Linux""".r |
22 |
private val Darwin = """Mac OS X""".r |
|
23 |
private val Windows = """Windows.*""".r |
|
31825 | 24 |
|
69112 | 25 |
private val X86 = """i.86|x86""".r |
26 |
private val X86_64 = """amd64|x86_64""".r |
|
31825 | 27 |
|
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
|
28 |
lazy val jvm_platform: String = |
31825 | 29 |
{ |
36195
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
30 |
val arch = |
53582 | 31 |
System.getProperty("os.arch", "") match { |
36195
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
32 |
case X86() => "x86" |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
33 |
case X86_64() => "x86_64" |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
34 |
case _ => error("Failed to determine CPU architecture") |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
35 |
} |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
36 |
val os = |
53582 | 37 |
System.getProperty("os.name", "") match { |
36195
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
38 |
case Linux() => "linux" |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
39 |
case Darwin() => "darwin" |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
40 |
case Windows() => "windows" |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
41 |
case _ => error("Failed to determine operating system platform") |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
42 |
} |
9c098598db2a
system properties determine the JVM platform, not the Isabelle one;
wenzelm
parents:
35002
diff
changeset
|
43 |
arch + "-" + os |
31825 | 44 |
} |
31828 | 45 |
|
46 |
||
61001 | 47 |
/* JVM version */ |
48 |
||
69112 | 49 |
private val Version = """1\.(\d+)\.0_(\d+)""".r |
61001 | 50 |
lazy val jvm_version = |
51 |
System.getProperty("java.version") match { |
|
52 |
case Version(a, b) => a + "u" + b |
|
53 |
case a => a |
|
54 |
} |
|
55 |
||
56 |
||
41381 | 57 |
/* JVM name */ |
58 |
||
53582 | 59 |
val jvm_name: String = System.getProperty("java.vm.name", "") |
31825 | 60 |
} |