src/Pure/Admin/component_windows_app.scala
changeset 79571 d160d7a18b25
parent 79570 7254253f2ec7
child 79572 fb6b448b7939
--- a/src/Pure/Admin/component_windows_app.scala	Sun Feb 04 20:23:37 2024 +0100
+++ b/src/Pure/Admin/component_windows_app.scala	Sun Feb 04 20:54:30 2024 +0100
@@ -34,6 +34,7 @@
     "https://github.com/chrislake/7zsfxmm/releases/download/1.7.1.3901/7zsd_extra_171_3901.7z"
 
   def build_windows_app(
+    build_binutils: Boolean = false,
     launch4j_url: String = default_launch4j_url,
     binutils_url: String = default_binutils_url,
     sfx_url: String = default_sfx_url,
@@ -66,20 +67,22 @@
 
       /* GNU binutils */
 
-      Isabelle_System.download_file(binutils_url, download_tar, progress = progress)
-      Isabelle_System.extract(download_tar, tmp_dir, strip = true)
+      if (build_binutils) {
+        Isabelle_System.download_file(binutils_url, download_tar, progress = progress)
+        Isabelle_System.extract(download_tar, tmp_dir, strip = true)
 
-      progress.echo("Building GNU binutils for " + platform_name + " ...")
-      val build_script =
-        List("""./configure --prefix="$PWD/target" --with-windres --with-ld""",
-          "make", "make install")
-      Isabelle_System.bash(build_script.mkString(" && "), cwd = tmp_dir.file,
-        progress_stdout = progress.echo(_, verbose = true),
-        progress_stderr = progress.echo(_, verbose = true)).check
+        progress.echo("Building GNU binutils for " + platform_name + " ...")
+        val build_script =
+          List("""./configure --prefix="$PWD/target" --with-windres --with-ld""",
+            "make", "make install")
+        Isabelle_System.bash(build_script.mkString(" && "), cwd = tmp_dir.file,
+          progress_stdout = progress.echo(_, verbose = true),
+          progress_stderr = progress.echo(_, verbose = true)).check
 
-      for (name <- List("ld", "windres")) {
-        Isabelle_System.copy_file(
-          tmp_dir + Path.explode("target/bin") + Path.basic(name), platform_bin_dir)
+        for (name <- List("ld", "windres")) {
+          Isabelle_System.copy_file(
+            tmp_dir + Path.explode("target/bin") + Path.basic(name), platform_bin_dir)
+        }
       }
 
 
@@ -134,6 +137,7 @@
         "build windows_app component from GNU binutils and launch4j",
       Scala_Project.here,
       { args =>
+        var build_binutils = false
         var target_dir = Path.current
         var launch4j_url = default_launch4j_url
         var binutils_url = default_binutils_url
@@ -144,6 +148,7 @@
 Usage: isabelle component_windows_app [OPTIONS]
 
   Options are:
+    -B           build GNU binutils from sources
     -D DIR       target directory (default ".")
     -U URL       download URL for launch4j, default:
                  """ + default_launch4j_url + """
@@ -155,6 +160,7 @@
 
   Build Isabelle windows_app component from GNU binutils and launch4j.
 """,
+          "B" -> (_ => build_binutils = true),
           "D:" -> (arg => target_dir = Path.explode(arg)),
           "U:" -> (arg => launch4j_url = arg),
           "V:" -> (arg => binutils_url = arg),
@@ -166,7 +172,8 @@
 
         val progress = new Console_Progress(verbose = verbose)
 
-        build_windows_app(launch4j_url = launch4j_url, binutils_url = binutils_url,
+        build_windows_app(build_binutils = build_binutils,
+          launch4j_url = launch4j_url, binutils_url = binutils_url,
           sfx_url = sfx_url, progress = progress, target_dir = target_dir)
       })
 }