src/Pure/Admin/build_cvc5.scala
author wenzelm
Mon, 29 Aug 2022 19:25:55 +0200
changeset 76018 8e796c204b87
parent 76017 9ca22009c2d0
child 76183 8089593a364a
permissions -rw-r--r--
tuned output;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Admin/build_cvc5scala
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    13
object Build_CVC5 {
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    16
  sealed case class CVC5_Platform(platform_name: String, download_name: String) {
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    20
  val platforms: List[CVC5_Platform] =
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    21
    List(
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    22
      CVC5_Platform("arm64-darwin", "cvc5-macOS-arm64"),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    23
      CVC5_Platform("x86_64-darwin", "cvc5-macOS"),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    24
      CVC5_Platform("x86_64-linux", "cvc5-Linux"),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    25
      CVC5_Platform("x86_64-windows", "cvc5-Win64.exe"))
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    42
    val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component))
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    43
    progress.echo("Component " + component_dir)
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    51
      val platform_dir = component_dir + Path.explode(platform.platform_name)
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)
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    56
      File.set_executable(platform_exe, true)
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    62
    val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc"))
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    63
    File.write(etc_dir + Path.basic("settings"),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    64
      """# -*- shell-script -*- :mode=shellscript:
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_HOME="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}}"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    67
CVC5_VERSION=""" + Bash.string(version) + """
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    68
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    69
CVC5_SOLVER="$CVC5_HOME/cvc5"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    70
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    71
if [ -e "$CVC5_HOME" ]
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    72
then
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    73
  CVC5_INSTALLED="yes"
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    74
fi
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    75
""")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    76
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    77
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    78
    /* README */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    79
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    80
    File.write(component_dir + Path.basic("README"),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    81
      """This distribution of cvc5 was assembled from the official downloads
76018
8e796c204b87 tuned output;
wenzelm
parents: 76017
diff changeset
    82
from """ + base_url + """ for 64bit macOS,
8e796c204b87 tuned output;
wenzelm
parents: 76017
diff changeset
    83
Linux, and Windows. There is native support for macOS ARM64, but
8e796c204b87 tuned output;
wenzelm
parents: 76017
diff changeset
    84
Linux ARM64 is missing.
76017
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    85
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    86
The oldest supported version of macOS is 10.14 Mojave.
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
The downloaded files were renamed and made executable.
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    89
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
        Makarius
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    92
        """ + Date.Format.date(Date.now()) + "\n")
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    95
    /* AUTHORS and COPYING */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    96
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    97
    // download "latest" versions as reasonable approximation
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    98
    def raw_download(name: String): Unit =
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
    99
      Isabelle_System.download_file("https://raw.githubusercontent.com/cvc5/cvc5/main/" + name,
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   100
        component_dir + Path.explode(name))
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
    raw_download("AUTHORS")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   103
    raw_download("COPYING")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   104
  }
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
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   107
  /* Isabelle tool wrapper */
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   108
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   109
  val isabelle_tool =
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   110
    Isabelle_Tool("build_cvc5", "build component for cvc5", Scala_Project.here,
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   111
      { args =>
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   112
        var target_dir = Path.current
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   113
        var base_url = default_url
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   114
        var version = default_version
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
        val getopts = Getopts("""
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   117
Usage: isabelle build_cvc5 [OPTIONS]
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   118
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   119
  Options are:
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   120
    -D DIR       target directory (default ".")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   121
    -U URL       download URL (default: """" + default_url + """")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   122
    -V VERSION   version (default: """" + default_version + """")
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   123
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   124
  Build component for Java Chromium Embedded Framework.
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   125
""",
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   126
          "D:" -> (arg => target_dir = Path.explode(arg)),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   127
          "U:" -> (arg => base_url = arg),
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   128
          "V:" -> (arg => version = arg))
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 more_args = getopts(args)
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   131
        if (more_args.nonEmpty) getopts.usage()
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   132
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   133
        val progress = new Console_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
        build_cvc5(base_url = base_url, version = version, target_dir = target_dir,
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   136
          progress = progress)
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   137
      })
9ca22009c2d0 tool to build Isabelle component for cvc5;
wenzelm
parents:
diff changeset
   138
}