author | wenzelm |
Wed, 09 Mar 2022 16:52:32 +0100 | |
changeset 75253 | 1b1b60db9dda |
parent 75252 | 41dfe941c3da |
child 75255 | d192b0a8b620 |
permissions | -rw-r--r-- |
75247 | 1 |
/* Title: Tools/VSCode/src/build_vscodium.scala |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
3 |
|
75250 | 4 |
Build the Isabelle system component for VSCodium: cross-compilation for all |
5 |
platforms. |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
6 |
*/ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
7 |
|
75247 | 8 |
package isabelle.vscode |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
9 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
10 |
|
75247 | 11 |
import isabelle._ |
12 |
||
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
13 |
import java.util.{Map => JMap} |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
14 |
import java.security.MessageDigest |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
15 |
import java.util.Base64 |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
16 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
17 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
18 |
object Build_VSCodium |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
19 |
{ |
75217 | 20 |
/* global parameters */ |
21 |
||
22 |
lazy val version: String = Isabelle_System.getenv_strict("ISABELLE_VSCODE_VERSION") |
|
23 |
val vscodium_repository = "https://github.com/VSCodium/vscodium.git" |
|
75224 | 24 |
val vscodium_download = "https://github.com/VSCodium/vscodium/releases/download" |
25 |
||
26 |
def vscodium_exe(dir: Path): Path = dir + Path.explode("bin/codium") |
|
75217 | 27 |
|
28 |
||
75253 | 29 |
/* Isabelle symbols (static subset only) */ |
75252
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
30 |
|
75253 | 31 |
def make_symbols(): File.Content = |
75252
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
32 |
{ |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
33 |
val symbols = Symbol.Symbols.load(static = true) |
75253 | 34 |
val symbols_js = |
35 |
JSON.Format.apply_lines( |
|
36 |
for (entry <- symbols.entries) yield |
|
37 |
JSON.Object( |
|
38 |
"symbol" -> entry.symbol, |
|
39 |
"name" -> entry.name, |
|
40 |
"abbrevs" -> entry.abbrevs) ++ |
|
41 |
JSON.optional("code", entry.code)) |
|
42 |
||
43 |
File.Content(Path.explode("symbols.json"), symbols_js) |
|
44 |
} |
|
45 |
||
46 |
def make_isabelle_encoding(header: String): File.Content = |
|
47 |
{ |
|
48 |
val symbols = Symbol.Symbols.load(static = true) |
|
49 |
val symbols_js = |
|
50 |
JSON.Format.apply_lines( |
|
51 |
for (entry <- symbols.entries; code <- entry.code) |
|
52 |
yield JSON.Object("symbol" -> entry.symbol, "code" -> code)) |
|
53 |
||
54 |
val path = Path.explode("isabelle_encoding.ts") |
|
55 |
val body = |
|
56 |
File.read(Path.explode("$ISABELLE_VSCODE_HOME/patches") + path) |
|
57 |
.replace("[/*symbols*/]", symbols_js) |
|
58 |
File.Content(path, header + "\n" + body) |
|
75252
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
59 |
} |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
60 |
|
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
61 |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
62 |
/* platform info */ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
63 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
64 |
sealed case class Platform_Info( |
75224 | 65 |
platform: Platform.Family.Value, |
66 |
download_template: String, |
|
67 |
build_name: String, |
|
68 |
env: List[String]) |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
69 |
{ |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
70 |
def is_linux: Boolean = platform == Platform.Family.linux |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
71 |
|
75224 | 72 |
def download_name: String = "VSCodium-" + download_template.replace("{VERSION}", version) |
73 |
def download_zip: Boolean = download_name.endsWith(".zip") |
|
74 |
||
75 |
def download(dir: Path, progress: Progress = new Progress): Unit = |
|
76 |
{ |
|
77 |
if (download_zip) Isabelle_System.require_command("unzip", test = "-h") |
|
78 |
||
79 |
Isabelle_System.with_tmp_file("download")(download_file => |
|
80 |
{ |
|
81 |
Isabelle_System.download_file(vscodium_download + "/" + version + "/" + download_name, |
|
82 |
download_file, progress = progress) |
|
83 |
||
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
84 |
progress.echo("Extract ...") |
75224 | 85 |
if (download_zip) { |
86 |
Isabelle_System.bash("unzip -x " + File.bash_path(download_file), cwd = dir.file).check |
|
87 |
} |
|
88 |
else { |
|
89 |
Isabelle_System.gnutar("-xzf " + File.bash_path(download_file), dir = dir).check |
|
90 |
} |
|
91 |
}) |
|
92 |
} |
|
93 |
||
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
94 |
def get_vscodium_repository(vscodium_dir: Path, progress: Progress = new Progress): Unit = |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
95 |
{ |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
96 |
progress.echo("Getting VSCodium repository ...") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
97 |
Isabelle_System.bash( |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
98 |
List( |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
99 |
"set -e", |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
100 |
"git clone -n " + Bash.string(vscodium_repository) + " .", |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
101 |
"git checkout -q " + Bash.string(version) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
102 |
).mkString("\n"), cwd = vscodium_dir.file).check |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
103 |
|
75232 | 104 |
progress.echo("Getting VSCode repository ...") |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
105 |
Isabelle_System.bash(environment + "\n" + "./get_repo.sh", cwd = vscodium_dir.file).check |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
106 |
} |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
107 |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
108 |
def platform_dir(dir: Path): Path = |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
109 |
{ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
110 |
val platform_name = |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
111 |
if (platform == Platform.Family.windows) Platform.Family.native(platform) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
112 |
else Platform.Family.standard(platform) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
113 |
dir + Path.explode(platform_name) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
114 |
} |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
115 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
116 |
def build_dir(dir: Path): Path = dir + Path.explode(build_name) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
117 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
118 |
def environment: String = |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
119 |
(("MS_TAG=" + Bash.string(version)) :: "SHOULD_BUILD=yes" :: "VSCODE_ARCH=x64" :: env) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
120 |
.map(s => "export " + s + "\n").mkString |
75222 | 121 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
122 |
def patch_sources(base_dir: Path): String = |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
123 |
{ |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
124 |
val dir = base_dir + Path.explode("vscode") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
125 |
Isabelle_System.with_copy_dir(dir, dir.orig) { |
75249
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
126 |
// macos icns |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
127 |
for (name <- Seq("build/lib/electron.js", "build/lib/electron.ts")) { |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
128 |
File.change(dir + Path.explode(name), strict = true) { |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
129 |
_.replace("""'resources/darwin/' + icon + '.icns'""", |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
130 |
"""'resources/darwin/' + icon.toLowerCase() + '.icns'""") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
131 |
} |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
132 |
} |
75249
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
133 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
134 |
// isabelle_encoding.ts |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
135 |
{ |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
136 |
val common_dir = dir + Path.explode("src/vs/workbench/services/textfile/common") |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
137 |
val header = |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
138 |
split_lines(File.read(common_dir + Path.explode("encoding.ts"))) |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
139 |
.takeWhile(_.trim.nonEmpty) |
75253 | 140 |
make_isabelle_encoding(cat_lines(header)).write(common_dir) |
75249
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
141 |
} |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
142 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
143 |
// explicit patches |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
144 |
{ |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
145 |
val patches_dir = Path.explode("$ISABELLE_VSCODE_HOME/patches") |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
146 |
for (name <- Seq("isabelle_encoding")) { |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
147 |
val path = patches_dir + Path.basic(name).patch |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
148 |
Isabelle_System.bash("patch -p1 < " + File.bash_path(path), cwd = dir.file).check |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
149 |
} |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
150 |
} |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
151 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
152 |
Isabelle_System.make_patch(base_dir, dir.base.orig, dir.base) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
153 |
} |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
154 |
} |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
155 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
156 |
def patch_resources(base_dir: Path): String = |
75224 | 157 |
{ |
75252
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
158 |
val dir = base_dir + Path.explode("resources") |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
159 |
if (platform == Platform.Family.macos) { |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
160 |
Isabelle_System.symlink(base_dir + Path.explode("VSCodium.app/Contents/Resources"), dir) |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
161 |
} |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
162 |
Isabelle_System.with_copy_dir(dir, dir.orig) { |
75252
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
163 |
val fonts_dir = dir + Path.explode("app/out/vs/base/browser/ui/fonts") |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
164 |
HTML.init_fonts(fonts_dir.dir) |
75253 | 165 |
make_symbols().write(fonts_dir) |
75222 | 166 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
167 |
val workbench_css = dir + Path.explode("app/out/vs/workbench/workbench.desktop.main.css") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
168 |
val checksum1 = file_checksum(workbench_css) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
169 |
File.append(workbench_css, "\n\n" + HTML.fonts_css_dir(prefix = "../base/browser/ui")) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
170 |
val checksum2 = file_checksum(workbench_css) |
75222 | 171 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
172 |
val file_name = workbench_css.file_name |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
173 |
File.change_lines(dir + Path.explode("app/product.json")) { _.map(line => |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
174 |
if (line.containsSlice(file_name) && line.contains(checksum1)) { |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
175 |
line.replace(checksum1, checksum2) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
176 |
} |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
177 |
else line) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
178 |
} |
75222 | 179 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
180 |
Isabelle_System.make_patch(dir.dir, dir.orig.base, dir.base) |
75222 | 181 |
} |
182 |
} |
|
75224 | 183 |
|
75228
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
184 |
def node_binaries(dir: Path, progress: Progress): Unit = |
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
185 |
{ |
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
186 |
Isabelle_System.with_tmp_dir("download")(download_dir => |
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
187 |
{ |
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
188 |
download(download_dir, progress = progress) |
75252
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
189 |
for { |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
190 |
name <- Seq("resources/app/node_modules.asar", "resources/app/node_modules.asar.unpacked") |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
191 |
} { |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
192 |
val path = Path.explode(name) |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
193 |
Isabelle_System.rm_tree(dir + path) |
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
194 |
Isabelle_System.copy_dir(download_dir + path, dir + path) |
75228
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
195 |
} |
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
196 |
}) |
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
197 |
} |
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
198 |
|
75224 | 199 |
def setup_executables(dir: Path): Unit = |
200 |
{ |
|
201 |
val exe = vscodium_exe(dir) |
|
202 |
Isabelle_System.make_directory(exe.dir) |
|
203 |
||
204 |
platform match { |
|
205 |
case Platform.Family.macos => |
|
206 |
File.write(exe, macos_exe) |
|
207 |
File.set_executable(exe, true) |
|
208 |
case Platform.Family.windows => |
|
209 |
val files1 = File.find_files(exe.dir.file) |
|
210 |
val files2 = File.find_files(dir.file, pred = file => |
|
211 |
{ |
|
212 |
val name = file.getName |
|
213 |
name.endsWith(".dll") || name.endsWith(".exe") || name.endsWith(".node") |
|
214 |
}) |
|
215 |
for (file <- files1 ::: files2) File.set_executable(File.path(file), true) |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
216 |
Isabelle_System.bash("chmod -R o-w " + File.bash_path(dir)).check |
75224 | 217 |
case _ => |
218 |
} |
|
219 |
} |
|
75222 | 220 |
} |
221 |
||
75252
41dfe941c3da
inline Isabelle symbols into source text, so that "isabelle vscode" can start up properly without access to process.env or fs;
wenzelm
parents:
75250
diff
changeset
|
222 |
|
75222 | 223 |
// see https://github.com/microsoft/vscode/blob/main/build/gulpfile.vscode.js |
224 |
// function computeChecksum(filename) |
|
225 |
private def file_checksum(path: Path): String = |
|
226 |
{ |
|
227 |
val digest = MessageDigest.getInstance("MD5") |
|
228 |
digest.update(Bytes.read(path).array) |
|
229 |
Bytes(Base64.getEncoder.encode(digest.digest())) |
|
230 |
.text.replaceAll("=", "") |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
231 |
} |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
232 |
|
75224 | 233 |
private val platform_infos: Map[Platform.Family.Value, Platform_Info] = |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
234 |
Iterator( |
75224 | 235 |
Platform_Info(Platform.Family.linux, "linux-x64-{VERSION}.tar.gz", "VSCode-linux-x64", |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
236 |
List("OS_NAME=linux", "SKIP_LINUX_PACKAGES=True")), |
75224 | 237 |
Platform_Info(Platform.Family.linux_arm, "linux-arm64-{VERSION}.tar.gz", "VSCode-linux-arm64", |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
238 |
List("OS_NAME=linux", "SKIP_LINUX_PACKAGES=True", "VSCODE_ARCH=arm64")), |
75224 | 239 |
Platform_Info(Platform.Family.macos, "darwin-x64-{VERSION}.zip", "VSCode-darwin-x64", |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
240 |
List("OS_NAME=osx")), |
75224 | 241 |
Platform_Info(Platform.Family.windows, "win32-x64-{VERSION}.zip", "VSCode-win32-x64", |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
242 |
List("OS_NAME=windows", |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
243 |
"SHOULD_BUILD_ZIP=no", |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
244 |
"SHOULD_BUILD_EXE_SYS=no", |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
245 |
"SHOULD_BUILD_EXE_USR=no", |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
246 |
"SHOULD_BUILD_MSI=no", |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
247 |
"SHOULD_BUILD_MSI_NOUP=no"))) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
248 |
.map(info => info.platform -> info).toMap |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
249 |
|
75224 | 250 |
def the_platform_info(platform: Platform.Family.Value): Platform_Info = |
251 |
platform_infos.getOrElse(platform, error("No platform info for " + quote(platform.toString))) |
|
252 |
||
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
253 |
def linux_platform_info: Platform_Info = |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
254 |
the_platform_info(Platform.Family.linux) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
255 |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
256 |
|
75222 | 257 |
/* check system */ |
258 |
||
259 |
def check_system(platforms: List[Platform.Family.Value]): Unit = |
|
260 |
{ |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
261 |
if (Platform.family != Platform.Family.linux) error("Not a Linux/x86_64 system") |
75222 | 262 |
|
263 |
Isabelle_System.require_command("git") |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
264 |
Isabelle_System.require_command("node") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
265 |
Isabelle_System.require_command("yarn") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
266 |
Isabelle_System.require_command("jq") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
267 |
|
75222 | 268 |
if (platforms.contains(Platform.Family.windows)) { |
269 |
Isabelle_System.require_command("wine") |
|
270 |
} |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
271 |
|
75224 | 272 |
if (platforms.exists(platform => the_platform_info(platform).download_zip)) { |
273 |
Isabelle_System.require_command("unzip", test = "-h") |
|
274 |
} |
|
75222 | 275 |
} |
276 |
||
277 |
||
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
278 |
/* original repository clones and patches */ |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
279 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
280 |
def vscodium_patch(verbose: Boolean = false, progress: Progress = new Progress): String = |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
281 |
{ |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
282 |
val platform_info = linux_platform_info |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
283 |
check_system(List(platform_info.platform)) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
284 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
285 |
Isabelle_System.with_tmp_dir("vscodium")(vscodium_dir => |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
286 |
{ |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
287 |
platform_info.get_vscodium_repository(vscodium_dir, progress = progress) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
288 |
val vscode_dir = vscodium_dir + Path.basic("vscode") |
75250 | 289 |
progress.echo("Prepare ...") |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
290 |
Isabelle_System.with_copy_dir(vscode_dir, vscode_dir.orig) { |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
291 |
progress.bash( |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
292 |
List( |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
293 |
"set -e", |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
294 |
platform_info.environment, |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
295 |
"./prepare_vscode.sh", |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
296 |
// enforce binary diff of code.xpm |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
297 |
"cp vscode/resources/linux/code.png vscode/resources/linux/rpm/code.xpm" |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
298 |
).mkString("\n"), cwd = vscodium_dir.file, echo = verbose).check |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
299 |
Isabelle_System.make_patch(vscodium_dir, vscode_dir.orig.base, vscode_dir.base, |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
300 |
diff_options = "--exclude=.git --exclude=node_modules") |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
301 |
} |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
302 |
}) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
303 |
} |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
304 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
305 |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
306 |
/* build vscodium */ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
307 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
308 |
def default_platforms: List[Platform.Family.Value] = Platform.Family.list |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
309 |
|
75223 | 310 |
def macos_exe: String = |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
311 |
"""#!/usr/bin/env bash |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
312 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
313 |
unset CDPATH |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
314 |
VSCODE_PATH="$(cd "$(dirname "$0")"/../VSCodium.app/Contents; pwd)" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
315 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
316 |
ELECTRON="$VSCODE_PATH/MacOS/Electron" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
317 |
CLI="$VSCODE_PATH/Resources/app/out/cli.js" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
318 |
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
319 |
exit $? |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
320 |
""" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
321 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
322 |
def build_vscodium( |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
323 |
target_dir: Path = Path.current, |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
324 |
platforms: List[Platform.Family.Value] = default_platforms, |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
325 |
verbose: Boolean = false, |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
326 |
progress: Progress = new Progress): Unit = |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
327 |
{ |
75222 | 328 |
check_system(platforms) |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
329 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
330 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
331 |
/* component */ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
332 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
333 |
val component_name = "vscodium-" + version |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
334 |
val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component_name)) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
335 |
progress.echo("Component " + component_dir) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
336 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
337 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
338 |
/* patches */ |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
339 |
|
75250 | 340 |
progress.echo("* Building patches:") |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
341 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
342 |
val patches_dir = Isabelle_System.new_directory(component_dir + Path.basic("patches")) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
343 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
344 |
def write_patch(name: String, patch: String): Unit = |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
345 |
File.write(patches_dir + Path.explode(name).patch, patch) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
346 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
347 |
write_patch("01-vscodium", vscodium_patch(verbose = verbose, progress = progress)) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
348 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
349 |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
350 |
/* build */ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
351 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
352 |
for (platform <- platforms) yield { |
75224 | 353 |
val platform_info = the_platform_info(platform) |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
354 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
355 |
Isabelle_System.with_tmp_dir("vscodium")(vscodium_dir => |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
356 |
{ |
75250 | 357 |
progress.echo("* Building " + platform + ":") |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
358 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
359 |
platform_info.get_vscodium_repository(vscodium_dir, progress = progress) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
360 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
361 |
val sources_patch = platform_info.patch_sources(vscodium_dir) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
362 |
if (platform_info.is_linux) write_patch("02-isabelle_sources", sources_patch) |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
363 |
|
75250 | 364 |
progress.echo("Build ...") |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
365 |
progress.bash(platform_info.environment + "\n" + "./build.sh", |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
366 |
cwd = vscodium_dir.file, echo = verbose).check |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
367 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
368 |
if (platform_info.is_linux) { |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
369 |
Isabelle_System.copy_file(vscodium_dir + Path.explode("LICENSE"), component_dir) |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
370 |
} |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
371 |
|
75224 | 372 |
val platform_dir = platform_info.platform_dir(component_dir) |
373 |
Isabelle_System.copy_dir(platform_info.build_dir(vscodium_dir), platform_dir) |
|
75228
33fb3014876f
recover platform-specific node binaries from original download, notably for node-pty for Terminal;
wenzelm
parents:
75227
diff
changeset
|
374 |
platform_info.node_binaries(platform_dir, progress) |
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
375 |
|
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
376 |
val resources_patch = platform_info.patch_resources(platform_dir) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
377 |
if (platform_info.is_linux) write_patch("03-isabelle_resources", resources_patch) |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
378 |
|
75224 | 379 |
platform_info.setup_executables(platform_dir) |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
380 |
}) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
381 |
} |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
382 |
|
75231 | 383 |
Isabelle_System.bash("gzip *.patch", cwd = patches_dir.file).check |
384 |
||
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
385 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
386 |
/* settings */ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
387 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
388 |
val etc_dir = Isabelle_System.make_directory(component_dir + Path.explode("etc")) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
389 |
File.write(etc_dir + Path.basic("settings"), |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
390 |
"""# -*- shell-script -*- :mode=shellscript: |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
391 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
392 |
ISABELLE_VSCODIUM_HOME="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-$ISABELLE_PLATFORM64}" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
393 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
394 |
case "$ISABELLE_PLATFORM_FAMILY" in |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
395 |
linux) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
396 |
ISABELLE_ELECTRON="$ISABELLE_VSCODIUM_HOME/codium" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
397 |
;; |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
398 |
macos) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
399 |
ISABELLE_ELECTRON="$ISABELLE_VSCODIUM_HOME/VSCodium.app/Contents/MacOS/Electron" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
400 |
;; |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
401 |
windows) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
402 |
ISABELLE_ELECTRON="$ISABELLE_VSCODIUM_HOME/VSCodium.exe" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
403 |
;; |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
404 |
esac |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
405 |
""") |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
406 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
407 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
408 |
/* README */ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
409 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
410 |
File.write(component_dir + Path.basic("README"), |
75217 | 411 |
"This is VSCodium " + version + " from " + vscodium_repository + |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
412 |
""" |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
413 |
|
75230
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
414 |
It has been built from sources using "isabelle build_vscodium". This applies |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
415 |
a few changes required for Isabelle/VSCode, see "patches" directory for a |
bbbee54b1198
prepare patched version more thoroughly, with explicit patches;
wenzelm
parents:
75228
diff
changeset
|
416 |
formal record. |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
417 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
418 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
419 |
Makarius |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
420 |
""" + Date.Format.date(Date.now()) + "\n") |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
421 |
} |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
422 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
423 |
|
75249
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
424 |
/* Isabelle tool wrappers */ |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
425 |
|
75249
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
426 |
val isabelle_tool1 = |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
427 |
Isabelle_Tool("build_vscodium", "build component for VSCodium", |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
428 |
Scala_Project.here, args => |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
429 |
{ |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
430 |
var target_dir = Path.current |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
431 |
var platforms = default_platforms |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
432 |
var verbose = false |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
433 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
434 |
val getopts = Getopts(""" |
75249
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
435 |
Usage: build_vscodium [OPTIONS] |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
436 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
437 |
Options are: |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
438 |
-D DIR target directory (default ".") |
75217 | 439 |
-p NAMES platform families (default: """ + quote(platforms.mkString(",")) + """) |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
440 |
-v verbose |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
441 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
442 |
Build VSCodium from sources and turn it into an Isabelle component. |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
443 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
444 |
The build platform needs to be Linux with nodejs/yarn, jq, and wine |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
445 |
for targeting Windows. |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
446 |
""", |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
447 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
448 |
"p:" -> (arg => platforms = Library.space_explode(',', arg).map(Platform.Family.parse)), |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
449 |
"v" -> (_ => verbose = true)) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
450 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
451 |
val more_args = getopts(args) |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
452 |
if (more_args.nonEmpty) getopts.usage() |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
453 |
|
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
454 |
val progress = new Console_Progress() |
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
455 |
|
75217 | 456 |
build_vscodium(target_dir = target_dir, platforms = platforms, |
457 |
verbose = verbose, progress = progress) |
|
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
458 |
}) |
75249
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
459 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
460 |
val isabelle_tool2 = |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
461 |
Isabelle_Tool("vscode_patch", "patch VSCode source tree", |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
462 |
Scala_Project.here, args => |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
463 |
{ |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
464 |
var base_dir = Path.current |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
465 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
466 |
val getopts = Getopts(""" |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
467 |
Usage: vscode_patch [OPTIONS] |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
468 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
469 |
Options are: |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
470 |
-D DIR base directory (default ".") |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
471 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
472 |
Patch original VSCode source tree for use with Isabelle/VSCode. |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
473 |
""", |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
474 |
"D:" -> (arg => base_dir = Path.explode(arg))) |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
475 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
476 |
val more_args = getopts(args) |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
477 |
if (more_args.nonEmpty) getopts.usage() |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
478 |
|
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
479 |
val platform_info = the_platform_info(Platform.family) |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
480 |
platform_info.patch_sources(base_dir) |
8142e75320f6
patch VSCode source tree to support isabelle_encoding.ts;
wenzelm
parents:
75247
diff
changeset
|
481 |
}) |
75214
a51a0a704854
build component for VSCodium (cross-compiled from sources for all platforms);
wenzelm
parents:
diff
changeset
|
482 |
} |