src/Pure/Admin/component_cvc5.scala
author wenzelm
Tue, 11 Jul 2023 12:12:21 +0200
changeset 78300 ab95c9f2d55c
parent 78158 8b5a2e4b16d4
child 79750 f8fb4384180e
permissions -rw-r--r--
tuned signature;
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: 76548
diff changeset
     1
/*  Title:      Pure/Admin/component_cvc5.scala
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     3
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     4
Build Isabelle component for cvc5. See also:
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     5
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     6
  - https://cvc5.github.io/
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     7
  - https://github.com/cvc5/cvc5
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     8
*/
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     9
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    10
package isabelle
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    11
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    12
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 76548
diff changeset
    13
object Component_CVC5 {
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    14
  /* platform information */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    15
78300
ab95c9f2d55c tuned signature;
wenzelm
parents: 78158
diff changeset
    16
  sealed case class Download_Platform(platform_name: String, download_name: String) {
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    17
    def is_windows: Boolean = platform_name.endsWith("-windows")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    18
  }
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    19
78300
ab95c9f2d55c tuned signature;
wenzelm
parents: 78158
diff changeset
    20
  val platforms: List[Download_Platform] =
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    21
    List(
78300
ab95c9f2d55c tuned signature;
wenzelm
parents: 78158
diff changeset
    22
      Download_Platform("arm64-darwin", "cvc5-macOS-arm64"),
ab95c9f2d55c tuned signature;
wenzelm
parents: 78158
diff changeset
    23
      Download_Platform("x86_64-darwin", "cvc5-macOS"),
ab95c9f2d55c tuned signature;
wenzelm
parents: 78158
diff changeset
    24
      Download_Platform("x86_64-linux", "cvc5-Linux"),
ab95c9f2d55c tuned signature;
wenzelm
parents: 78158
diff changeset
    25
      Download_Platform("x86_64-windows", "cvc5-Win64.exe"))
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    26
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    27
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    28
  /* build cvc5 */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    29
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    30
  val default_url = "https://github.com/cvc5/cvc5/releases/download"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    31
  val default_version = "1.0.2"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    32
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    33
  def build_cvc5(
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    34
    base_url: String = default_url,
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    35
    version: String = default_version,
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    36
    target_dir: Path = Path.current,
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    37
    progress: Progress = new Progress
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    38
  ): Unit = {
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    39
    /* component name */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    40
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    41
    val component = "cvc5-" + version
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 76477
diff changeset
    42
    val component_dir =
76547
9fe5d8c70352 tuned signature;
wenzelm
parents: 76518
diff changeset
    43
      Components.Directory(target_dir + Path.basic(component)).create(progress = progress)
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    44
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    45
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    46
    /* download executables */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    47
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    48
    for (platform <- platforms) {
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    49
      val url = base_url + "/cvc5-" + version + "/" + platform.download_name
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    50
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 76477
diff changeset
    51
      val platform_dir = component_dir.path + Path.explode(platform.platform_name)
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    52
      val platform_exe = platform_dir + Path.explode("cvc5").exe_if(platform.is_windows)
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    53
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    54
      Isabelle_System.make_directory(platform_dir)
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    55
      Isabelle_System.download_file(url, platform_exe, progress = progress)
78158
8b5a2e4b16d4 tuned signature;
wenzelm
parents: 77566
diff changeset
    56
      File.set_executable(platform_exe)
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    57
    }
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    58
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    59
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    60
    /* settings */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    61
76548
0af64cc2eee9 tuned signature;
wenzelm
parents: 76547
diff changeset
    62
    component_dir.write_settings("""
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    63
CVC5_HOME="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}}"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    64
CVC5_VERSION=""" + Bash.string(version) + """
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    65
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    66
CVC5_SOLVER="$CVC5_HOME/cvc5"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    67
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    68
if [ -e "$CVC5_HOME" ]
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    69
then
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    70
  CVC5_INSTALLED="yes"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    71
fi
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    72
""")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    73
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    74
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    75
    /* README */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    76
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 76477
diff changeset
    77
    File.write(component_dir.README,
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    78
      """This distribution of cvc5 was assembled from the official downloads
76018
8e796c204b87 tuned output;
wenzelm
parents: 76017
diff changeset
    79
from """ + base_url + """ for 64bit macOS,
8e796c204b87 tuned output;
wenzelm
parents: 76017
diff changeset
    80
Linux, and Windows. There is native support for macOS ARM64, but
8e796c204b87 tuned output;
wenzelm
parents: 76017
diff changeset
    81
Linux ARM64 is missing.
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    82
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    83
The oldest supported version of macOS is 10.14 Mojave.
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    84
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    85
The downloaded files were renamed and made executable.
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    86
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    87
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    88
        Makarius
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    89
        """ + Date.Format.date(Date.now()) + "\n")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    90
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    91
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    92
    /* AUTHORS and COPYING */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    93
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    94
    // download "latest" versions as reasonable approximation
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    95
    def raw_download(name: String): Unit =
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    96
      Isabelle_System.download_file("https://raw.githubusercontent.com/cvc5/cvc5/main/" + name,
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 76477
diff changeset
    97
        component_dir.path + Path.explode(name))
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    98
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    99
    raw_download("AUTHORS")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   100
    raw_download("COPYING")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   101
  }
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   102
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   103
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   104
  /* Isabelle tool wrapper */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   105
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   106
  val isabelle_tool =
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 76548
diff changeset
   107
    Isabelle_Tool("component_cvc5", "build component for cvc5", Scala_Project.here,
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   108
      { args =>
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   109
        var target_dir = Path.current
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   110
        var base_url = default_url
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   111
        var version = default_version
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   112
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   113
        val getopts = Getopts("""
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 76548
diff changeset
   114
Usage: isabelle component_cvc5 [OPTIONS]
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   115
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   116
  Options are:
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   117
    -D DIR       target directory (default ".")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   118
    -U URL       download URL (default: """" + default_url + """")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   119
    -V VERSION   version (default: """" + default_version + """")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   120
76477
6e68ec0fdc48 tuned message;
wenzelm
parents: 76183
diff changeset
   121
  Build component for cvc5 solver.
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   122
""",
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   123
          "D:" -> (arg => target_dir = Path.explode(arg)),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   124
          "U:" -> (arg => base_url = arg),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   125
          "V:" -> (arg => version = arg))
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   126
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   127
        val more_args = getopts(args)
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   128
        if (more_args.nonEmpty) getopts.usage()
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   129
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   130
        val progress = new Console_Progress()
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   131
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   132
        build_cvc5(base_url = base_url, version = version, target_dir = target_dir,
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   133
          progress = progress)
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   134
      })
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   135
}