author | wenzelm |
Thu, 06 Jun 2024 22:03:20 +0200 | |
changeset 80271 | 198fc882ec0f |
parent 80025 | d1ac1bb01060 |
permissions | -rw-r--r-- |
80021
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/System/setup_tool.scala |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
3 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
4 |
Additional setup tools for other Isabelle distribution. |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
6 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
8 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
9 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
10 |
object Setup_Tool { |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
11 |
lazy val services: List[Setup_Tool] = |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
12 |
Isabelle_System.make_services(classOf[Setup_Tool]) |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
13 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
14 |
def init(other_isabelle: Other_Isabelle, verbose: Boolean = false): Unit = |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
15 |
services.foreach(_.init(other_isabelle, verbose = verbose)) |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
16 |
} |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
17 |
|
80022
77e605c66797
clarified signature: explicit variable is easier to find in source;
wenzelm
parents:
80021
diff
changeset
|
18 |
abstract class Setup_Tool(tool: String, val variable: String) |
80021
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
19 |
extends Isabelle_System.Service { |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
20 |
override def toString: String = tool |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
21 |
|
80025 | 22 |
val test_file: Path = Path.explode("lib/Tools") + Path.basic(tool) |
80021
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
23 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
24 |
def test(other_isabelle: Other_Isabelle): Boolean = |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
25 |
other_isabelle.getenv(variable) == "true" && |
80025 | 26 |
other_isabelle.ssh.is_file(other_isabelle.isabelle_home + test_file) |
80021
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
27 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
28 |
def run(other_isabelle: Other_Isabelle, verbose: Boolean = false): Unit = |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
29 |
other_isabelle.bash("bin/isabelle " + Bash.string(tool), echo = verbose) |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
30 |
|
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
31 |
def init(other_isabelle: Other_Isabelle, verbose: Boolean = false): Unit = |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
32 |
if (test(other_isabelle)) run(other_isabelle, verbose = verbose) |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
33 |
} |
ba06861e91f9
proper services for Setup_Tool --- avoid hardwired stuff;
wenzelm
parents:
diff
changeset
|
34 |
|
80022
77e605c66797
clarified signature: explicit variable is easier to find in source;
wenzelm
parents:
80021
diff
changeset
|
35 |
class GHC_Setup extends Setup_Tool("ghc_setup", "ISABELLE_GHC_SETUP") |
77e605c66797
clarified signature: explicit variable is easier to find in source;
wenzelm
parents:
80021
diff
changeset
|
36 |
class OCaml_Setup extends Setup_Tool("ocaml_setup", "ISABELLE_OCAML_SETUP") |