author | wenzelm |
Sun, 20 Nov 2022 23:37:54 +0100 | |
changeset 76518 | b30b8e23383c |
parent 75491 | 47d790984e82 |
child 76543 | fef0195f8d8e |
permissions | -rw-r--r-- |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/Admin/build_sqlite.scala |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
3 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
4 |
Build Isabelle sqlite-jdbc component from official download. |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
6 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
8 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
9 |
|
75393 | 10 |
object Build_SQLite { |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
11 |
/* build sqlite */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
12 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
13 |
def build_sqlite( |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
14 |
download_url: String, |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
15 |
progress: Progress = new Progress, |
75393 | 16 |
target_dir: Path = Path.current |
17 |
): Unit = { |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
18 |
val Download_Name = """^.*/([^/]+)\.jar""".r |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
19 |
val download_name = |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
20 |
download_url match { |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
21 |
case Download_Name(download_name) => download_name |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
22 |
case _ => error("Malformed jar download URL: " + quote(download_url)) |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
23 |
} |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
24 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
25 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
26 |
/* component */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
27 |
|
76518 | 28 |
val component_dir = |
29 |
Components.Directory.create(target_dir + Path.basic(download_name), progress = progress) |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
30 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
31 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
32 |
/* README */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
33 |
|
76518 | 34 |
File.write(component_dir.README, |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
35 |
"This is " + download_name + " from\n" + download_url + |
72444 | 36 |
"\n\n Makarius\n " + Date.Format.date(Date.now()) + "\n") |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
37 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
38 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
39 |
/* settings */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
40 |
|
76518 | 41 |
File.write(component_dir.settings, |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
42 |
"""# -*- shell-script -*- :mode=shellscript: |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
43 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
44 |
ISABELLE_SQLITE_HOME="$COMPONENT" |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
45 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
46 |
classpath "$ISABELLE_SQLITE_HOME/""" + download_name + """.jar" |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
47 |
""") |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
48 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
49 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
50 |
/* jar */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
51 |
|
76518 | 52 |
val jar = component_dir.path + Path.basic(download_name).ext("jar") |
73566 | 53 |
Isabelle_System.download_file(download_url, jar, progress = progress) |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
54 |
|
75491 | 55 |
Isabelle_System.with_tmp_dir("build") { jar_dir => |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
56 |
progress.echo("Unpacking " + jar) |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
57 |
Isabelle_System.bash("isabelle_jdk jar xf " + File.bash_path(jar.absolute), |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
58 |
cwd = jar_dir.file).check |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
59 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
60 |
val jar_files = |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
61 |
List( |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
62 |
"META-INF/maven/org.xerial/sqlite-jdbc/LICENSE" -> ".", |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
63 |
"META-INF/maven/org.xerial/sqlite-jdbc/LICENSE.zentus" -> ".", |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
64 |
"org/sqlite/native/Linux/aarch64/libsqlitejdbc.so" -> "arm64-linux", |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
65 |
"org/sqlite/native/Linux/x86_64/libsqlitejdbc.so" -> "x86_64-linux", |
73000
a4efee8f8842
updated to sqlite-jdbc-3.34.0, with support for native arm64-darwin;
wenzelm
parents:
72763
diff
changeset
|
66 |
"org/sqlite/native/Mac/aarch64/libsqlitejdbc.jnilib" -> "arm64-darwin", |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
67 |
"org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib" -> "x86_64-darwin", |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
68 |
"org/sqlite/native/Windows/x86_64/sqlitejdbc.dll" -> "x86_64-windows") |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
69 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
70 |
for ((file, dir) <- jar_files) { |
76518 | 71 |
val target = Isabelle_System.make_directory(component_dir.path + Path.explode(dir)) |
73317 | 72 |
Isabelle_System.copy_file(jar_dir + Path.explode(file), target) |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
73 |
} |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
74 |
|
76518 | 75 |
File.set_executable(component_dir.path + Path.explode("x86_64-windows/sqlitejdbc.dll"), true) |
75394 | 76 |
} |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
77 |
} |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
78 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
79 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
80 |
/* Isabelle tool wrapper */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
81 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
82 |
val isabelle_tool = |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
83 |
Isabelle_Tool("build_sqlite", "build Isabelle sqlite-jdbc component from official download", |
75394 | 84 |
Scala_Project.here, |
85 |
{ args => |
|
86 |
var target_dir = Path.current |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
87 |
|
75394 | 88 |
val getopts = Getopts(""" |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
89 |
Usage: isabelle build_sqlite [OPTIONS] DOWNLOAD |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
90 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
91 |
Options are: |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
92 |
-D DIR target directory (default ".") |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
93 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
94 |
Build sqlite-jdbc component from the specified download URL (JAR), see also |
73000
a4efee8f8842
updated to sqlite-jdbc-3.34.0, with support for native arm64-darwin;
wenzelm
parents:
72763
diff
changeset
|
95 |
https://github.com/xerial/sqlite-jdbc and |
a4efee8f8842
updated to sqlite-jdbc-3.34.0, with support for native arm64-darwin;
wenzelm
parents:
72763
diff
changeset
|
96 |
https://oss.sonatype.org/content/repositories/releases/org/xerial/sqlite-jdbc |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
97 |
""", |
75394 | 98 |
"D:" -> (arg => target_dir = Path.explode(arg))) |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
99 |
|
75394 | 100 |
val more_args = getopts(args) |
101 |
val download_url = |
|
102 |
more_args match { |
|
103 |
case List(download_url) => download_url |
|
104 |
case _ => getopts.usage() |
|
105 |
} |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
106 |
|
75394 | 107 |
val progress = new Console_Progress() |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
108 |
|
75394 | 109 |
build_sqlite(download_url, progress = progress, target_dir = target_dir) |
110 |
}) |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
111 |
} |