src/Pure/Tools/go_setup.scala
author Fabian Huch <huch@in.tum.de>
Thu, 18 Jul 2024 13:08:11 +0200
changeset 80574 90493e889dff
parent 80039 0732ee5c8ee1
permissions -rw-r--r--
clarified: more uniform;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
     1
/*  Title:      Pure/Tools/go_setup.scala
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
     3
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
     4
Dynamic setup of Go component.
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
     5
*/
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
     6
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
     7
package isabelle
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
     8
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
     9
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    10
object Go_Setup {
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    11
  /* platform information */
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    12
80008
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    13
  sealed case class Platform_Info(platform: String, go_platform: String)
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    14
  extends Platform.Info {
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    15
    def paths: List[String] = List(platform, "pkg/tool/" + go_platform)
79982
013558fd6fed more accurate platform directories: pkg/tool structure is hardwired in "go";
wenzelm
parents: 79976
diff changeset
    16
013558fd6fed more accurate platform directories: pkg/tool structure is hardwired in "go";
wenzelm
parents: 79976
diff changeset
    17
    def download(base_url: String, version: String): String = {
80008
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    18
      val ext = if (is_windows) ".zip" else ".tar.gz"
79982
013558fd6fed more accurate platform directories: pkg/tool structure is hardwired in "go";
wenzelm
parents: 79976
diff changeset
    19
      Url.append_path(base_url, "go" + version + "." + go_platform.replace("_", "-") + ext)
013558fd6fed more accurate platform directories: pkg/tool structure is hardwired in "go";
wenzelm
parents: 79976
diff changeset
    20
    }
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    21
  }
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    22
80008
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    23
  val all_platforms: List[Platform_Info] =
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    24
    List(
80008
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    25
      Platform_Info("arm64-darwin", "darwin_arm64"),
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    26
      Platform_Info("arm64-linux", "linux_arm64"),
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    27
      Platform_Info("x86_64-darwin", "darwin_amd64"),
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    28
      Platform_Info("x86_64-linux", "linux_amd64"),
914c4a81027d clarified signature: explicit type Platform.Info with derived operations;
wenzelm
parents: 79982
diff changeset
    29
      Platform_Info("x86_64-windows", "windows_amd64"))
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    30
80038
b1e2246147eb clarified signature;
wenzelm
parents: 80026
diff changeset
    31
  def check_platform(spec: String): String = Platform.Info.check(all_platforms, spec)
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    32
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    33
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    34
  /* Go download and setup */
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    35
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    36
  def default_platform: String =
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    37
    Isabelle_Platform.self.ISABELLE_PLATFORM(windows = true, apple = true)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    38
  def default_target_dir: Path = Components.default_components_base
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    39
  val default_url = "https://go.dev/dl"
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    40
  def default_version: String = Isabelle_System.getenv_strict("ISABELLE_GO_VERSION")
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    41
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    42
  def go_setup(
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    43
    platforms: List[String] = List(default_platform),
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    44
    base_url: String = default_url,
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    45
    version: String = default_version,
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    46
    target_dir: Path = default_target_dir,
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    47
    progress: Progress = new Progress,
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    48
    force: Boolean = false
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    49
  ): Unit = {
80038
b1e2246147eb clarified signature;
wenzelm
parents: 80026
diff changeset
    50
    platforms.foreach(check_platform)
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    51
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    52
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    53
    /* component directory */
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    54
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    55
    val component_dir =
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    56
      Components.Directory(target_dir + Path.basic("go-" + version)).create(permissive = true)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    57
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    58
    progress.echo("Component directory " + component_dir)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    59
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    60
    component_dir.write_settings("""
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    61
ISABELLE_GOROOT="$COMPONENT"
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    62
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    63
if [ -n "$ISABELLE_WINDOWS_PLATFORM64" -a -d "$ISABELLE_GOROOT/$ISABELLE_WINDOWS_PLATFORM64" ]; then
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    64
  ISABELLE_GOEXE="$ISABELLE_GOROOT/$ISABELLE_WINDOWS_PLATFORM64"
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    65
elif [ -n "$ISABELLE_APPLE_PLATFORM64" -a -d "$ISABELLE_GOROOT/$ISABELLE_APPLE_PLATFORM64" ]; then
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    66
  ISABELLE_GOEXE="$ISABELLE_GOROOT/$ISABELLE_APPLE_PLATFORM64"
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    67
elif [ -d "$ISABELLE_GOROOT/$ISABELLE_PLATFORM64" ]; then
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    68
  ISABELLE_GOEXE="$ISABELLE_GOROOT/$ISABELLE_PLATFORM64"
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    69
fi
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    70
""")
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    71
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    72
    File.write(component_dir.platform_props,
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    73
      (for ((a, b) <- all_platforms.groupBy(_.family_name).iterator)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    74
        yield a + " = " + b.flatMap(_.paths).mkString(" ")
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    75
      ).mkString("", "\n", "\n"))
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    76
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    77
    for (old <- proper_string(Isabelle_System.getenv("ISABELLE_GOROOT"))) {
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    78
      Components.update_components(false, Path.explode(old))
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    79
    }
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    80
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    81
    Components.update_components(true, component_dir.path)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    82
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    83
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    84
    /* download and setup */
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    85
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    86
    Isabelle_System.with_tmp_dir("download") { download_dir =>
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    87
      for (platform <- all_platforms if platforms.exists(platform.is)) {
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    88
        val platform_dir = component_dir.path + platform.path
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    89
        if (platform_dir.is_dir && !force) {
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    90
          progress.echo_warning("Platform " + platform + " already installed")
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    91
        }
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    92
        else {
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    93
          progress.echo("Platform " + platform + " ...")
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    94
          progress.expose_interrupt()
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
    95
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    96
          if (force) {
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    97
            for (name <- platform.paths) {
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    98
              val dir = component_dir.path + Path.explode(name)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
    99
              if (dir.is_dir) Isabelle_System.rm_tree(dir)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   100
            }
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   101
          }
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   102
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   103
          val download = platform.download(base_url, version)
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   104
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   105
          val archive_name =
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   106
            Url.get_base_name(download) getOrElse
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   107
              error("Malformed download URL " + quote(download))
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   108
          val archive_path = download_dir + Path.basic(archive_name)
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   109
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   110
          Isabelle_System.download_file(download, archive_path)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   111
          Isabelle_System.extract(archive_path, component_dir.path, strip = true)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   112
          Isabelle_System.move_file(component_dir.bin, platform_dir)
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   113
        }
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   114
      }
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   115
    }
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   116
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   117
    File.find_files(component_dir.path.file, pred = file => File.is_exe(file.getName)).
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   118
      foreach(file => File.set_executable(File.path(file)))
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   119
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   120
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   121
    /* README */
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   122
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   123
    File.write(component_dir.README,
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   124
      """This installation of Go has been produced via "isabelle go_setup".
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   125
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   126
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   127
        Makarius
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   128
        """ + Date.Format.date(Date.now()) + "\n")
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   129
  }
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   130
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   131
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   132
  /* Isabelle tool wrapper */
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   133
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   134
  val isabelle_tool =
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   135
    Isabelle_Tool("go_setup", "dynamic setup of Go component", Scala_Project.here,
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   136
      { args =>
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   137
        var target_dir = default_target_dir
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   138
        var base_url = default_url
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   139
        var version = default_version
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   140
        var force = false
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   141
        var platforms = List(default_platform)
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   142
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   143
        val getopts = Getopts("""
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   144
Usage: isabelle go_setup [OPTIONS]
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   145
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   146
  Options are:
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   147
    -D DIR       target directory (default ".")
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   148
    -U URL       download URL (default: """" + default_url + """")
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   149
    -V VERSION   version (default: """" + default_version + """")
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   150
    -f           force fresh installation of specified platforms
80039
0732ee5c8ee1 support for "all" platforms;
wenzelm
parents: 80038
diff changeset
   151
    -p PLATFORMS comma-separated list of platform specifications: "all" or
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   152
                 as family or formal name (default: """ + quote(default_platform) + """)
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   153
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   154
  Download the Go development environment and configure it as Isabelle
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   155
  component. See also https://go.dev
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   156
""",
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   157
          "D:" -> (arg => target_dir = Path.explode(arg)),
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   158
          "U:" -> (arg => base_url = arg),
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   159
          "V:" -> (arg => version = arg),
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   160
          "f" -> (_ => force = true),
80038
b1e2246147eb clarified signature;
wenzelm
parents: 80026
diff changeset
   161
          "p:" -> (arg => platforms = space_explode(',', arg).map(check_platform)))
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   162
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   163
        val more_args = getopts(args)
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   164
        if (more_args.nonEmpty) getopts.usage()
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   165
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   166
        val progress = new Console_Progress()
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   167
80011
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   168
        go_setup(platforms = platforms, base_url = base_url, version = version,
b082476a8036 dynamic setup of Go component, similar to Dotnet;
wenzelm
parents: 80008
diff changeset
   169
          target_dir = target_dir, progress = progress, force = force)
79976
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   170
      })
c7e6a508a65b build Isabelle component for Go: all platforms;
wenzelm
parents:
diff changeset
   171
}
80026
a03a7d4b82f8 more Setup_Tool services;
wenzelm
parents: 80011
diff changeset
   172
a03a7d4b82f8 more Setup_Tool services;
wenzelm
parents: 80011
diff changeset
   173
class Go_Setup extends Setup_Tool("go_setup", "ISABELLE_GO_SETUP") {
a03a7d4b82f8 more Setup_Tool services;
wenzelm
parents: 80011
diff changeset
   174
  override val test_file: Path = Path.explode("lib/Tools/go")
a03a7d4b82f8 more Setup_Tool services;
wenzelm
parents: 80011
diff changeset
   175
}