more explicit MinGW context;
authorwenzelm
Sat, 10 Oct 2020 20:57:08 +0200
changeset 72656 f8aa2efce869
parent 72655 9d59738102b8
child 72657 10c07d224035
more explicit MinGW context;
src/Pure/Admin/build_csdp.scala
--- a/src/Pure/Admin/build_csdp.scala	Sat Oct 10 20:56:09 2020 +0200
+++ b/src/Pure/Admin/build_csdp.scala	Sat Oct 10 20:57:08 2020 +0200
@@ -54,8 +54,10 @@
     verbose: Boolean = false,
     progress: Progress = new Progress,
     target_dir: Path = Path.current,
-    msys_root: Option[Path] = None)
+    mingw_context: MinGW.Context = MinGW.none)
   {
+    mingw_context.check
+
     Isabelle_System.with_tmp_dir("build")(tmp_dir =>
     {
       /* component */
@@ -121,17 +123,8 @@
             foreach(file => flags.change(File.path(file)))
       }
 
-      val build_script = {
-        if (!Platform.is_windows) "make"
-        else if (msys_root.isEmpty) error("Windows requires specification of msys root directory")
-        else {
-          val msys_script =
-            "PATH=/usr/bin:/bin:/mingw64/bin; export CONFIG_SITE=/mingw64/etc/config.site; make"
-          File.bash_path(msys_root.get + Path.explode("usr/bin/bash")) +
-            " -c " + Bash.string(msys_script)
-        }
-      }
-      progress.bash(build_script, cwd = build_dir.file, echo = verbose).check
+      progress.bash(mingw_context.bash_command("make"),
+        cwd = build_dir.file, echo = verbose).check
 
 
       /* install */
@@ -147,7 +140,7 @@
           List("libblas", "liblapack", "libgfortran-5", "libgcc_s_seh-1",
             "libquadmath-0", "libwinpthread-1")
         for (name <- libs) {
-          File.copy(msys_root.get + Path.explode("mingw64/bin") + Path.basic(name).ext("dll"),
+          File.copy(mingw_context.get_root + Path.explode("mingw64/bin") + Path.basic(name).ext("dll"),
             platform_dir)
         }
       }
@@ -192,7 +185,7 @@
     args =>
     {
       var target_dir = Path.current
-      var msys_root: Option[Path] = None
+      var mingw_context = MinGW.none
       var download_url = default_download_url
       var verbose = false
 
@@ -201,7 +194,7 @@
 
   Options are:
     -D DIR       target directory (default ".")
-    -M DIR       msys root directory (for Windows)
+    -M DIR       msys/mingw root directory (for Windows)
     -U URL       download URL
                  (default: """" + default_download_url + """")
     -v           verbose
@@ -209,7 +202,7 @@
   Build prover component from official downloads.
 """,
         "D:" -> (arg => target_dir = Path.explode(arg)),
-        "M:" -> (arg => msys_root = Some(Path.explode(arg))),
+        "M:" -> (arg => mingw_context = MinGW.context(Path.explode(arg))),
         "U:" -> (arg => download_url = arg),
         "v" -> (_ => verbose = true))
 
@@ -219,6 +212,6 @@
       val progress = new Console_Progress()
 
       build_csdp(download_url = download_url, verbose = verbose, progress = progress,
-        target_dir = target_dir, msys_root = msys_root)
+        target_dir = target_dir, mingw_context = mingw_context)
     })
 }