16 import scala.io.Source |
16 import scala.io.Source |
17 import scala.util.matching.Regex |
17 import scala.util.matching.Regex |
18 import scala.collection.mutable |
18 import scala.collection.mutable |
19 |
19 |
20 |
20 |
21 class Isabelle_System extends Standard_System |
21 class Isabelle_System(this_isabelle_home: String) extends Standard_System |
22 { |
22 { |
|
23 def this() = this(null) |
|
24 |
|
25 |
23 /** Isabelle environment **/ |
26 /** Isabelle environment **/ |
|
27 |
|
28 /* |
|
29 isabelle_home precedence: |
|
30 (1) this_isabelle_home as explicit argument |
|
31 (2) ISABELLE_HOME process environment variable (e.g. inherited from running isabelle tool) |
|
32 (3) isabelle.home system property (e.g. via JVM application boot process) |
|
33 */ |
24 |
34 |
25 private val environment: Map[String, String] = |
35 private val environment: Map[String, String] = |
26 { |
36 { |
27 import scala.collection.JavaConversions._ |
37 import scala.collection.JavaConversions._ |
28 |
38 |
29 val env0 = Map(java.lang.System.getenv.toList: _*) + |
39 val env0 = Map(java.lang.System.getenv.toList: _*) + |
30 ("THIS_JAVA" -> this_java()) |
40 ("THIS_JAVA" -> this_java()) |
31 |
41 |
32 val isabelle_home = |
42 val isabelle_home = |
33 env0.get("ISABELLE_HOME") match { |
43 if (this_isabelle_home != null) this_isabelle_home |
34 case None | Some("") => |
44 else |
35 val path = java.lang.System.getProperty("isabelle.home") |
45 env0.get("ISABELLE_HOME") match { |
36 if (path == null || path == "") error("Unknown Isabelle home directory") |
46 case None | Some("") => |
37 else path |
47 val path = java.lang.System.getProperty("isabelle.home") |
38 case Some(path) => path |
48 if (path == null || path == "") error("Unknown Isabelle home directory") |
39 } |
49 else path |
|
50 case Some(path) => path |
|
51 } |
40 |
52 |
41 Standard_System.with_tmp_file("settings") { dump => |
53 Standard_System.with_tmp_file("settings") { dump => |
42 val shell_prefix = |
54 val shell_prefix = |
43 if (Platform.is_windows) List(platform_root + "\\bin\\bash", "-l") else Nil |
55 if (Platform.is_windows) List(platform_root + "\\bin\\bash", "-l") else Nil |
44 val cmdline = |
56 val cmdline = |