support for platform family "linux_arm";
authorwenzelm
Thu, 06 May 2021 23:09:19 +0200
changeset 73893 f3a356c64193
parent 73892 6945ac084763
child 73894 a6a9162f3ec1
support for platform family "linux_arm";
Admin/components/bundled-linux_arm
src/Pure/Admin/build_release.scala
src/Pure/Admin/components.scala
src/Pure/System/platform.scala
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/components/bundled-linux_arm	Thu May 06 23:09:19 2021 +0200
@@ -0,0 +1,2 @@
+#additional components to be bundled for release
+Isabelle_app-20210126
--- a/src/Pure/Admin/build_release.scala	Thu May 06 22:13:30 2021 +0200
+++ b/src/Pure/Admin/build_release.scala	Thu May 06 23:09:19 2021 +0200
@@ -76,6 +76,8 @@
 
     def bundle_info(platform: Platform.Family.Value): Bundle_Info =
       platform match {
+        case Platform.Family.linux_arm =>
+          Bundle_Info(platform, "Linux (ARM)", dist_name + "_linux_arm.tar.gz")
         case Platform.Family.linux => Bundle_Info(platform, "Linux", dist_name + "_linux.tar.gz")
         case Platform.Family.macos => Bundle_Info(platform, "macOS", dist_name + "_macos.tar.gz")
         case Platform.Family.windows => Bundle_Info(platform, "Windows", dist_name + ".exe")
@@ -175,7 +177,7 @@
   {
     val catalogs =
       List("main", "bundled").map((_, new Bundled())) :::
-      default_platform_families.flatMap(platform =>
+      Platform.Family.list.flatMap(platform =>
         List(platform.toString, "bundled-" + platform.toString).
           map((_, new Bundled(platform = Some(platform)))))
 
@@ -322,7 +324,7 @@
 
     val component_dir = isabelle_target + Path.explode("contrib/Isabelle_app")
     Isabelle_System.move_file(
-      component_dir + Path.explode(Platform.standard_platform(platform)) + Path.explode("Isabelle"),
+      component_dir + Path.explode(Platform.Family.standard(platform)) + Path.explode("Isabelle"),
       isabelle_target + Path.explode(isabelle_name))
     Isabelle_System.rm_tree(component_dir)
   }
@@ -389,9 +391,6 @@
 
   /* main */
 
-  private val default_platform_families: List[Platform.Family.Value] =
-    List(Platform.Family.linux, Platform.Family.windows, Platform.Family.macos)
-
   def use_release_archive(
     context: Release_Context,
     archive: Release_Archive,
@@ -492,7 +491,7 @@
     options: Options,
     context: Release_Context,
     afp_rev: String = "",
-    platform_families: List[Platform.Family.Value] = default_platform_families,
+    platform_families: List[Platform.Family.Value] = Platform.Family.list,
     more_components: List[Path] = Nil,
     website: Option[Path] = None,
     build_sessions: List[String] = Nil,
@@ -608,7 +607,7 @@
         // application bundling
 
         platform match {
-          case Platform.Family.linux =>
+          case Platform.Family.linux_arm | Platform.Family.linux =>
             File.change(isabelle_target + jedit_options,
               _.replaceAll("jedit_reset_font_size : int =.*", "jedit_reset_font_size : int = 24"))
 
@@ -625,10 +624,9 @@
 
             make_isabelle_app(platform, isabelle_target, isabelle_name, jdk_component, classpath)
 
-            val archive_name = isabelle_name + "_linux.tar.gz"
-            progress.echo("Packaging " + archive_name + " ...")
+            progress.echo("Packaging " + bundle_info.name + " ...")
             execute_tar(tmp_dir,
-              "-czf " + File.bash_path(context.dist_dir + Path.explode(archive_name)) + " " +
+              "-czf " + File.bash_path(context.dist_dir + bundle_info.path) + " " +
               Bash.string(isabelle_name))
 
 
@@ -661,15 +659,14 @@
 
             // application archive
 
-            val archive_name = isabelle_name + "_macos.tar.gz"
-            progress.echo("Packaging " + archive_name + " ...")
+            progress.echo("Packaging " + bundle_info.name + " ...")
 
             val isabelle_app = Path.explode(isabelle_name + ".app")
             Isabelle_System.move_file(tmp_dir + Path.explode(isabelle_name),
               tmp_dir + isabelle_app)
 
             execute_tar(tmp_dir,
-              "-czf " + File.bash_path(context.dist_dir + Path.explode(archive_name)) + " " +
+              "-czf " + File.bash_path(context.dist_dir + bundle_info.path) + " " +
               File.bash_path(isabelle_app))
 
 
@@ -689,7 +686,7 @@
               java_options, line_ending = "\r\n")
 
             val isabelle_xml = Path.explode("isabelle.xml")
-            val isabelle_exe = Path.explode(isabelle_name + ".exe")
+            val isabelle_exe = bundle_info.path
 
             File.write(tmp_dir + isabelle_xml,
               File.read(app_template + isabelle_xml)
@@ -858,7 +855,7 @@
       var parallel_jobs = 1
       var build_library = false
       var options = Options.init()
-      var platform_families = default_platform_families
+      var platform_families = Platform.Family.list
       var rev = ""
 
       val getopts = Getopts("""
@@ -877,7 +874,7 @@
     -j INT       maximum number of parallel jobs (default 1)
     -l           build library
     -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
-    -p NAMES     platform families (default: """ + default_platform_families.mkString(",") + """)
+    -p NAMES     platform families (default: """ + Platform.Family.list.mkString(",") + """)
     -r REV       Mercurial changeset id (default: ARCHIVE or RELEASE or tip)
 
   Build Isabelle release in base directory, using the local repository clone.
--- a/src/Pure/Admin/components.scala	Thu May 06 22:13:30 2021 +0200
+++ b/src/Pure/Admin/components.scala	Thu May 06 23:09:19 2021 +0200
@@ -77,19 +77,21 @@
     }
   }
 
+  private val platforms_family: Map[Platform.Family.Value, Set[String]] =
+    Map(
+      Platform.Family.linux_arm -> Set("arm64-linux", "arm64_32-linux"),
+      Platform.Family.linux -> Set("x86_64-linux", "x86_64_32-linux"),
+      Platform.Family.macos ->
+        Set("arm64-darwin", "arm64_32-darwin", "x86_64-darwin", "x86_64_32-darwin"),
+      Platform.Family.windows ->
+        Set("x86_64-cygwin", "x86_64-windows", "x86_64_32-windows", "x86-windows"))
+
+  private val platforms_all: Set[String] =
+    Set("x86-linux", "x86-cygwin") ++ platforms_family.iterator.flatMap(_._2)
+
   def purge(dir: Path, platform: Platform.Family.Value): Unit =
   {
-    val purge_default = Set("x86-linux", "x86-cygwin", "arm64-linux")
-    val purge_linux = Set("x86_64-linux", "x86_64_32-linux")
-    val purge_macos = Set("arm64-darwin", "x86_64-darwin", "x86_64_32-darwin")
-    val purge_windows = Set("x86_64-cygwin", "x86_64-windows", "x86_64_32-windows", "x86-windows")
-
-    val purge_set =
-      platform match {
-        case Platform.Family.linux => purge_default ++ purge_macos ++ purge_windows
-        case Platform.Family.macos => purge_default ++ purge_linux ++ purge_windows
-        case Platform.Family.windows => purge_default ++ purge_linux ++ purge_macos
-      }
+    val purge_set = platforms_all -- platforms_family(platform)
 
     File.find_files(dir.file,
       (file: JFile) => file.isDirectory && purge_set(file.getName),
--- a/src/Pure/System/platform.scala	Thu May 06 22:13:30 2021 +0200
+++ b/src/Pure/System/platform.scala	Thu May 06 23:09:19 2021 +0200
@@ -16,15 +16,19 @@
   val is_windows: Boolean = System.getProperty("os.name", "").startsWith("Windows")
   val is_unix: Boolean = is_linux || is_macos
 
+  def is_arm: Boolean = cpu_arch.startsWith("arm")
+
   def family: Family.Value =
-    if (is_linux) Family.linux
+    if (is_linux && is_arm) Family.linux_arm
+    else if (is_linux) Family.linux
     else if (is_macos) Family.macos
     else if (is_windows) Family.windows
     else error("Failed to determine current platform family")
 
   object Family extends Enumeration
   {
-    val linux, macos, windows = Value
+    val linux_arm, linux, macos, windows = Value
+    val list: List[Value] = List(linux_arm, linux, windows, macos)
 
     def unapply(name: String): Option[Value] =
       try { Some(withName(name)) }
@@ -32,15 +36,15 @@
 
     def parse(name: String): Value =
       unapply(name) getOrElse error("Bad platform family: " + quote(name))
+
+    def standard(platform: Value): String =
+      if (platform == linux_arm) "arm64-linux"
+      else if (platform == linux) "x86_64-linux"
+      else if (platform == macos) "x86_64-darwin"
+      else if (platform == windows) "x86_64-cygwin"
+      else error("Unknown platform family " + quote(platform.toString))
   }
 
-  def standard_platform(platform: Family.Value): String =
-    platform match {
-      case Platform.Family.linux => "x86_64-linux"
-      case Platform.Family.macos => "x86_64-darwin"
-      case Platform.Family.windows => "x86_64-cygwin"
-    }
-
 
   /* platform identifiers */