author | wenzelm |
Mon, 13 Mar 2023 11:02:26 +0100 | |
changeset 77622 | f458547b4f0f |
parent 77593 | 08ed864fed24 |
child 78158 | 8b5a2e4b16d4 |
permissions | -rw-r--r-- |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77035
diff
changeset
|
1 |
/* Title: Pure/Admin/component_sqlite.scala |
72346
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 |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77035
diff
changeset
|
10 |
object Component_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 |
|
76544 | 13 |
val default_download_url = |
77593 | 14 |
"https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.41.0.0/sqlite-jdbc-3.41.0.0.jar" |
76544 | 15 |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
16 |
def build_sqlite( |
76544 | 17 |
download_url: String = default_download_url, |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
18 |
progress: Progress = new Progress, |
75393 | 19 |
target_dir: Path = Path.current |
20 |
): Unit = { |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
21 |
val Download_Name = """^.*/([^/]+)\.jar""".r |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
22 |
val download_name = |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
23 |
download_url match { |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
24 |
case Download_Name(download_name) => download_name |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
25 |
case _ => error("Malformed jar download URL: " + quote(download_url)) |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
26 |
} |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
27 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
28 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
29 |
/* component */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
30 |
|
76518 | 31 |
val component_dir = |
76547 | 32 |
Components.Directory(target_dir + Path.basic(download_name)).create(progress = progress) |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
33 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
34 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
35 |
/* README */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
36 |
|
76518 | 37 |
File.write(component_dir.README, |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
38 |
"This is " + download_name + " from\n" + download_url + |
72444 | 39 |
"\n\n Makarius\n " + Date.Format.date(Date.now()) + "\n") |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
40 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
41 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
42 |
/* settings */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
43 |
|
76548 | 44 |
component_dir.write_settings(""" |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
45 |
ISABELLE_SQLITE_HOME="$COMPONENT" |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
46 |
|
76545 | 47 |
classpath "$ISABELLE_SQLITE_HOME/lib/""" + download_name + """.jar" |
72346
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 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
51 |
/* jar */ |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
52 |
|
77035 | 53 |
val jar = component_dir.lib + Path.basic(download_name).jar |
76545 | 54 |
Isabelle_System.make_directory(jar.dir) |
73566 | 55 |
Isabelle_System.download_file(download_url, jar, progress = progress) |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
56 |
|
75491 | 57 |
Isabelle_System.with_tmp_dir("build") { jar_dir => |
76543
fef0195f8d8e
clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents:
76518
diff
changeset
|
58 |
Isabelle_System.extract(jar, jar_dir) |
72346
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 = |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77035
diff
changeset
|
83 |
Isabelle_Tool("component_sqlite", "build Isabelle sqlite-jdbc component from official download", |
75394 | 84 |
Scala_Project.here, |
85 |
{ args => |
|
86 |
var target_dir = Path.current |
|
76544 | 87 |
var download_url = default_download_url |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
88 |
|
75394 | 89 |
val getopts = Getopts(""" |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77035
diff
changeset
|
90 |
Usage: isabelle component_sqlite [OPTIONS] DOWNLOAD |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
91 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
92 |
Options are: |
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
93 |
-D DIR target directory (default ".") |
76544 | 94 |
-U URL download URL |
95 |
(default: """" + default_download_url + """") |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
96 |
|
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
97 |
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
|
98 |
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
|
99 |
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
|
100 |
""", |
76544 | 101 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
102 |
"U:" -> (arg => download_url = arg)) |
|
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
103 |
|
75394 | 104 |
val more_args = getopts(args) |
76544 | 105 |
if (more_args.nonEmpty) getopts.usage() |
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 |
|
76544 | 109 |
build_sqlite(download_url = download_url, progress = progress, target_dir = target_dir) |
75394 | 110 |
}) |
72346
93e533198bf6
build Isabelle sqlite-jdbc component from official download;
wenzelm
parents:
diff
changeset
|
111 |
} |