|
1 /* Title: Pure/Admin/component_zipperposition.scala |
|
2 Author: Makarius |
|
3 |
|
4 Build Isabelle Zipperposition component from OPAM repository. |
|
5 */ |
|
6 |
|
7 package isabelle |
|
8 |
|
9 |
|
10 object Component_Zipperposition { |
|
11 val default_version = "2.1" |
|
12 |
|
13 |
|
14 /* build Zipperposition */ |
|
15 |
|
16 def build_zipperposition( |
|
17 version: String = default_version, |
|
18 progress: Progress = new Progress, |
|
19 target_dir: Path = Path.current |
|
20 ): Unit = { |
|
21 Isabelle_System.with_tmp_dir("build") { build_dir => |
|
22 if (Platform.is_linux) Isabelle_System.require_command("patchelf") |
|
23 |
|
24 |
|
25 /* component */ |
|
26 |
|
27 val component_name = "zipperposition-" + version |
|
28 val component_dir = |
|
29 Components.Directory(target_dir + Path.basic(component_name)).create(progress = progress) |
|
30 |
|
31 |
|
32 /* platform */ |
|
33 |
|
34 val platform_name = |
|
35 proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse |
|
36 error("No 64bit platform") |
|
37 |
|
38 val platform_dir = |
|
39 Isabelle_System.make_directory(component_dir.path + Path.basic(platform_name)) |
|
40 |
|
41 |
|
42 /* build */ |
|
43 |
|
44 progress.echo("OCaml/OPAM setup ...") |
|
45 progress.bash("isabelle ocaml_setup", echo = progress.verbose).check |
|
46 |
|
47 progress.echo("Building Zipperposition for " + platform_name + " ...") |
|
48 progress.bash(cwd = build_dir.file, echo = progress.verbose, |
|
49 script = "isabelle_opam install -y --destdir=" + File.bash_path(build_dir) + |
|
50 " zipperposition=" + Bash.string(version)).check |
|
51 |
|
52 |
|
53 /* install */ |
|
54 |
|
55 Isabelle_System.copy_file(build_dir + Path.explode("doc/zipperposition/LICENSE"), |
|
56 component_dir.path) |
|
57 |
|
58 val prg_path = Path.basic("zipperposition") |
|
59 val exe_path = prg_path.platform_exe |
|
60 Isabelle_System.copy_file(build_dir + Path.basic("bin") + prg_path, platform_dir + exe_path) |
|
61 |
|
62 if (!Platform.is_windows) { |
|
63 Executable.libraries_closure( |
|
64 platform_dir + exe_path, filter = Set("libgmp"), patchelf = true) |
|
65 } |
|
66 |
|
67 |
|
68 /* settings */ |
|
69 |
|
70 component_dir.write_settings(""" |
|
71 ZIPPERPOSITION_HOME="$COMPONENT/$ISABELLE_PLATFORM64" |
|
72 """) |
|
73 |
|
74 |
|
75 /* README */ |
|
76 |
|
77 File.write(component_dir.README, |
|
78 """This is Zipperposition """ + version + """ from the OCaml/OPAM repository. |
|
79 |
|
80 |
|
81 Makarius |
|
82 """ + Date.Format.date(Date.now()) + "\n") |
|
83 } |
|
84 } |
|
85 |
|
86 |
|
87 /* Isabelle tool wrapper */ |
|
88 |
|
89 val isabelle_tool = |
|
90 Isabelle_Tool("component_zipperposition", "build prover component from OPAM repository", |
|
91 Scala_Project.here, |
|
92 { args => |
|
93 var target_dir = Path.current |
|
94 var version = default_version |
|
95 var verbose = false |
|
96 |
|
97 val getopts = Getopts(""" |
|
98 Usage: isabelle component_zipperposition [OPTIONS] |
|
99 |
|
100 Options are: |
|
101 -D DIR target directory (default ".") |
|
102 -V VERSION version (default: """" + default_version + """") |
|
103 -v verbose |
|
104 |
|
105 Build prover component from OPAM repository. |
|
106 """, |
|
107 "D:" -> (arg => target_dir = Path.explode(arg)), |
|
108 "V:" -> (arg => version = arg), |
|
109 "v" -> (_ => verbose = true)) |
|
110 |
|
111 val more_args = getopts(args) |
|
112 if (more_args.nonEmpty) getopts.usage() |
|
113 |
|
114 val progress = new Console_Progress(verbose = verbose) |
|
115 |
|
116 build_zipperposition(version = version, progress = progress, target_dir = target_dir) |
|
117 }) |
|
118 } |