update to mlton-20210117-2, which covers x86_64-linux, x86_64-darwin, arm64-darwin;
authorwenzelm
Thu, 21 Mar 2024 14:19:05 +0100
changeset 79951 84f2d481d6d7
parent 79950 82aaa0d8fc3b
child 79952 a2b06af75d3b
update to mlton-20210117-2, which covers x86_64-linux, x86_64-darwin, arm64-darwin;
Admin/components/components.sha1
Admin/components/main
NEWS
etc/build.props
etc/settings
src/Pure/Admin/component_mlton.scala
src/Pure/System/isabelle_tool.scala
--- a/Admin/components/components.sha1	Thu Mar 21 12:47:51 2024 +0100
+++ b/Admin/components/components.sha1	Thu Mar 21 14:19:05 2024 +0100
@@ -314,6 +314,7 @@
 5fb1a2d21b220d0e588790c0203ac87c10ed0870 minisat-2.2.1-1.tar.gz
 ae76bfaade3bf72ff6b2d3aafcd52fa45609fcd1 minisat-2.2.1.tar.gz
 59aa13f48685326995714cc6028aebb789e445e3 mlton-20210117-1.tar.gz
+7624509ba58b9b8231626a66eda571fba69f7cd3 mlton-20210117-2.tar.gz
 5d48b7163a68c18b691bedc1511364b0b103baeb mlton-20210117.tar.gz
 eda10c62da927a842c0a8881f726eac85e1cb4f7 naproche-20210122.tar.gz
 edcb517b7578db4eec1b6573b624f291776e11f6 naproche-20210124.tar.gz
--- a/Admin/components/main	Thu Mar 21 12:47:51 2024 +0100
+++ b/Admin/components/main	Thu Mar 21 14:19:05 2024 +0100
@@ -22,7 +22,7 @@
 lipics-3.1.3
 llncs-2.23
 minisat-2.2.1-1
-mlton-20210117-1
+mlton-20210117-2
 nunchaku-0.5
 opam-2.0.7
 pdfjs-2.14.305
--- a/NEWS	Thu Mar 21 12:47:51 2024 +0100
+++ b/NEWS	Thu Mar 21 14:19:05 2024 +0100
@@ -238,6 +238,11 @@
 component javamail (previously javax.mail) from jakarta 2.1.2
 using eclipse angus 2.0.2/2.0.1.
 
+* The MLton compiler has been bundled as Isabelle component, for
+x86_64-linux, x86_64-darwin, arm64-darwin. ISABELLE_MLTON_OPTIONS that
+work most of the time are provided by default, but this may have to be
+overridden (e.g. in $ISABELLE_HOME_USER/etc/settings).
+
 * Update to GHC stack 2.15.1 with support for all platforms, including
 ARM Linux and Apple Silicon.
 
--- a/etc/build.props	Thu Mar 21 12:47:51 2024 +0100
+++ b/etc/build.props	Thu Mar 21 14:19:05 2024 +0100
@@ -34,6 +34,7 @@
   src/Pure/Admin/component_lipics.scala \
   src/Pure/Admin/component_llncs.scala \
   src/Pure/Admin/component_minisat.scala \
+  src/Pure/Admin/component_mlton.scala \
   src/Pure/Admin/component_pdfjs.scala \
   src/Pure/Admin/component_polyml.scala \
   src/Pure/Admin/component_postgresql.scala \
--- a/etc/settings	Thu Mar 21 12:47:51 2024 +0100
+++ b/etc/settings	Thu Mar 21 14:19:05 2024 +0100
@@ -185,7 +185,5 @@
 ISABELLE_GNUPLOT="gnuplot"
 ISABELLE_FONTFORGE="fontforge"
 
-#ISABELLE_MLTON="/usr/bin/mlton"
-#ISABELLE_MLTON_OPTIONS="-pi-style npi"
 #ISABELLE_SMLNJ="/usr/bin/sml"
 #ISABELLE_SWIPL="/usr/bin/swipl"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/Admin/component_mlton.scala	Thu Mar 21 14:19:05 2024 +0100
@@ -0,0 +1,126 @@
+/*  Title:      Pure/Admin/component_mlton.scala
+    Author:     Makarius
+
+Build Isabelle component for MLton. See also:
+
+  - http://mlton.org
+  - https://projects.laas.fr/tina/software.php
+*/
+
+package isabelle
+
+
+object Component_MLton {
+  /* platform information */
+
+  sealed case class Download_Platform(platform_name: String, download_name: String) {
+    def download(base_url: String, version: String): String =
+      Url.append_path(base_url, version + "." + download_name)
+  }
+
+  val platforms: List[Download_Platform] =
+    List(
+      Download_Platform("arm64-darwin", "arm64-darwin-21.6-gmp-static.tgz"),
+      Download_Platform("x86_64-darwin", "amd64-darwin-16.7-gmp-static.tgz"),
+      Download_Platform("x86_64-linux", "amd64-linux-glibc2.19-gmp-static.tgz"))
+
+
+  /* build mlton */
+
+  val default_url = "https://projects.laas.fr/tina/software"
+  val default_version = "mlton-20210117-1"
+
+  def build_mlton(
+    base_url: String = default_url,
+    version: String = default_version,
+    target_dir: Path = Path.current,
+    progress: Progress = new Progress
+  ): Unit = {
+    val component_dir =
+      Components.Directory(target_dir + Path.basic(version)).create(progress = progress)
+
+
+    /* download executables */
+
+    for (platform <- platforms) {
+      Isabelle_System.with_tmp_dir("download") { download_dir =>
+        val download = platform.download(base_url, version)
+
+        val archive_name =
+          Url.get_base_name(download) getOrElse
+            error("Malformed download URL " + quote(download))
+        val archive_path = download_dir + Path.basic(archive_name)
+
+        val platform_dir = component_dir.path + Path.explode(platform.platform_name)
+        Isabelle_System.make_directory(platform_dir)
+
+        Isabelle_System.download_file(download, archive_path, progress = progress)
+        Isabelle_System.extract(archive_path, platform_dir, strip = true)
+        Isabelle_System.copy_file(platform_dir + Path.basic("LICENSE"), platform_dir.expand.dir)
+      }
+    }
+
+
+  /* settings */
+
+    component_dir.write_settings("""
+if [ -d "$COMPONENT/${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}" ]; then
+  ISABELLE_MLTON="$COMPONENT/${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}/bin/mlton"
+  case "$ISABELLE_PLATFORM_FAMILY" in
+    linux*)
+      ISABELLE_MLTON_OPTIONS="-pi-style npi"
+      ;;
+    *)
+      ISABELLE_MLTON_OPTIONS=""
+      ;;
+  esac
+fi
+""")
+
+
+    /* README */
+
+    File.write(component_dir.README,
+      """This distribution of MLton has been taken from the TINA project
+https://projects.laas.fr/tina/software.php using following downloads:""" +
+        platforms.map(_.download(base_url, version)).mkString("\n\n  ", "\n  ", "\n\n") +
+"""Some Isabelle platforms are unsupported, notably Windows and Linux ARM.
+
+
+        Makarius
+        """ + Date.Format.date(Date.now()) + "\n")
+  }
+
+
+  /* Isabelle tool wrapper */
+
+  val isabelle_tool =
+    Isabelle_Tool("component_mlton", "build component for MLton", Scala_Project.here,
+      { args =>
+        var target_dir = Path.current
+        var base_url = default_url
+        var version = default_version
+
+        val getopts = Getopts("""
+Usage: isabelle component_mlton [OPTIONS]
+
+  Options are:
+    -D DIR       target directory (default ".")
+    -U URL       download URL (default: """" + default_url + """")
+    -V VERSION   version (default: """" + default_version + """")
+
+  Build component for MLton compiler.
+""",
+          "D:" -> (arg => target_dir = Path.explode(arg)),
+          "U:" -> (arg => base_url = arg),
+          "V:" -> (arg => version = arg))
+
+        val more_args = getopts(args)
+        if (more_args.nonEmpty) getopts.usage()
+
+        val progress = new Console_Progress()
+
+        build_mlton(base_url = base_url, version = version, target_dir = target_dir,
+          progress = progress)
+      })
+}
--- a/src/Pure/System/isabelle_tool.scala	Thu Mar 21 12:47:51 2024 +0100
+++ b/src/Pure/System/isabelle_tool.scala	Thu Mar 21 14:19:05 2024 +0100
@@ -182,6 +182,7 @@
   Component_LIPIcs.isabelle_tool,
   Component_LLNCS.isabelle_tool,
   Component_Minisat.isabelle_tool,
+  Component_MLton.isabelle_tool,
   Component_PDFjs.isabelle_tool,
   Component_PolyML.isabelle_tool1,
   Component_PolyML.isabelle_tool2,