16 |
16 |
17 def vscode_home: Path = Path.variable("ISABELLE_VSCODE_HOME") |
17 def vscode_home: Path = Path.variable("ISABELLE_VSCODE_HOME") |
18 def vscode_settings: Path = Path.variable("ISABELLE_VSCODE_SETTINGS") |
18 def vscode_settings: Path = Path.variable("ISABELLE_VSCODE_SETTINGS") |
19 def vscode_version: String = Isabelle_System.getenv_strict("ISABELLE_VSCODE_VERSION") |
19 def vscode_version: String = Isabelle_System.getenv_strict("ISABELLE_VSCODE_VERSION") |
20 |
20 |
|
21 def exe_path(dir: Path): Path = dir + Path.explode("bin/codium") |
|
22 |
21 def vscode_installation(version: String, platform: Platform.Family.Value): (Boolean, Path) = |
23 def vscode_installation(version: String, platform: Platform.Family.Value): (Boolean, Path) = |
22 { |
24 { |
23 val platform_name = |
25 val platform_name = |
24 if (platform == Platform.Family.windows) Platform.Family.native(platform) |
26 if (platform == Platform.Family.windows) Platform.Family.native(platform) |
25 else Platform.Family.standard(platform) |
27 else Platform.Family.standard(platform) |
26 val install_dir = |
28 val install_dir = |
27 vscode_settings + Path.basic("installation") + |
29 vscode_settings + Path.basic("installation") + |
28 Path.basic(version) + Path.basic(platform_name) |
30 Path.basic(version) + Path.basic(platform_name) |
29 val install_ok = (install_dir + Path.explode("bin/codium")).is_file |
31 val install_ok = exe_path(install_dir).is_file |
30 (install_ok, install_dir) |
32 (install_ok, install_dir) |
31 } |
33 } |
32 |
34 |
33 |
35 |
34 /* vscode setup */ |
36 /* vscode setup */ |
35 |
37 |
36 val default_download_url: String = "https://github.com/VSCodium/vscodium/releases/download" |
38 val default_download_url: String = "https://github.com/VSCodium/vscodium/releases/download" |
37 def default_platform: Platform.Family.Value = Platform.family |
39 def default_platform: Platform.Family.Value = Platform.family |
|
40 |
|
41 private def macos_exe: String = |
|
42 """#!/usr/bin/env bash |
|
43 |
|
44 unset CDPATH |
|
45 VSCODE_PATH="$(cd "$(dirname "$0")"/../VSCodium.app/Contents; pwd)" |
|
46 |
|
47 ELECTRON="$VSCODE_PATH/MacOS/Electron" |
|
48 CLI="$VSCODE_PATH/Resources/app/out/cli.js" |
|
49 ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@" |
|
50 exit $? |
|
51 """ |
38 |
52 |
39 def download_name(version: String, platform: Platform.Family.Value): String = |
53 def download_name(version: String, platform: Platform.Family.Value): String = |
40 { |
54 { |
41 val a = "VSCodium" |
55 val a = "VSCodium" |
42 val (b, c) = |
56 val (b, c) = |
74 val name = download_name(version, platform) |
88 val name = download_name(version, platform) |
75 val is_zip = name.endsWith(".zip") |
89 val is_zip = name.endsWith(".zip") |
76 if (is_zip) Isabelle_System.require_command("unzip", test = "-h") |
90 if (is_zip) Isabelle_System.require_command("unzip", test = "-h") |
77 |
91 |
78 Isabelle_System.make_directory(install_dir) |
92 Isabelle_System.make_directory(install_dir) |
|
93 val exe = exe_path(install_dir) |
|
94 |
79 Isabelle_System.with_tmp_file("download")(download => |
95 Isabelle_System.with_tmp_file("download")(download => |
80 { |
96 { |
81 Isabelle_System.download_file(download_url + "/" + version + "/" + name, download, |
97 Isabelle_System.download_file(download_url + "/" + version + "/" + name, download, |
82 progress = if (verbose) progress else new Progress) |
98 progress = if (verbose) progress else new Progress) |
83 if (verbose) progress.echo("Installing " + install_dir.expand) |
99 if (verbose) progress.echo("Installing " + install_dir.expand) |
87 } |
103 } |
88 else { |
104 else { |
89 Isabelle_System.gnutar("-xzf " + File.bash_path(download), |
105 Isabelle_System.gnutar("-xzf " + File.bash_path(download), |
90 dir = install_dir).check |
106 dir = install_dir).check |
91 } |
107 } |
92 if (platform == Platform.Family.windows) { |
108 platform match { |
93 val files1 = File.find_files((install_dir + Path.explode("bin")).file) |
109 case Platform.Family.macos => |
94 val files2 = |
110 Isabelle_System.make_directory(exe.dir) |
95 File.find_files(install_dir.file, |
111 File.write(exe, macos_exe) |
96 pred = file => file.getName.endsWith(".exe") || file.getName.endsWith(".dll")) |
112 File.set_executable(exe, true) |
97 for (file <- files1 ::: files2) File.set_executable(File.path(file), true) |
113 case Platform.Family.windows => |
|
114 val files1 = File.find_files(exe.dir.file) |
|
115 val files2 = |
|
116 File.find_files(install_dir.file, |
|
117 pred = file => file.getName.endsWith(".exe") || file.getName.endsWith(".dll")) |
|
118 for (file <- files1 ::: files2) File.set_executable(File.path(file), true) |
|
119 case _ => |
98 } |
120 } |
99 }) |
121 }) |
100 } |
122 } |
101 } |
123 } |
102 |
124 |