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