src/Pure/Admin/component_hol_light.scala
author wenzelm
Sun, 19 Jan 2025 14:23:13 +0100 (5 weeks ago)
changeset 81924 61b711122061
parent 81923 02b4ae06974d
child 81925 27854cbcadf1
permissions -rw-r--r--
allow to load additional HOL Light files, after "hol.ml";
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Admin/component_hol_light.scala
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     3
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     4
Build component for HOL-Light, with export of facts and proofs, offline
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     5
optimization, and import to Isabelle/HOL.
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     6
*/
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     7
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     8
package isabelle
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
     9
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    10
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    11
object Component_HOL_Light {
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    12
  /* resources */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    13
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    14
  val default_hol_light_url = "https://github.com/jrh13/hol-light.git"
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    15
  val default_hol_light_rev = "Release-3.0.0"
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    16
81915
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
    17
  val hol_import_dir: Path = Path.explode("~~/src/HOL/Import")
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    18
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    19
  def build_hol_light_import(
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    20
    only_offline: Boolean = false,
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    21
    progress: Progress = new Progress,
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    22
    target_dir: Path = Path.current,
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
    23
    load_more: List[Path] = Nil,
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    24
    hol_light_url: String = default_hol_light_url,
81915
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
    25
    hol_light_rev: String = default_hol_light_rev
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    26
  ): Unit = {
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    27
    /* system */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    28
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    29
    if (!only_offline) {
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    30
      Linux.check_system()
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    31
      Isabelle_System.require_command("patch")
81920
8d5989ab1e42 clarified compression;
wenzelm
parents: 81918
diff changeset
    32
      Isabelle_System.require_command("zstd")
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    33
    }
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    34
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    35
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    36
    /* component */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    37
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    38
    val component_name = "hol_light_import-" + Date.Format.alt_date(Date.now())
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    39
    val component_dir = Components.Directory(target_dir + Path.basic(component_name)).create()
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    40
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    41
    val platform = Isabelle_Platform.self.ISABELLE_PLATFORM(windows = true, apple = true)
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    42
    val platform_dir = Isabelle_System.make_directory(component_dir.path + Path.basic(platform))
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    43
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    44
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    45
    /* settings */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    46
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    47
    component_dir.write_settings("""
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    48
HOL_LIGHT_IMPORT="$COMPONENT"
81921
86e3ad5034a1 proper settings;
wenzelm
parents: 81920
diff changeset
    49
HOL_LIGHT_BUNDLE="$HOL_LIGHT_IMPORT/bundle/proofs.zst"
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    50
HOL_LIGHT_OFFLINE="$HOL_LIGHT_IMPORT/${ISABELLE_WINDOWS_PLATFORM64:-${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}}/offline"
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    51
""")
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    52
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    53
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    54
    /* README */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    55
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    56
    File.write(component_dir.README,
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    57
      """Author: Cezary Kaliszyk, University of Innsbruck, 2013
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    58
Author: Alexander Krauss, QAware GmbH, 2013
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    59
Author: Sophie Tourret, INRIA, 2024
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    60
Author: Stéphane Glondu, INRIA, 2024
81922
aa9800b48193 tuned README;
wenzelm
parents: 81921
diff changeset
    61
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    62
LICENSE (export tools): BSD-3 from Isabelle
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    63
LICENSE (HOL Light proofs): BSD-2 from HOL Light
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    64
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    65
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    66
This is an export of primitive proofs from HOL Light """ + hol_light_rev + """.
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    67
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    68
The original repository """ + hol_light_url + """
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
    69
has been patched in 2 phases. The overall export process works like this:
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    70
81915
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
    71
  cd hol-light
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    72
  make
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    73
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
    74
  patch -p1 < "$HOL_LIGHT_IMPORT/patches/patch1"
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    75
  ./ocaml-hol -I +compiler-libs stage1.ml
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    76
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
    77
  patch -p1 < "$HOL_LIGHT_IMPORT/patches/patch2"
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    78
  export MAXTMS=10000
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    79
  ./ocaml-hol -I +compiler-libs stage2.ml
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    80
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    81
  > maps.lst
81915
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
    82
  "$HOL_LIGHT_IMPORT/x86_64-linux/offline"
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    83
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    84
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    85
      Makarius
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    86
      """ + Date.Format.date(Date.now()) + "\n")
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    87
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    88
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    89
    Isabelle_System.with_tmp_dir("build") { tmp_dir =>
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    90
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    91
      /* OCaml setup */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    92
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    93
      progress.echo("Setup OCaml ...")
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    94
      progress.bash(
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    95
        if (only_offline) "isabelle ocaml_setup_base"
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    96
        else "isabelle ocaml_setup && isabelle ocaml_opam install -y camlp5",
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    97
        echo = progress.verbose).check
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    98
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
    99
      val opam_env = Isabelle_System.bash("isabelle ocaml_opam env").check.out
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   100
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   101
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   102
      /* "offline" tool */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   103
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   104
      progress.echo("Building offline tool ...")
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   105
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   106
      val offline_path = Path.explode("offline")
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   107
      val offline_exe = offline_path.platform_exe
81915
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
   108
      val offline_dir = Isabelle_System.make_directory(tmp_dir + offline_path)
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
   109
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
   110
      Isabelle_System.copy_dir(hol_import_dir + offline_path, offline_dir, direct = true)
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   111
81915
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
   112
      progress.bash("ocamlopt offline.ml -o offline",
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
   113
        cwd = offline_dir, echo = progress.verbose).check
02e107686442 move material from https://gitlab.inria.fr/hol-light-isabelle/hol-light 72b2b702eadb and https://gitlab.inria.fr/hol-light-isabelle/import ce58755b0232 into Isabelle repository: results from running "isabelle component_hol_light_import" of previous version;
wenzelm
parents: 81834
diff changeset
   114
      Isabelle_System.copy_file(offline_dir + offline_exe, platform_dir + offline_exe)
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   115
      File.set_executable(platform_dir + offline_exe)
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   116
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   117
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   118
      if (!only_offline) {
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   119
        /* clone repository */
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   120
81916
2bb448f2ac51 avoid redundant repository clone;
wenzelm
parents: 81915
diff changeset
   121
        val hol_light_dir = tmp_dir + Path.basic("hol-light")
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   122
81916
2bb448f2ac51 avoid redundant repository clone;
wenzelm
parents: 81915
diff changeset
   123
        Isabelle_System.git_clone(hol_light_url, hol_light_dir, checkout = hol_light_rev,
2bb448f2ac51 avoid redundant repository clone;
wenzelm
parents: 81915
diff changeset
   124
          progress = progress)
2bb448f2ac51 avoid redundant repository clone;
wenzelm
parents: 81915
diff changeset
   125
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   126
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   127
        /* patches */
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   128
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   129
        Isabelle_System.make_directory(component_dir.path + Path.basic("patches"))
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   130
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   131
        def patch(n: Int, source: Boolean = false): Path =
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   132
          (if (source) hol_import_dir else component_dir.path) + Path.explode("patches/patch" + n)
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   133
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   134
        for (n <- List(1, 2)) Isabelle_System.copy_file(patch(n, source = true), patch(n))
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   135
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   136
        if (load_more.nonEmpty) {
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   137
          val bad = load_more.filter(path => !(hol_light_dir + path).is_file)
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   138
          if (bad.nonEmpty) error("Bad HOL Light files: " + bad.mkString(", "))
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   139
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   140
          val more = load_more.map(path => "needs " + path + ";; ").mkString("+", "", "")
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   141
          File.change_lines(patch(1), strict = true)(_.map(line =>
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   142
            if (line == "+(*LOAD MORE*)") more else line))
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   143
        }
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   144
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   145
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   146
        /* export stages */
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   147
81917
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   148
        def run(n: Int, lines: String*): Unit = {
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   149
          val title = "stage " + n
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   150
          if (n > 0) progress.echo("Running " + title + " ...")
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   151
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   152
          val start = Time.now()
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   153
          progress.bash(cat_lines("set -e" :: opam_env :: lines.toList),
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   154
            cwd = hol_light_dir, echo = progress.verbose).check.timing
81917
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   155
          val elapsed = Time.now() - start
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   156
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   157
          if (n > 0) {
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   158
            progress.echo("Finished " + title + " (" + elapsed.message_hms + " elapsed time)")
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   159
          }
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   160
        }
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   161
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   162
        run(0, "make")
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   163
        run(1,
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   164
          "patch -p1 < " + File.bash_path(patch(1)),
81917
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   165
          "./ocaml-hol -I +compiler-libs stage1.ml")
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   166
        run(2,
81918
deb6cb34a37f clarified patches;
wenzelm
parents: 81917
diff changeset
   167
          "patch -p1 < " + File.bash_path(patch(2)),
81917
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   168
          "export MAXTMS=10000",
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   169
          "./ocaml-hol -I +compiler-libs stage2.ml")
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   170
        run(3,
50cd5037aff7 more explicit stages, with timing messages;
wenzelm
parents: 81916
diff changeset
   171
          "> maps.lst",
81920
8d5989ab1e42 clarified compression;
wenzelm
parents: 81918
diff changeset
   172
          File.bash_path(platform_dir + offline_exe) + " proofs",
8d5989ab1e42 clarified compression;
wenzelm
parents: 81918
diff changeset
   173
          "zstd -8 proofs")
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   174
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   175
        val bundle_dir = Isabelle_System.make_directory(component_dir.path + Path.explode("bundle"))
81923
02b4ae06974d more complete bundle;
wenzelm
parents: 81922
diff changeset
   176
        Isabelle_System.copy_file(hol_light_dir + Path.explode("facts.lst"), bundle_dir)
81920
8d5989ab1e42 clarified compression;
wenzelm
parents: 81918
diff changeset
   177
        Isabelle_System.copy_file(hol_light_dir + Path.explode("proofs.zst"), bundle_dir)
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   178
      }
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   179
    }
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   180
  }
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   181
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   182
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   183
  /* Isabelle tool wrapper */
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   184
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   185
  val isabelle_tool =
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   186
    Isabelle_Tool("component_hol_light_import", "build Isabelle component for HOL Light import",
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   187
      Scala_Project.here,
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   188
      { args =>
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   189
        var target_dir = Path.current
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   190
        var load_more = List.empty[Path]
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   191
        var only_offline = false
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   192
        var hol_light_url = default_hol_light_url
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   193
        var hol_light_rev = default_hol_light_rev
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   194
        var verbose = false
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   195
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   196
        val getopts = Getopts("""
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   197
Usage: isabelle component_hol_light_import [OPTIONS]
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   198
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   199
  Options are:
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   200
    -D DIR       target directory (default ".")
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   201
    -L PATH      load additional HOL Light files, after "hol.ml"
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   202
    -O           only build the "offline" tool
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   203
    -U URL       git URL for original HOL Light repository, default:
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   204
                 """ + default_hol_light_url + """
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   205
    -r REV       revision or branch to checkout HOL Light (default: """ +
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   206
                    default_hol_light_rev + """)
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   207
    -v           verbose
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   208
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   209
  Build Isabelle component for HOL Light import. For example:
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   210
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   211
    isabelle component_hol_light_import -L Logic/make.ml
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   212
    isabelle component_hol_light_import -L 100/thales.ml -L 100/ceva.ml
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   213
""",
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   214
          "D:" -> (arg => target_dir = Path.explode(arg)),
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   215
          "L:" -> (arg => load_more = load_more ::: List(Path.explode(arg))),
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   216
          "O" -> (_ => only_offline = true),
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   217
          "U:" -> (arg => hol_light_url = arg),
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   218
          "r:" -> (arg => hol_light_rev = arg),
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   219
          "v" -> (_ => verbose = true))
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   220
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   221
        val more_args = getopts(args)
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   222
        if (more_args.nonEmpty) getopts.usage()
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   223
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   224
        val progress = new Console_Progress(verbose = verbose)
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   225
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   226
        build_hol_light_import(
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   227
          only_offline = only_offline, progress = progress, target_dir = target_dir,
81924
61b711122061 allow to load additional HOL Light files, after "hol.ml";
wenzelm
parents: 81923
diff changeset
   228
          load_more = load_more, hol_light_url = hol_light_url, hol_light_rev = hol_light_rev)
81834
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   229
      })
9e25f6e2748c reproducible construction of HOL Light export bundle;
wenzelm
parents:
diff changeset
   230
}