clarified modules;
authorwenzelm
Sat Dec 08 15:13:28 2018 +0100 (19 months ago)
changeset 6942691f46633bb4e
parent 69425 94f6ca69d983
child 69427 ff2f39a221d4
clarified modules;
src/Pure/Admin/components.scala
src/Pure/System/components.scala
src/Pure/build-jars
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/Pure/Admin/components.scala	Sat Dec 08 15:13:28 2018 +0100
     1.3 @@ -0,0 +1,90 @@
     1.4 +/*  Title:      Pure/Admin/components.scala
     1.5 +    Author:     Makarius
     1.6 +
     1.7 +Isabelle system components.
     1.8 +*/
     1.9 +
    1.10 +package isabelle
    1.11 +
    1.12 +
    1.13 +import java.io.{File => JFile}
    1.14 +
    1.15 +
    1.16 +object Components
    1.17 +{
    1.18 +  /* archive name */
    1.19 +
    1.20 +  object Archive
    1.21 +  {
    1.22 +    val suffix: String = ".tar.gz"
    1.23 +    def apply(name: String): String = name + suffix
    1.24 +    def unapply(archive: String): Option[String] = Library.try_unsuffix(suffix, archive)
    1.25 +    def get_name(archive: String): String =
    1.26 +      unapply(archive) getOrElse
    1.27 +        error("Bad component archive name (expecting .tar.gz): " + quote(archive))
    1.28 +  }
    1.29 +
    1.30 +
    1.31 +  /* component collections */
    1.32 +
    1.33 +  def admin(dir: Path): Path = dir + Path.explode("Admin/components")
    1.34 +
    1.35 +  def contrib(dir: Path = Path.current, name: String = ""): Path =
    1.36 +    dir + Path.explode("contrib") + Path.explode(name)
    1.37 +
    1.38 +  def unpack(dir: Path, archive: Path, progress: Progress = No_Progress): String =
    1.39 +  {
    1.40 +    val name = Archive.get_name(archive.file_name)
    1.41 +    progress.echo("Unpacking " + name)
    1.42 +    Isabelle_System.gnutar("-xzf " + File.bash_path(archive), dir = dir).check
    1.43 +    name
    1.44 +  }
    1.45 +
    1.46 +  def resolve(base_dir: Path, names: List[String],
    1.47 +    target_dir: Option[Path] = None,
    1.48 +    progress: Progress = No_Progress)
    1.49 +  {
    1.50 +    Isabelle_System.mkdirs(base_dir)
    1.51 +    for (name <- names) {
    1.52 +      val archive_name = Archive(name)
    1.53 +      val archive = base_dir + Path.explode(archive_name)
    1.54 +      if (!archive.is_file) {
    1.55 +        val remote = Isabelle_System.getenv("ISABELLE_COMPONENT_REPOSITORY") + "/" + archive_name
    1.56 +        progress.echo("Getting " + remote)
    1.57 +        Bytes.write(archive, Url.read_bytes(Url(remote)))
    1.58 +      }
    1.59 +      unpack(target_dir getOrElse base_dir, archive, progress = progress)
    1.60 +    }
    1.61 +  }
    1.62 +
    1.63 +  def purge(dir: Path, platform: Platform.Family.Value)
    1.64 +  {
    1.65 +    def purge_platforms(platforms: String*): Set[String] =
    1.66 +      platforms.flatMap(name => List("x86-" + name, "x86_64-" + name)).toSet + "ppc-darwin"
    1.67 +    val purge_set =
    1.68 +      platform match {
    1.69 +        case Platform.Family.linux => purge_platforms("darwin", "cygwin", "windows")
    1.70 +        case Platform.Family.macos => purge_platforms("linux", "cygwin", "windows")
    1.71 +        case Platform.Family.windows => purge_platforms("linux", "darwin")
    1.72 +      }
    1.73 +
    1.74 +    File.find_files(dir.file,
    1.75 +      (file: JFile) => file.isDirectory && purge_set(file.getName),
    1.76 +      include_dirs = true).foreach(Isabelle_System.rm_tree)
    1.77 +  }
    1.78 +
    1.79 +
    1.80 +  /* component directory content */
    1.81 +
    1.82 +  def settings(dir: Path): Path = dir + Path.explode("etc/settings")
    1.83 +  def components(dir: Path): Path = dir + Path.explode("etc/components")
    1.84 +
    1.85 +  def check_dir(dir: Path): Boolean =
    1.86 +    settings(dir).is_file || components(dir).is_file
    1.87 +
    1.88 +  def read_components(dir: Path): List[String] =
    1.89 +    split_lines(File.read(components(dir))).filter(_.nonEmpty)
    1.90 +
    1.91 +  def write_components(dir: Path, lines: List[String]): Unit =
    1.92 +    File.write(components(dir), terminate_lines(lines))
    1.93 +}
     2.1 --- a/src/Pure/System/components.scala	Sat Dec 08 14:58:56 2018 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,90 +0,0 @@
     2.4 -/*  Title:      Pure/Admin/components.scala
     2.5 -    Author:     Makarius
     2.6 -
     2.7 -Isabelle system components.
     2.8 -*/
     2.9 -
    2.10 -package isabelle
    2.11 -
    2.12 -
    2.13 -import java.io.{File => JFile}
    2.14 -
    2.15 -
    2.16 -object Components
    2.17 -{
    2.18 -  /* archive name */
    2.19 -
    2.20 -  object Archive
    2.21 -  {
    2.22 -    val suffix: String = ".tar.gz"
    2.23 -    def apply(name: String): String = name + suffix
    2.24 -    def unapply(archive: String): Option[String] = Library.try_unsuffix(suffix, archive)
    2.25 -    def get_name(archive: String): String =
    2.26 -      unapply(archive) getOrElse
    2.27 -        error("Bad component archive name (expecting .tar.gz): " + quote(archive))
    2.28 -  }
    2.29 -
    2.30 -
    2.31 -  /* component collections */
    2.32 -
    2.33 -  def admin(dir: Path): Path = dir + Path.explode("Admin/components")
    2.34 -
    2.35 -  def contrib(dir: Path = Path.current, name: String = ""): Path =
    2.36 -    dir + Path.explode("contrib") + Path.explode(name)
    2.37 -
    2.38 -  def unpack(dir: Path, archive: Path, progress: Progress = No_Progress): String =
    2.39 -  {
    2.40 -    val name = Archive.get_name(archive.file_name)
    2.41 -    progress.echo("Unpacking " + name)
    2.42 -    Isabelle_System.gnutar("-xzf " + File.bash_path(archive), dir = dir).check
    2.43 -    name
    2.44 -  }
    2.45 -
    2.46 -  def resolve(base_dir: Path, names: List[String],
    2.47 -    target_dir: Option[Path] = None,
    2.48 -    progress: Progress = No_Progress)
    2.49 -  {
    2.50 -    Isabelle_System.mkdirs(base_dir)
    2.51 -    for (name <- names) {
    2.52 -      val archive_name = Archive(name)
    2.53 -      val archive = base_dir + Path.explode(archive_name)
    2.54 -      if (!archive.is_file) {
    2.55 -        val remote = Isabelle_System.getenv("ISABELLE_COMPONENT_REPOSITORY") + "/" + archive_name
    2.56 -        progress.echo("Getting " + remote)
    2.57 -        Bytes.write(archive, Url.read_bytes(Url(remote)))
    2.58 -      }
    2.59 -      unpack(target_dir getOrElse base_dir, archive, progress = progress)
    2.60 -    }
    2.61 -  }
    2.62 -
    2.63 -  def purge(dir: Path, platform: Platform.Family.Value)
    2.64 -  {
    2.65 -    def purge_platforms(platforms: String*): Set[String] =
    2.66 -      platforms.flatMap(name => List("x86-" + name, "x86_64-" + name)).toSet + "ppc-darwin"
    2.67 -    val purge_set =
    2.68 -      platform match {
    2.69 -        case Platform.Family.linux => purge_platforms("darwin", "cygwin", "windows")
    2.70 -        case Platform.Family.macos => purge_platforms("linux", "cygwin", "windows")
    2.71 -        case Platform.Family.windows => purge_platforms("linux", "darwin")
    2.72 -      }
    2.73 -
    2.74 -    File.find_files(dir.file,
    2.75 -      (file: JFile) => file.isDirectory && purge_set(file.getName),
    2.76 -      include_dirs = true).foreach(Isabelle_System.rm_tree)
    2.77 -  }
    2.78 -
    2.79 -
    2.80 -  /* component directory content */
    2.81 -
    2.82 -  def settings(dir: Path): Path = dir + Path.explode("etc/settings")
    2.83 -  def components(dir: Path): Path = dir + Path.explode("etc/components")
    2.84 -
    2.85 -  def check_dir(dir: Path): Boolean =
    2.86 -    settings(dir).is_file || components(dir).is_file
    2.87 -
    2.88 -  def read_components(dir: Path): List[String] =
    2.89 -    split_lines(File.read(components(dir))).filter(_.nonEmpty)
    2.90 -
    2.91 -  def write_components(dir: Path, lines: List[String]): Unit =
    2.92 -    File.write(components(dir), terminate_lines(lines))
    2.93 -}
     3.1 --- a/src/Pure/build-jars	Sat Dec 08 14:58:56 2018 +0100
     3.2 +++ b/src/Pure/build-jars	Sat Dec 08 15:13:28 2018 +0100
     3.3 @@ -21,6 +21,7 @@
     3.4    Admin/build_status.scala
     3.5    Admin/check_sources.scala
     3.6    Admin/ci_profile.scala
     3.7 +  Admin/components.scala
     3.8    Admin/isabelle_cronjob.scala
     3.9    Admin/isabelle_devel.scala
    3.10    Admin/jenkins.scala
    3.11 @@ -112,7 +113,6 @@
    3.12    ROOT.scala
    3.13    System/bash.scala
    3.14    System/command_line.scala
    3.15 -  System/components.scala
    3.16    System/cygwin.scala
    3.17    System/distribution.scala
    3.18    System/getopts.scala