| author | wenzelm |
| Thu, 17 Feb 2022 19:00:14 +0100 | |
| changeset 75083 | 35a5c4b16024 |
| parent 73340 | 0ffcad1f6130 |
| child 75143 | 4b740c1740eb |
| permissions | -rw-r--r-- |
| 65367 | 1 |
/* Title: Tools/VSCode/src/build_vscode.scala |
| 65138 | 2 |
Author: Makarius |
3 |
||
4 |
Build VSCode configuration and extension module for Isabelle. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle.vscode |
|
8 |
||
9 |
||
10 |
import isabelle._ |
|
11 |
||
12 |
||
13 |
object Build_VSCode |
|
14 |
{
|
|
15 |
val extension_dir = Path.explode("~~/src/Tools/VSCode/extension")
|
|
16 |
||
17 |
||
18 |
/* grammar */ |
|
19 |
||
| 73340 | 20 |
def build_grammar(options: Options, progress: Progress = new Progress): Unit = |
| 65138 | 21 |
{
|
| 72767 | 22 |
val logic = TextMate_Grammar.default_logic |
| 72627 | 23 |
val keywords = Sessions.base_info(options, logic).check.base.overall_syntax.keywords |
| 65138 | 24 |
|
| 72767 | 25 |
val output_path = extension_dir + Path.explode(TextMate_Grammar.default_output(logic)) |
| 65138 | 26 |
progress.echo(output_path.implode) |
| 72767 | 27 |
File.write_backup(output_path, TextMate_Grammar.generate(keywords)) |
| 65138 | 28 |
} |
29 |
||
30 |
||
31 |
/* extension */ |
|
32 |
||
| 73340 | 33 |
def build_extension(progress: Progress = new Progress, publish: Boolean = false): Unit = |
| 65138 | 34 |
{
|
35 |
val output_path = extension_dir + Path.explode("out")
|
|
36 |
progress.echo(output_path.implode) |
|
37 |
||
| 65164 | 38 |
progress.bash( |
| 66231 | 39 |
"npm install && npm update --dev && vsce package" + (if (publish) " && vsce publish" else ""), |
| 65164 | 40 |
cwd = extension_dir.file, echo = true).check |
| 65138 | 41 |
} |
42 |
||
43 |
||
44 |
/* Isabelle tool wrapper */ |
|
45 |
||
46 |
val isabelle_tool = |
|
| 72763 | 47 |
Isabelle_Tool("build_vscode", "build Isabelle/VSCode extension module",
|
48 |
Scala_Project.here, args => |
|
| 65138 | 49 |
{
|
50 |
var publish = false |
|
51 |
||
52 |
val getopts = Getopts("""
|
|
53 |
Usage: isabelle build_vscode |
|
54 |
||
55 |
Options are: |
|
56 |
-P publish the package |
|
57 |
||
58 |
Build Isabelle/VSCode extension module in directory |
|
59 |
""" + extension_dir.expand + """ |
|
60 |
||
61 |
This requires npm and the vsce build and publishing tool, see also |
|
62 |
https://code.visualstudio.com/docs/tools/vscecli |
|
63 |
""", |
|
64 |
"P" -> (_ => publish = true)) |
|
65 |
||
66 |
val more_args = getopts(args) |
|
67 |
if (more_args.nonEmpty) getopts.usage() |
|
68 |
||
69 |
val options = Options.init() |
|
70 |
val progress = new Console_Progress() |
|
71 |
||
72 |
build_grammar(options, progress) |
|
73 |
build_extension(progress, publish = publish) |
|
|
69277
258bef08b31e
support for user-defined Isabelle/Scala command-line tools;
wenzelm
parents:
66976
diff
changeset
|
74 |
}) |
| 65138 | 75 |
} |