src/Pure/Tools/dotnet_setup.scala
author wenzelm
Sun, 06 Nov 2022 12:54:46 +0100
changeset 76470 f65bb0ecc7e7
parent 76469 98cfe33db5a7
child 76518 b30b8e23383c
permissions -rw-r--r--
proper executable files for Windows;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Tools/dotnet_setup.scala
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     3
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     4
Dynamic setup of dotnet component.
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     5
*/
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     6
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     7
package isabelle
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     8
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
     9
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    10
object Dotnet_Setup {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    11
  /* platforms */
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    12
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    13
  sealed case class Platform_Info(
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    14
    family: Platform.Family.Value,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    15
    name: String,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    16
    os: String = "",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    17
    arch: String = "x64",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    18
    ext: String = "sh",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    19
    exec: String = "bash",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    20
    check: () => Unit = () => ())
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    21
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    22
  val all_platforms =
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    23
    List(
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    24
      Platform_Info(Platform.Family.linux_arm, "arm64-linux", os = "linux", arch = "arm64"),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    25
      Platform_Info(Platform.Family.linux, "x86_64-linux", os = "linux"),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    26
      Platform_Info(Platform.Family.macos, "arm64-darwin", os = "osx", arch = "arm64"),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    27
      Platform_Info(Platform.Family.macos, "x86_64-darwin", os = "osx"),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    28
      Platform_Info(Platform.Family.windows, "x86_64-windows",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    29
        ext = "ps1",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    30
        exec = "powershell -ExecutionPolicy ByPass",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    31
        check = () => Isabelle_System.require_command("powershell", "-NoProfile -Command Out-Null")))
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    32
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    33
  def check_platform_spec(spec: String): String = {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    34
    val all_specs =
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    35
      Library.distinct(all_platforms.map(_.family.toString) ::: all_platforms.map(_.name))
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    36
    if (all_specs.contains(spec)) spec
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    37
    else {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    38
      error("Bad platform specification " + quote(spec) +
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    39
        "\n  expected " + commas_quote(all_specs))
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    40
    }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    41
  }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    42
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    43
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    44
  /* dotnet download and setup */
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    45
76461
0869eacad310 proper default_platform;
wenzelm
parents: 76458
diff changeset
    46
  def default_platform: String = {
0869eacad310 proper default_platform;
wenzelm
parents: 76458
diff changeset
    47
    val self = Isabelle_Platform.self
0869eacad310 proper default_platform;
wenzelm
parents: 76458
diff changeset
    48
    proper_string(self.ISABELLE_WINDOWS_PLATFORM64).getOrElse(
0869eacad310 proper default_platform;
wenzelm
parents: 76458
diff changeset
    49
      proper_string(self.ISABELLE_APPLE_PLATFORM64).getOrElse(
0869eacad310 proper default_platform;
wenzelm
parents: 76458
diff changeset
    50
        self.ISABELLE_PLATFORM64))
0869eacad310 proper default_platform;
wenzelm
parents: 76458
diff changeset
    51
  }
0869eacad310 proper default_platform;
wenzelm
parents: 76458
diff changeset
    52
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    53
  def default_target_dir: Path = Path.explode("$ISABELLE_COMPONENTS_BASE")
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    54
  def default_install_url: String = "https://dot.net/v1/dotnet-install"
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    55
  def default_version: String = "6.0.402"
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    56
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    57
  def dotnet_setup(
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    58
    platform_spec: String = default_platform,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    59
    target_dir: Path = default_target_dir,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    60
    install_url: String = default_install_url,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    61
    version: String = default_version,
76467
5a9de03e0fa4 more command-line options;
wenzelm
parents: 76466
diff changeset
    62
    force: Boolean = false,
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    63
    dry_run: Boolean = false,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    64
    verbose: Boolean = false,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    65
    progress: Progress = new Progress
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    66
  ): Unit = {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    67
    check_platform_spec(platform_spec)
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    68
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    69
    for {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    70
      platform <- all_platforms
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    71
      if platform.family.toString == platform_spec || platform.name == platform_spec
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    72
    } {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    73
      progress.expose_interrupt()
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    74
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    75
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    76
      /* component directory */
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    77
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    78
      val component_dir =
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    79
        target_dir + Path.explode(if (version.isEmpty) "dotnet-latest" else "dotnet-" + version)
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    80
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
    81
      if (!dry_run) {
76466
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    82
        progress.echo("Component " + component_dir.expand)
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    83
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    84
        val settings_path = component_dir + Path.explode("etc/settings")
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    85
        Isabelle_System.make_directory(settings_path.dir)
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    86
        File.write(settings_path, """# -*- shell-script -*- :mode=shellscript:
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    87
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    88
ISABELLE_DOTNET_ROOT="$COMPONENT"
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    89
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    90
if [ -n "$ISABELLE_WINDOWS_PLATFORM64" -a -d "$ISABELLE_DOTNET_ROOT/$ISABELLE_WINDOWS_PLATFORM64" ]; then
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    91
  ISABELLE_DOTNET="$ISABELLE_DOTNET_ROOT/$ISABELLE_WINDOWS_PLATFORM64/dotnet.exe"
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    92
elif [ -n "$ISABELLE_APPLE_PLATFORM64" -a -d "$ISABELLE_DOTNET_ROOT/$ISABELLE_APPLE_PLATFORM64" ]; then
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    93
  ISABELLE_DOTNET="$ISABELLE_DOTNET_ROOT/$ISABELLE_APPLE_PLATFORM64/dotnet"
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    94
elif [ -d "$ISABELLE_DOTNET_ROOT/$ISABELLE_PLATFORM64" ]; then
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    95
  ISABELLE_DOTNET="$ISABELLE_DOTNET_ROOT/$ISABELLE_PLATFORM64/dotnet"
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    96
fi
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    97
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
    98
DOTNET_CLI_TELEMETRY_OPTOUT="true"
76469
98cfe33db5a7 further attempts to confine dotnet to $ISABELLE_HOME_USER;
wenzelm
parents: 76468
diff changeset
    99
DOTNET_CLI_HOME="$(platform_path "$ISABELLE_HOME_USER/dotnet")"
76466
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
   100
""")
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   101
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   102
        File.write(component_dir + Path.explode("README"),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   103
          """This installation of Dotnet has been produced via "isabelle dotnet_setup".
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   104
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   105
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   106
        Makarius
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   107
        """ + Date.Format.date(Date.now()) + "\n")
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   108
76466
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
   109
        for (old <- proper_string(Isabelle_System.getenv("ISABELLE_DOTNET_ROOT"))) {
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
   110
          Components.update_components(false, Path.explode(old))
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
   111
        }
730dadb82936 clarified component settings: always update existing version;
wenzelm
parents: 76464
diff changeset
   112
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   113
        Components.update_components(true, component_dir)
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   114
      }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   115
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   116
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   117
      /* platform directory */
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   118
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   119
      Isabelle_System.with_tmp_file("install", ext = platform.ext) { install =>
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   120
        Isabelle_System.download_file(install_url + "." + platform.ext, install)
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   121
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   122
        val platform_dir = component_dir + Path.explode(platform.name)
76467
5a9de03e0fa4 more command-line options;
wenzelm
parents: 76466
diff changeset
   123
        if (platform_dir.is_dir && !force) {
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   124
          progress.echo_warning("Platform " + platform.name + " already installed")
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   125
        }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   126
        else {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   127
          progress.echo("Platform " + platform.name + " ...")
76463
da85bffef443 clarified error;
wenzelm
parents: 76462
diff changeset
   128
          platform.check()
76467
5a9de03e0fa4 more command-line options;
wenzelm
parents: 76466
diff changeset
   129
          if (platform_dir.is_dir && force) Isabelle_System.rm_tree(platform_dir)
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   130
          val script =
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   131
            platform.exec + " " + File.bash_platform_path(install) +
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   132
              (if (version.nonEmpty) " -Version " + Bash.string(version) else "") +
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   133
              " -Architecture " + Bash.string(platform.arch) +
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   134
              (if (platform.os.nonEmpty) " -OS " + Bash.string(platform.os) else "") +
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   135
              " -InstallDir " + Bash.string(platform.name) +
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   136
              (if (dry_run) " -DryRun" else "") +
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   137
              " -NoPath"
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   138
          progress.bash(script, echo = verbose,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   139
            cwd = if (dry_run) null else component_dir.file).check
76470
f65bb0ecc7e7 proper executable files for Windows;
wenzelm
parents: 76469
diff changeset
   140
          for (exe <- File.find_files(platform_dir.file, pred = _.getName.endsWith(".exe"))) {
f65bb0ecc7e7 proper executable files for Windows;
wenzelm
parents: 76469
diff changeset
   141
            File.set_executable(File.path(exe), true)
f65bb0ecc7e7 proper executable files for Windows;
wenzelm
parents: 76469
diff changeset
   142
          }
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   143
        }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   144
      }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   145
    }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   146
  }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   147
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   148
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   149
  /* Isabelle tool wrapper */
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   150
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   151
  val isabelle_tool =
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   152
    Isabelle_Tool("dotnet_setup", "dynamic setup of dotnet component (for Fsharp)",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   153
      Scala_Project.here,
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   154
      { args =>
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   155
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   156
        var target_dir = default_target_dir
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   157
        var install_url = default_install_url
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   158
        var version = default_version
76467
5a9de03e0fa4 more command-line options;
wenzelm
parents: 76466
diff changeset
   159
        var force = false
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   160
        var dry_run = false
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   161
        var platforms = List(default_platform)
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   162
        var verbose = false
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   163
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   164
        val getopts = Getopts("""
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   165
Usage: isabelle dotnet_setup [OPTIONS]
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   166
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   167
  Options are:
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   168
    -D DIR       target directory (default: """ + default_target_dir.expand + """)
76468
01109e16cee8 tuned output;
wenzelm
parents: 76467
diff changeset
   169
    -I URL       URL for install script without extension
01109e16cee8 tuned output;
wenzelm
parents: 76467
diff changeset
   170
                 (default: """ + quote(default_install_url) + """)
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   171
    -V VERSION   version (empty means "latest", default: """ + quote(default_version) + """)
76467
5a9de03e0fa4 more command-line options;
wenzelm
parents: 76466
diff changeset
   172
    -f           force fresh installation of specified platforms
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   173
    -n           dry run: try download without installation
76468
01109e16cee8 tuned output;
wenzelm
parents: 76467
diff changeset
   174
    -p PLATFORMS comma-separated list of platform specifications,
01109e16cee8 tuned output;
wenzelm
parents: 76467
diff changeset
   175
                 as family or formal name (default: """ + quote(default_platform) + """)
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   176
    -v           verbose
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   177
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   178
  Download the Dotnet / Fsharp platform and configure it as Isabelle component.
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   179
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   180
  See also:
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   181
    https://fsharp.org
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   182
    https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
76464
18c50ff16bbc disable telemetry;
wenzelm
parents: 76463
diff changeset
   183
    https://learn.microsoft.com/en-us/dotnet/core/tools/telemetry
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   184
""",
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   185
          "D:" -> (arg => target_dir = Path.explode(arg)),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   186
          "I:" -> (arg => install_url = arg),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   187
          "V:" -> (arg => version = arg),
76467
5a9de03e0fa4 more command-line options;
wenzelm
parents: 76466
diff changeset
   188
          "f" -> (_ => force = true),
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   189
          "n" -> (_ => dry_run = true),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   190
          "p:" -> (arg => platforms = Library.space_explode(',', arg).map(check_platform_spec)),
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   191
          "v" -> (_ => verbose = true))
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   192
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   193
        val more_args = getopts(args)
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   194
        if (more_args.nonEmpty) getopts.usage()
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   195
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   196
        val progress = new Console_Progress()
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   197
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   198
        for (platform <- platforms) {
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   199
          dotnet_setup(platform_spec = platform, target_dir = target_dir, install_url = install_url,
76467
5a9de03e0fa4 more command-line options;
wenzelm
parents: 76466
diff changeset
   200
            version = version, force = force, dry_run = dry_run, verbose = verbose, progress = progress)
76458
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   201
        }
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   202
      })
cc6fd1695294 support for Dotnet / Fsharp platform, via dynamically installed Isabelle component;
wenzelm
parents:
diff changeset
   203
}