src/Pure/Admin/component_e.scala
author wenzelm
Thu, 28 Mar 2024 11:35:39 +0100
changeset 80049 b525f783b784
parent 79754 9686af7b947a
child 80153 8e3730b527e9
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 77510
diff changeset
     1
/*  Title:      Pure/Admin/component_e.scala
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     3
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     4
Build Isabelle E prover component from official downloads.
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     5
*/
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     6
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     7
package isabelle
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     8
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     9
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 77510
diff changeset
    10
object Component_E {
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    11
  /* build E prover */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    12
79752
788f11af9822 provide e-3.0.03 on all platforms, including arm64-linux and arm64-darwin --- still inactive;
wenzelm
parents: 79629
diff changeset
    13
  val default_version = "3.0.03"
72408
2daa5f549687 misc tuning;
wenzelm
parents: 72406
diff changeset
    14
  val default_download_url = "https://wwwlehre.dhbw-stuttgart.de/~sschulz/WORK/E_DOWNLOAD"
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    15
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    16
  def build_e(
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    17
    version: String = default_version,
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    18
    download_url: String = default_download_url,
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    19
    progress: Progress = new Progress,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74359
diff changeset
    20
    target_dir: Path = Path.current
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74359
diff changeset
    21
  ): Unit = {
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
    22
    Isabelle_System.with_tmp_dir("build") { tmp_dir =>
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    23
      /* component */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    24
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    25
      val component_name = "e-" + version
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 75394
diff changeset
    26
      val component_dir =
76547
9fe5d8c70352 tuned signature;
wenzelm
parents: 76541
diff changeset
    27
        Components.Directory(target_dir + Path.basic(component_name)).create(progress = progress)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    28
80049
wenzelm
parents: 79754
diff changeset
    29
      val platform_name = Isabelle_Platform.self.ISABELLE_PLATFORM(apple = true)
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 75394
diff changeset
    30
      val platform_dir =
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 75394
diff changeset
    31
        Isabelle_System.make_directory(component_dir.path + Path.basic(platform_name))
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    32
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    33
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    34
      /* download source */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    35
72410
wenzelm
parents: 72408
diff changeset
    36
      val archive_url = download_url + "/V_" + version + "/E.tgz"
wenzelm
parents: 72408
diff changeset
    37
      val archive_path = tmp_dir + Path.explode("E.tgz")
73566
4e6b31ed7197 clarified signature: avoid tmp file;
wenzelm
parents: 73340
diff changeset
    38
      Isabelle_System.download_file(archive_url, archive_path, progress = progress)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    39
76540
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    40
      Isabelle_System.extract(archive_path, tmp_dir)
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    41
      val source_dir = File.get_dir(tmp_dir, title = archive_url)
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    42
76541
3706b88035d2 more direct target directory;
wenzelm
parents: 76540
diff changeset
    43
      Isabelle_System.extract(archive_path, component_dir.src, strip = true)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    44
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    45
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    46
      /* build */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    47
72440
d0ba71b3297e tuned messages;
wenzelm
parents: 72416
diff changeset
    48
      progress.echo("Building E prover for " + platform_name + " ...")
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    49
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74359
diff changeset
    50
      val build_options = {
76540
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    51
        val result = Isabelle_System.bash("./configure --help", cwd = source_dir.file)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    52
        if (result.check.out.containsSlice("--enable-ho")) " --enable-ho" else ""
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    53
      }
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    54
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    55
      val build_script = "./configure" + build_options + " && make"
76540
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    56
      Isabelle_System.bash(build_script, cwd = source_dir.file,
77510
f5d6cd98b16a clarified signature: manage "verbose" flag via "progress";
wenzelm
parents: 76548
diff changeset
    57
        progress_stdout = progress.echo(_, verbose = true),
f5d6cd98b16a clarified signature: manage "verbose" flag via "progress";
wenzelm
parents: 76548
diff changeset
    58
        progress_stderr = progress.echo(_, verbose = true)).check
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    59
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    60
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    61
      /* install */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    62
76540
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    63
      Isabelle_System.copy_file(source_dir + Path.basic("COPYING"), component_dir.LICENSE)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    64
72406
a49be9fc83c3 discontinued unused eproof_ram (actually absent in version 2.5);
wenzelm
parents: 72405
diff changeset
    65
      val install_files = List("epclextract", "eprover", "eprover-ho")
72364
374aafa52e92 clarified installed files;
wenzelm
parents: 72363
diff changeset
    66
      for (name <- install_files ::: install_files.map(_ + ".exe")) {
76540
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    67
        val path = source_dir + Path.basic("PROVER") + Path.basic(name)
73317
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 72763
diff changeset
    68
        if (path.is_file) Isabelle_System.copy_file(path, platform_dir)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    69
      }
72364
374aafa52e92 clarified installed files;
wenzelm
parents: 72363
diff changeset
    70
      Isabelle_System.bash("if [ -f eprover-ho ]; then mv eprover-ho eprover; fi",
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    71
        cwd = platform_dir.file).check
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    72
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    73
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    74
      /* settings */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    75
76548
0af64cc2eee9 tuned signature;
wenzelm
parents: 76547
diff changeset
    76
      component_dir.write_settings("""
79752
788f11af9822 provide e-3.0.03 on all platforms, including arm64-linux and arm64-darwin --- still inactive;
wenzelm
parents: 79629
diff changeset
    77
E_HOME="$COMPONENT/${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}"
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    78
E_VERSION=""" + quote(version) + """
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    79
""")
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    80
76548
0af64cc2eee9 tuned signature;
wenzelm
parents: 76547
diff changeset
    81
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    82
      /* README */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    83
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 75394
diff changeset
    84
      File.write(component_dir.README,
72410
wenzelm
parents: 72408
diff changeset
    85
        "This is E prover " + version + " from\n" + archive_url + """
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    86
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    87
The distribution has been built like this:
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    88
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    89
    cd src && """ + build_script + """
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    90
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    91
Only a few executables from PROVERS/ have been moved to the platform-specific
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    92
Isabelle component directory: x86_64-linux etc.
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    93
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    94
72444
2d9a70b85009 tuned whitespace;
wenzelm
parents: 72440
diff changeset
    95
        Makarius
2d9a70b85009 tuned whitespace;
wenzelm
parents: 72440
diff changeset
    96
        """ + Date.Format.date(Date.now()) + "\n")
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
    97
    }
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    98
}
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    99
79629
4d81c0391da2 tuned comments;
wenzelm
parents: 77566
diff changeset
   100
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   101
  /* Isabelle tool wrapper */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   102
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   103
  val isabelle_tool =
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 77510
diff changeset
   104
    Isabelle_Tool("component_e", "build prover component from source distribution", Scala_Project.here,
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   105
      { args =>
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   106
        var target_dir = Path.current
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   107
        var version = default_version
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   108
        var download_url = default_download_url
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   109
        var verbose = false
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   110
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   111
        val getopts = Getopts("""
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 77510
diff changeset
   112
Usage: isabelle component_e [OPTIONS]
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   113
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   114
  Options are:
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   115
    -D DIR       target directory (default ".")
72416
783c3a47d57c tuned message;
wenzelm
parents: 72410
diff changeset
   116
    -U URL       download URL
72396
63e83aaec7a8 Fix formatting of default value in help message of "build_e" component.
desharna
parents: 72395
diff changeset
   117
                 (default: """" + default_download_url + """")
72416
783c3a47d57c tuned message;
wenzelm
parents: 72410
diff changeset
   118
    -V VERSION   version (default: """ + default_version + """)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   119
    -v           verbose
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   120
72408
2daa5f549687 misc tuning;
wenzelm
parents: 72406
diff changeset
   121
  Build prover component from the specified source distribution.
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   122
""",
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   123
          "D:" -> (arg => target_dir = Path.explode(arg)),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   124
          "U:" -> (arg => download_url = arg),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   125
          "V:" -> (arg => version = arg),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   126
          "v" -> (_ => verbose = true))
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   127
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   128
        val more_args = getopts(args)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   129
        if (more_args.nonEmpty) getopts.usage()
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   130
77510
f5d6cd98b16a clarified signature: manage "verbose" flag via "progress";
wenzelm
parents: 76548
diff changeset
   131
        val progress = new Console_Progress(verbose = verbose)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   132
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   133
        build_e(version = version, download_url = download_url,
77510
f5d6cd98b16a clarified signature: manage "verbose" flag via "progress";
wenzelm
parents: 76548
diff changeset
   134
          progress = progress, target_dir = target_dir)
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   135
      })
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   136
}