src/Pure/Admin/build_scala.scala
changeset 76518 b30b8e23383c
parent 76327 f70b015e4ac1
child 76537 cdbe20024038
equal deleted inserted replaced
76517:b67c9ed2c810 76518:b30b8e23383c
    69     progress: Progress = new Progress
    69     progress: Progress = new Progress
    70   ): Unit = {
    70   ): Unit = {
    71     /* component */
    71     /* component */
    72 
    72 
    73     val component_name = main_download.name + "-" + main_download.version
    73     val component_name = main_download.name + "-" + main_download.version
    74     val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component_name))
    74     val component_dir =
    75     progress.echo("Component " + component_dir)
    75       Components.Directory.create(target_dir + Path.basic(component_name), progress = progress)
    76 
    76 
    77 
    77 
    78     /* download */
    78     /* download */
    79 
    79 
    80     main_download.get_unpacked(component_dir, strip = 1, progress = progress)
    80     main_download.get_unpacked(component_dir.path, strip = 1, progress = progress)
    81 
    81 
    82     val lib_dir = component_dir + Path.explode("lib")
       
    83     lib_downloads.foreach(download =>
    82     lib_downloads.foreach(download =>
    84       download.get(lib_dir + Path.basic(download.artifact), progress = progress))
    83       download.get(component_dir.lib + Path.basic(download.artifact), progress = progress))
    85 
    84 
    86     File.write(component_dir + Path.basic("LICENSE"),
    85     File.write(component_dir.LICENSE,
    87       Url.read(Url("https://www.apache.org/licenses/LICENSE-2.0.txt")))
    86       Url.read(Url("https://www.apache.org/licenses/LICENSE-2.0.txt")))
    88 
    87 
    89 
    88 
    90     /* classpath */
    89     /* classpath */
    91 
    90 
    93       def no_function(name: String): String = "function " + name + "() {\n:\n}"
    92       def no_function(name: String): String = "function " + name + "() {\n:\n}"
    94       val script =
    93       val script =
    95         cat_lines(List(
    94         cat_lines(List(
    96           no_function("stty"),
    95           no_function("stty"),
    97           no_function("tput"),
    96           no_function("tput"),
    98           "PROG_HOME=" + File.bash_path(component_dir),
    97           "PROG_HOME=" + File.bash_path(component_dir.path),
    99           File.read(component_dir + Path.explode("bin/common"))
    98           File.read(component_dir.path + Path.explode("bin/common"))
   100             .replace("scala_exit_status=127", "scala_exit_status=0"),
    99             .replace("scala_exit_status=127", "scala_exit_status=0"),
   101           "compilerJavaClasspathArgs",
   100           "compilerJavaClasspathArgs",
   102           "echo \"$jvm_cp_args\""))
   101           "echo \"$jvm_cp_args\""))
   103 
   102 
   104       val main_classpath = Path.split(Isabelle_System.bash(script).check.out).map(_.file_name)
   103       val main_classpath = Path.split(Isabelle_System.bash(script).check.out).map(_.file_name)
   112         .getOrElse(error("Missing jar for scala3-interfaces"))
   111         .getOrElse(error("Missing jar for scala3-interfaces"))
   113 
   112 
   114 
   113 
   115     /* settings */
   114     /* settings */
   116 
   115 
   117     val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc"))
   116     File.write(component_dir.settings,
   118     File.write(etc_dir + Path.basic("settings"),
       
   119       """# -*- shell-script -*- :mode=shellscript:
   117       """# -*- shell-script -*- :mode=shellscript:
   120 
   118 
   121 SCALA_HOME="$COMPONENT"
   119 SCALA_HOME="$COMPONENT"
   122 SCALA_INTERFACES="$SCALA_HOME/lib/""" + interfaces + """"
   120 SCALA_INTERFACES="$SCALA_HOME/lib/""" + interfaces + """"
   123 """ + terminate_lines(classpath.map(jar => "classpath \"$SCALA_HOME/lib/" + jar + "\"")))
   121 """ + terminate_lines(classpath.map(jar => "classpath \"$SCALA_HOME/lib/" + jar + "\"")))
   125 
   123 
   126     /* adhoc changes */
   124     /* adhoc changes */
   127 
   125 
   128     val patched_scripts = List("bin/scala", "bin/scalac")
   126     val patched_scripts = List("bin/scala", "bin/scalac")
   129     for (name <- patched_scripts) {
   127     for (name <- patched_scripts) {
   130       File.change(component_dir + Path.explode(name)) {
   128       File.change(component_dir.path + Path.explode(name)) {
   131         _.replace(""""-Dscala.home=$PROG_HOME"""", """"-Dscala.home=\"$PROG_HOME\""""")
   129         _.replace(""""-Dscala.home=$PROG_HOME"""", """"-Dscala.home=\"$PROG_HOME\""""")
   132       }
   130       }
   133     }
   131     }
   134 
   132 
   135 
   133 
   136     /* README */
   134     /* README */
   137 
   135 
   138     File.write(component_dir + Path.basic("README"),
   136     File.write(component_dir.README,
   139       "This distribution of Scala integrates the following parts:\n\n" +
   137       "This distribution of Scala integrates the following parts:\n\n" +
   140       (main_download :: lib_downloads).map(_.print).mkString("\n\n") + """
   138       (main_download :: lib_downloads).map(_.print).mkString("\n\n") + """
   141 
   139 
   142 Minor changes to """ + patched_scripts.mkString(" and ") + """ allow an installation location
   140 Minor changes to """ + patched_scripts.mkString(" and ") + """ allow an installation location
   143 with spaces in the directory name.
   141 with spaces in the directory name.