src/Pure/Admin/component_polyml.scala
changeset 82475 0a6d57c4d58b
parent 82474 fcefbef691bf
child 82476 dd13205ebb0e
equal deleted inserted replaced
82474:fcefbef691bf 82475:0a6d57c4d58b
    59 
    59 
    60 
    60 
    61 
    61 
    62   /** build stages **/
    62   /** build stages **/
    63 
    63 
       
    64   def make_polyml_gmp(
       
    65     platform_context: Platform_Context,
       
    66     root: Path,
       
    67     options: List[String] = Nil
       
    68   ): Path = {
       
    69     val progress = platform_context.progress
       
    70     val platform = platform_context.platform
       
    71 
       
    72     val platform_arch = if (platform.is_arm) "aarch64" else "x86_64"
       
    73     val platform_os =
       
    74       if (platform.is_linux) "unknown-linux-gnu"
       
    75       else if (platform.is_windows) "w64-mingw32"
       
    76       else if (platform.is_macos) """apple-darwin"$(uname -r)""""
       
    77       else error("Bad platform " + platform)
       
    78 
       
    79     val target_dir = root + Path.explode("target")
       
    80 
       
    81     progress.echo("Building GMP library ...")
       
    82     platform_context.execute(root,
       
    83       "[ -f Makefile ] && make distclean",
       
    84       "./configure --enable-cxx --build=" + platform_arch + "-" + platform_os +
       
    85         " --prefix=" + Bash.string(platform_context.standard_path(target_dir)) +
       
    86         if_proper(options, " " + Bash.strings(options)),
       
    87       "make",
       
    88       "make check",
       
    89       "make install")
       
    90 
       
    91     target_dir
       
    92   }
       
    93 
    64   def make_polyml(
    94   def make_polyml(
    65     platform_context: Platform_Context,
    95     platform_context: Platform_Context,
    66     root: Path,
    96     root: Path,
    67     gmp_root: Option[Path] = None,
    97     gmp_root: Option[Path] = None,
    68     sha1_root: Option[Path] = None,
    98     sha1_root: Option[Path] = None,
   237             Url.get_base_name(gmp_url).getOrElse(error("No base name in " + quote(gmp_url)))
   267             Url.get_base_name(gmp_url).getOrElse(error("No base name in " + quote(gmp_url)))
   238           val archive = download_dir + Path.basic(archive_name)
   268           val archive = download_dir + Path.basic(archive_name)
   239           Isabelle_System.download_file(gmp_url, archive, progress = progress)
   269           Isabelle_System.download_file(gmp_url, archive, progress = progress)
   240           Isabelle_System.extract(archive, gmp_dir, strip = true)
   270           Isabelle_System.extract(archive, gmp_dir, strip = true)
   241 
   271 
   242           val platform_arch = if (platform.is_arm) "aarch64" else "x86_64"
   272           Some(make_polyml_gmp(platform_context, gmp_dir))
   243           val platform_os =
       
   244             if (platform.is_linux) "unknown-linux-gnu"
       
   245             else if (platform.is_windows) "w64-mingw32"
       
   246             else if (platform.is_macos) """apple-darwin"$(uname -r)""""
       
   247             else error("Bad platform " + platform)
       
   248 
       
   249           progress.echo("Building GMP library ...")
       
   250           platform_context.execute(gmp_dir,
       
   251             "./configure --enable-cxx --build=" + platform_arch + "-" + platform_os +
       
   252               """ --prefix="$PWD/target"""",
       
   253             "make",
       
   254             "make check",
       
   255             "make install")
       
   256 
       
   257           Some(gmp_dir + Path.explode("target"))
       
   258         }
   273         }
   259 
   274 
   260 
   275 
   261       /* Poly/ML */
   276       /* Poly/ML */
   262 
   277 
   365 
   380 
   366 
   381 
   367   /** Isabelle tool wrappers **/
   382   /** Isabelle tool wrappers **/
   368 
   383 
   369   val isabelle_tool1 =
   384   val isabelle_tool1 =
       
   385     Isabelle_Tool("make_polyml_gmp", "make GMP library from existing sources", Scala_Project.here,
       
   386       { args =>
       
   387         var mingw = MinGW.none
       
   388 
       
   389         val getopts = Getopts("""
       
   390 Usage: isabelle make_polyml_gmp [OPTIONS] ROOT [CONFIGURE_OPTIONS]
       
   391 
       
   392   Options are:
       
   393     -M DIR       msys/mingw root specification for Windows
       
   394 
       
   395   Make GMP library in the ROOT directory of its sources, with additional
       
   396   CONFIGURE_OPTIONS.
       
   397 """,
       
   398           "M:" -> (arg => mingw = MinGW(Path.explode(arg))))
       
   399 
       
   400         val more_args = getopts(args)
       
   401         val (root, options) =
       
   402           more_args match {
       
   403             case root :: options => (Path.explode(root), options)
       
   404             case Nil => getopts.usage()
       
   405           }
       
   406         make_polyml_gmp(Platform_Context(mingw = mingw, progress = new Console_Progress),
       
   407           root, options = options)
       
   408       })
       
   409 
       
   410   val isabelle_tool2 =
   370     Isabelle_Tool("make_polyml", "make Poly/ML from existing sources", Scala_Project.here,
   411     Isabelle_Tool("make_polyml", "make Poly/ML from existing sources", Scala_Project.here,
   371       { args =>
   412       { args =>
   372         var gmp_root: Option[Path] = None
   413         var gmp_root: Option[Path] = None
   373         var mingw = MinGW.none
   414         var mingw = MinGW.none
   374         var arch_64 = false
   415         var arch_64 = false
   405           }
   446           }
   406         make_polyml(Platform_Context(mingw = mingw, progress = new Console_Progress),
   447         make_polyml(Platform_Context(mingw = mingw, progress = new Console_Progress),
   407           root, gmp_root = gmp_root, sha1_root = sha1_root, arch_64 = arch_64, options = options)
   448           root, gmp_root = gmp_root, sha1_root = sha1_root, arch_64 = arch_64, options = options)
   408       })
   449       })
   409 
   450 
   410   val isabelle_tool2 =
   451   val isabelle_tool3 =
   411     Isabelle_Tool("component_polyml", "build Poly/ML component from official repository",
   452     Isabelle_Tool("component_polyml", "build Poly/ML component from official repository",
   412       Scala_Project.here,
   453       Scala_Project.here,
   413       { args =>
   454       { args =>
   414         var target_dir = Path.current
   455         var target_dir = Path.current
   415         var gmp_url = ""
   456         var gmp_url = ""