src/Pure/Admin/build_csdp.scala
changeset 75393 87ebf5a50283
parent 75205 c33e75542ffe
child 75394 42267c650205
equal deleted inserted replaced
75388:b3ca4a6ed74b 75393:87ebf5a50283
     5 */
     5 */
     6 
     6 
     7 package isabelle
     7 package isabelle
     8 
     8 
     9 
     9 
    10 object Build_CSDP
    10 object Build_CSDP {
    11 {
       
    12   // Note: version 6.2.0 does not quite work for the "sos" proof method
    11   // Note: version 6.2.0 does not quite work for the "sos" proof method
    13   val default_download_url = "https://github.com/coin-or/Csdp/archive/releases/6.1.1.tar.gz"
    12   val default_download_url = "https://github.com/coin-or/Csdp/archive/releases/6.1.1.tar.gz"
    14 
    13 
    15 
    14 
    16   /* flags */
    15   /* flags */
    17 
    16 
    18   sealed case class Flags(platform: String, CFLAGS: String = "", LIBS: String = "")
    17   sealed case class Flags(platform: String, CFLAGS: String = "", LIBS: String = "") {
    19   {
       
    20     val changed: List[(String, String)] =
    18     val changed: List[(String, String)] =
    21       List("CFLAGS" -> CFLAGS, "LIBS" -> LIBS).filter(p => p._2.nonEmpty)
    19       List("CFLAGS" -> CFLAGS, "LIBS" -> LIBS).filter(p => p._2.nonEmpty)
    22 
    20 
    23     def print: Option[String] =
    21     def print: Option[String] =
    24       if (changed.isEmpty) None
    22       if (changed.isEmpty) None
    25       else
    23       else
    26         Some("  * " + platform + ":\n" + changed.map(p => "    " + Properties.Eq(p))
    24         Some("  * " + platform + ":\n" + changed.map(p => "    " + Properties.Eq(p))
    27           .mkString("\n"))
    25           .mkString("\n"))
    28 
    26 
    29     def change(path: Path): Unit =
    27     def change(path: Path): Unit = {
    30     {
       
    31       def change_line(line: String, p: (String, String)): String =
    28       def change_line(line: String, p: (String, String)): String =
    32         line.replaceAll(p._1 + "=.*", Properties.Eq(p))
    29         line.replaceAll(p._1 + "=.*", Properties.Eq(p))
    33       File.change_lines(path) { _.map(line => changed.foldLeft(line)(change_line)) }
    30       File.change_lines(path) { _.map(line => changed.foldLeft(line)(change_line)) }
    34     }
    31     }
    35   }
    32   }
    53   def build_csdp(
    50   def build_csdp(
    54     download_url: String = default_download_url,
    51     download_url: String = default_download_url,
    55     verbose: Boolean = false,
    52     verbose: Boolean = false,
    56     progress: Progress = new Progress,
    53     progress: Progress = new Progress,
    57     target_dir: Path = Path.current,
    54     target_dir: Path = Path.current,
    58     mingw: MinGW = MinGW.none): Unit =
    55     mingw: MinGW = MinGW.none
    59   {
    56   ): Unit = {
    60     mingw.check
    57     mingw.check
    61 
    58 
    62     Isabelle_System.with_tmp_dir("build")(tmp_dir =>
    59     Isabelle_System.with_tmp_dir("build")(tmp_dir => {
    63     {
       
    64       /* component */
    60       /* component */
    65 
    61 
    66       val Archive_Name = """^.*?([^/]+)$""".r
    62       val Archive_Name = """^.*?([^/]+)$""".r
    67       val Version = """^[^0-9]*([0-9].*)\.tar.gz$""".r
    63       val Version = """^[^0-9]*([0-9].*)\.tar.gz$""".r
    68 
    64 
   169 
   165 
   170   /* Isabelle tool wrapper */
   166   /* Isabelle tool wrapper */
   171 
   167 
   172   val isabelle_tool =
   168   val isabelle_tool =
   173     Isabelle_Tool("build_csdp", "build prover component from official download", Scala_Project.here,
   169     Isabelle_Tool("build_csdp", "build prover component from official download", Scala_Project.here,
   174     args =>
   170     args => {
   175     {
       
   176       var target_dir = Path.current
   171       var target_dir = Path.current
   177       var mingw = MinGW.none
   172       var mingw = MinGW.none
   178       var download_url = default_download_url
   173       var download_url = default_download_url
   179       var verbose = false
   174       var verbose = false
   180 
   175