src/Pure/System/mingw.scala
changeset 72424 10c07d224035
parent 72421 9a8bc089890d
child 72425 d0937d55eb90
--- a/src/Pure/System/mingw.scala	Sat Oct 10 20:57:08 2020 +0200
+++ b/src/Pure/System/mingw.scala	Sat Oct 10 21:04:49 2020 +0200
@@ -9,9 +9,6 @@
 
 object MinGW
 {
-  val none: Context = new Context(None)
-  def context(root: Path) = new Context(Some(root))
-
   def environment: List[(String, String)] =
     List("PATH" -> "/usr/bin:/bin:/mingw64/bin", "CONFIG_SITE" -> "/mingw64/etc/config.site")
 
@@ -19,34 +16,37 @@
     (for ((a, b) <- environment) yield Bash.string(a) + "=" + Bash.string(b))
       .mkString("/usr/bin/env ", " ", " ")
 
-  class Context private[MinGW](val root: Option[Path])
-  {
-    override def toString: String =
-      root match {
-        case None => "MinGW.none"
-        case Some(msys_root) => "MinGW.context(" + msys_root.toString + ")"
-      }
+  val none: MinGW = new MinGW(None)
+  def root(path: Path) = new MinGW(Some(path))
+}
+
+class MinGW private(val root: Option[Path])
+{
+  override def toString: String =
+    root match {
+      case None => "MinGW.none"
+      case Some(msys_root) => "MinGW.root(" + msys_root.toString + ")"
+    }
 
-    def bash_command(command: String): String =
-      root match {
-        case None => command
-        case Some(msys_root) =>
-          File.bash_path(msys_root + Path.explode("usr/bin/bash")) +
-            " -c " + Bash.string(environment_prefix + command)
-      }
+  def bash_command(command: String): String =
+    root match {
+      case None => command
+      case Some(msys_root) =>
+        File.bash_path(msys_root + Path.explode("usr/bin/bash")) +
+          " -c " + Bash.string(MinGW.environment_prefix + command)
+    }
 
-    def get_root: Path =
-      if (!Platform.is_windows) error("Windows platform required")
-      else if (root.isEmpty) error("Windows platform needs specification of msys root directory")
-      else root.get
+  def get_root: Path =
+    if (!Platform.is_windows) error("Windows platform required")
+    else if (root.isEmpty) error("Windows platform needs specification of msys root directory")
+    else root.get
 
-    def check
-    {
-      if (Platform.is_windows) {
-        get_root
-        val result = Isabelle_System.bash(bash_command("uname -s")).check
-        if (!result.out.startsWith("MSYS")) error("Bad msys installation " + get_root)
-      }
+  def check
+  {
+    if (Platform.is_windows) {
+      get_root
+      val result = Isabelle_System.bash(bash_command("uname -s")).check
+      if (!result.out.startsWith("MSYS")) error("Bad msys installation " + get_root)
     }
   }
 }