src/Pure/Admin/component_lipics.scala
author wenzelm
Fri, 01 Mar 2024 21:23:47 +0100
changeset 79753 a66588206ec5
parent 78286 68f1c4ca48c3
permissions -rw-r--r--
update to scala-3.3.3; enforce rebuild of Isabelle/Scala + Isabelle/ML;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 76548
diff changeset
     1
/*  Title:      Pure/Admin/component_lipics.scala
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     3
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     4
Build Isabelle component for Dagstuhl LIPIcs style.
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     5
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     6
See also:
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     7
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     8
  - https://github.com/dagstuhl-publishing/styles
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
     9
  - https://submission.dagstuhl.de/documentation/authors
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    10
  - https://www.dagstuhl.de/en/publications/lipics
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    11
*/
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    12
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    13
package isabelle
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    14
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    15
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 76548
diff changeset
    16
object Component_LIPIcs {
77758
2e3c7c557151 tuned comments;
wenzelm
parents: 77566
diff changeset
    17
  /* resources */
76451
87cd8506e000 document_build engine for "lipics", with options and document_files;
wenzelm
parents: 76395
diff changeset
    18
87cd8506e000 document_build engine for "lipics", with options and document_files;
wenzelm
parents: 76395
diff changeset
    19
  val document_files: List[Path] =
87cd8506e000 document_build engine for "lipics", with options and document_files;
wenzelm
parents: 76395
diff changeset
    20
    for (name <- List("cc-by.pdf", "lipics-logo-bw.pdf", "lipics-v2021.cls"))
87cd8506e000 document_build engine for "lipics", with options and document_files;
wenzelm
parents: 76395
diff changeset
    21
      yield Path.explode("$ISABELLE_LIPICS_HOME/" + name)
87cd8506e000 document_build engine for "lipics", with options and document_files;
wenzelm
parents: 76395
diff changeset
    22
87cd8506e000 document_build engine for "lipics", with options and document_files;
wenzelm
parents: 76395
diff changeset
    23
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    24
  /* build lipics component */
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    25
78286
68f1c4ca48c3 update to current lipics-3.1.3;
wenzelm
parents: 77758
diff changeset
    26
  val default_url = "https://github.com/dagstuhl-publishing/styles/archive/refs/tags/v2021.1.3.tar.gz"
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    27
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    28
  def build_lipics(
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    29
    download_url: String = default_url,
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    30
    target_dir: Path = Path.current,
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    31
    progress: Progress = new Progress
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    32
  ): Unit = {
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    33
    Isabelle_System.with_tmp_file("download", ext = "tar.gz") { download_file =>
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    34
      Isabelle_System.with_tmp_dir("download") { download_dir =>
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    35
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    36
        /* download */
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    37
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    38
        Isabelle_System.download_file(download_url, download_file, progress = progress)
76540
83de6e9ae983 clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents: 76518
diff changeset
    39
        Isabelle_System.extract(download_file, download_dir, strip = true)
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    40
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    41
        val lipics_dir = download_dir + Path.explode("LIPIcs/authors")
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    42
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    43
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    44
        /* component */
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    45
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    46
        val version = {
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    47
          val Version = """^*.* v(.*)$""".r
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    48
          val changelog = Path.explode("CHANGELOG.md")
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    49
          split_lines(File.read(lipics_dir + changelog))
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    50
            .collectFirst({ case Version(v) => v })
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    51
            .getOrElse(error("Failed to detect version in " + changelog))
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    52
        }
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    53
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    54
        val component = "lipics-" + version
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 76451
diff changeset
    55
        val component_dir =
76547
9fe5d8c70352 tuned signature;
wenzelm
parents: 76540
diff changeset
    56
          Components.Directory(target_dir + Path.basic(component)).create(progress = progress)
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    57
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 76451
diff changeset
    58
        Isabelle_System.copy_dir(lipics_dir, component_dir.path)
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    59
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    60
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    61
        /* settings */
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    62
76548
0af64cc2eee9 tuned signature;
wenzelm
parents: 76547
diff changeset
    63
        component_dir.write_settings("""
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    64
ISABELLE_LIPICS_HOME="$COMPONENT/authors"
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    65
""")
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    66
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    67
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    68
        /* README */
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    69
76518
b30b8e23383c clarified signature: more explicit types;
wenzelm
parents: 76451
diff changeset
    70
        File.write(component_dir.README,
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    71
          """This is the Dagstuhl LIPIcs style for authors from
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    72
""" + download_url + """
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    73
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    74
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    75
    Makarius
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    76
    """ + Date.Format.date(Date.now()) + "\n")
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    77
      }
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    78
    }
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    79
  }
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    80
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    81
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    82
  /* Isabelle tool wrapper */
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    83
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    84
  val isabelle_tool =
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 76548
diff changeset
    85
    Isabelle_Tool("component_lipics", "build component for Dagstuhl LIPIcs style",
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    86
      Scala_Project.here,
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    87
      { args =>
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    88
        var target_dir = Path.current
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    89
        var download_url = default_url
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    90
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    91
        val getopts = Getopts("""
77566
2a99fcb283ee renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents: 76548
diff changeset
    92
Usage: isabelle component_lipics [OPTIONS]
76395
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    93
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    94
  Options are:
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    95
    -D DIR       target directory (default ".")
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    96
    -U URL       download URL (default: """" + default_url + """")
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    97
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    98
  Build component for Dagstuhl LIPIcs style.
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
    99
""",
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   100
          "D:" -> (arg => target_dir = Path.explode(arg)),
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   101
          "U:" -> (arg => download_url = arg))
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   102
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   103
        val more_args = getopts(args)
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   104
        if (more_args.nonEmpty) getopts.usage()
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   105
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   106
        val progress = new Console_Progress()
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   107
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   108
        build_lipics(download_url = download_url, target_dir = target_dir, progress = progress)
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   109
      })
fac28b6c37e8 support for Dagstuhl LIPIcs style with demo document;
wenzelm
parents:
diff changeset
   110
}