src/Pure/Admin/build_e.scala
author wenzelm
Sat, 04 Dec 2021 12:38:51 +0100
changeset 74876 e8935405f082
parent 74359 8cbe519c2085
child 75393 87ebf5a50283
permissions -rw-r--r--
merged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Admin/build_e.scala
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
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    10
object Build_E
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    11
{
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    12
  /* build E prover */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    13
74359
8cbe519c2085 update to e-2.6, following Martin Desharnais;
wenzelm
parents: 73566
diff changeset
    14
  val default_version = "2.6"
72408
2daa5f549687 misc tuning;
wenzelm
parents: 72406
diff changeset
    15
  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
    16
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    17
  def build_e(
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    18
    version: String = default_version,
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    19
    download_url: String = default_download_url,
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    20
    verbose: Boolean = false,
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    21
    progress: Progress = new Progress,
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 73317
diff changeset
    22
    target_dir: Path = Path.current): Unit =
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    23
  {
72408
2daa5f549687 misc tuning;
wenzelm
parents: 72406
diff changeset
    24
    Isabelle_System.with_tmp_dir("build")(tmp_dir =>
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    25
    {
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    26
      /* component */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    27
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    28
      val component_name = "e-" + version
72377
c7741f767e3e clarified signature;
wenzelm
parents: 72376
diff changeset
    29
      val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component_name))
c7741f767e3e clarified signature;
wenzelm
parents: 72376
diff changeset
    30
      progress.echo("Component " + component_dir)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    31
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    32
      val platform_name =
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    33
        proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64"))
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    34
          .getOrElse(error("No 64bit platform"))
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    35
72376
04bce3478688 clarified signature;
wenzelm
parents: 72375
diff changeset
    36
      val platform_dir = Isabelle_System.make_directory(component_dir + Path.basic(platform_name))
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    37
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    38
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    39
      /* download source */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    40
72410
wenzelm
parents: 72408
diff changeset
    41
      val archive_url = download_url + "/V_" + version + "/E.tgz"
wenzelm
parents: 72408
diff changeset
    42
      val archive_path = tmp_dir + Path.explode("E.tgz")
73566
4e6b31ed7197 clarified signature: avoid tmp file;
wenzelm
parents: 73340
diff changeset
    43
      Isabelle_System.download_file(archive_url, archive_path, progress = progress)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    44
72410
wenzelm
parents: 72408
diff changeset
    45
      Isabelle_System.bash("tar xzf " + archive_path, cwd = tmp_dir.file).check
wenzelm
parents: 72408
diff changeset
    46
      Isabelle_System.bash("tar xzf " + archive_path + " && mv E src", cwd = component_dir.file).check
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    47
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    48
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    49
      /* build */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    50
72440
d0ba71b3297e tuned messages;
wenzelm
parents: 72416
diff changeset
    51
      progress.echo("Building E prover for " + platform_name + " ...")
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    52
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    53
      val build_dir = tmp_dir + Path.basic("E")
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    54
      val build_options =
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    55
      {
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    56
        val result = Isabelle_System.bash("./configure --help", cwd = build_dir.file)
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    57
        if (result.check.out.containsSlice("--enable-ho")) " --enable-ho" else ""
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    58
      }
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
      val build_script = "./configure" + build_options + " && make"
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    61
      Isabelle_System.bash(build_script,
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    62
        cwd = build_dir.file,
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    63
        progress_stdout = progress.echo_if(verbose, _),
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    64
        progress_stderr = progress.echo_if(verbose, _)).check
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    65
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    66
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    67
      /* install */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    68
73317
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 72763
diff changeset
    69
      Isabelle_System.copy_file(build_dir + Path.basic("COPYING"),
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 72763
diff changeset
    70
        component_dir + Path.basic("LICENSE"))
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    71
72406
a49be9fc83c3 discontinued unused eproof_ram (actually absent in version 2.5);
wenzelm
parents: 72405
diff changeset
    72
      val install_files = List("epclextract", "eprover", "eprover-ho")
72364
374aafa52e92 clarified installed files;
wenzelm
parents: 72363
diff changeset
    73
      for (name <- install_files ::: install_files.map(_ + ".exe")) {
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    74
        val path = build_dir + Path.basic("PROVER") + Path.basic(name)
73317
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 72763
diff changeset
    75
        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
    76
      }
72364
374aafa52e92 clarified installed files;
wenzelm
parents: 72363
diff changeset
    77
      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
    78
        cwd = platform_dir.file).check
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
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    81
      /* settings */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    82
72376
04bce3478688 clarified signature;
wenzelm
parents: 72375
diff changeset
    83
      val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc"))
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    84
      File.write(etc_dir + Path.basic("settings"),
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    85
        """# -*- shell-script -*- :mode=shellscript:
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
E_HOME="$COMPONENT/$ISABELLE_PLATFORM64"
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    88
E_VERSION=""" + quote(version) + """
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    89
""")
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
      /* README */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    92
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    93
      File.write(component_dir + Path.basic("README"),
72410
wenzelm
parents: 72408
diff changeset
    94
        "This is E prover " + version + " from\n" + archive_url + """
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    95
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    96
The distribution has been built like this:
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    97
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    98
    cd src && """ + build_script + """
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
    99
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   100
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
   101
Isabelle component directory: x86_64-linux etc.
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
72444
2d9a70b85009 tuned whitespace;
wenzelm
parents: 72440
diff changeset
   104
        Makarius
2d9a70b85009 tuned whitespace;
wenzelm
parents: 72440
diff changeset
   105
        """ + Date.Format.date(Date.now()) + "\n")
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   106
    })
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   107
}
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   108
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   109
  /* Isabelle tool wrapper */
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   110
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   111
  val isabelle_tool =
72763
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72444
diff changeset
   112
    Isabelle_Tool("build_e", "build prover component from source distribution", Scala_Project.here,
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   113
    args =>
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   114
    {
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   115
      var target_dir = Path.current
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   116
      var version = default_version
72395
5fac6c50e6d5 tuned signature;
wenzelm
parents: 72378
diff changeset
   117
      var download_url = default_download_url
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   118
      var verbose = false
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   119
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   120
      val getopts = Getopts("""
72367
d3069e7e1175 proper usage;
wenzelm
parents: 72364
diff changeset
   121
Usage: isabelle build_e [OPTIONS]
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   122
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   123
  Options are:
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   124
    -D DIR       target directory (default ".")
72416
783c3a47d57c tuned message;
wenzelm
parents: 72410
diff changeset
   125
    -U URL       download URL
72396
63e83aaec7a8 Fix formatting of default value in help message of "build_e" component.
desharna
parents: 72395
diff changeset
   126
                 (default: """" + default_download_url + """")
72416
783c3a47d57c tuned message;
wenzelm
parents: 72410
diff changeset
   127
    -V VERSION   version (default: """ + default_version + """)
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   128
    -v           verbose
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   129
72408
2daa5f549687 misc tuning;
wenzelm
parents: 72406
diff changeset
   130
  Build prover component from the specified source distribution.
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   131
""",
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   132
        "D:" -> (arg => target_dir = Path.explode(arg)),
72395
5fac6c50e6d5 tuned signature;
wenzelm
parents: 72378
diff changeset
   133
        "U:" -> (arg => download_url = arg),
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   134
        "V:" -> (arg => version = arg),
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   135
        "v" -> (_ => verbose = true))
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   136
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   137
      val more_args = getopts(args)
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   138
      if (more_args.nonEmpty) getopts.usage()
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   139
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   140
      val progress = new Console_Progress()
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   141
72405
c8e8e3e3d929 discontinued obsolete runepar.pl (see 4a3169d8885c);
wenzelm
parents: 72396
diff changeset
   142
      build_e(version = version, download_url = download_url,
72363
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   143
        verbose = verbose, progress = progress, target_dir = target_dir)
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   144
    })
fc5f10691147 build Isabelle E prover component from official downloads;
wenzelm
parents:
diff changeset
   145
}