author | wenzelm |
Fri, 29 Mar 2019 16:53:46 +0100 | |
changeset 70013 | 6de8b7a5cd44 |
parent 70011 | 9dde788b0128 |
child 70015 | c8e08d8ffb93 |
permissions | -rw-r--r-- |
68090 | 1 |
(* Title: Pure/Thy/export.ML |
2 |
Author: Makarius |
|
3 |
||
68102 | 4 |
Manage theory exports: compressed blobs. |
68090 | 5 |
*) |
6 |
||
7 |
signature EXPORT = |
|
8 |
sig |
|
70011 | 9 |
val check_name: Path.T -> string |
69788 | 10 |
type params = {theory: theory, path: Path.T, executable: bool, compress: bool} |
11 |
val export_params: params -> string list -> unit |
|
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
12 |
val export: theory -> Path.T -> string list -> unit |
69788 | 13 |
val export_executable: theory -> Path.T -> string list -> unit |
70013 | 14 |
val export_file: theory -> Path.T -> Path.T -> unit |
15 |
val export_executable_file: theory -> Path.T -> Path.T -> unit |
|
70009
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
16 |
val markup: theory -> Path.T -> Markup.T |
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
17 |
val message: theory -> Path.T -> string |
68090 | 18 |
end; |
19 |
||
20 |
structure Export: EXPORT = |
|
21 |
struct |
|
22 |
||
69648 | 23 |
(* export *) |
24 |
||
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
25 |
fun check_name path = |
68105 | 26 |
let |
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
27 |
val name = Path.implode path; |
69627 | 28 |
val _ = |
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
29 |
if not (Path.is_current path) andalso Path.all_basic path then () |
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
30 |
else error ("Bad export name: " ^ quote name); |
68105 | 31 |
in name end; |
32 |
||
69788 | 33 |
type params = {theory: theory, path: Path.T, executable: bool, compress: bool}; |
34 |
||
35 |
fun export_params ({theory, path, executable, compress}: params) blob = |
|
68090 | 36 |
(Output.try_protocol_message o Markup.export) |
37 |
{id = Position.get_id (Position.thread_data ()), |
|
68101 | 38 |
serial = serial (), |
69788 | 39 |
theory_name = Context.theory_long_name theory, |
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
40 |
name = check_name path, |
69788 | 41 |
executable = executable, |
42 |
compress = compress} blob; |
|
68090 | 43 |
|
70013 | 44 |
fun export thy path blob = |
45 |
export_params {theory = thy, path = path, executable = false, compress = true} blob; |
|
69788 | 46 |
|
70013 | 47 |
fun export_executable thy path blob = |
48 |
export_params {theory = thy, path = path, executable = true, compress = true} blob; |
|
49 |
||
50 |
fun export_file thy path file = export thy path [File.read file]; |
|
51 |
fun export_executable_file thy path file = export_executable thy path [File.read file]; |
|
68090 | 52 |
|
69648 | 53 |
|
54 |
(* information message *) |
|
55 |
||
70009
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
56 |
fun markup thy path = |
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
57 |
let |
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
58 |
val thy_path = Path.append (Path.basic (Context.theory_long_name thy)) path; |
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
59 |
val name = (Markup.nameN, Path.implode thy_path); |
69650 | 60 |
in Active.make_markup Markup.theory_exportsN {implicit = false, properties = [name]} end; |
69648 | 61 |
|
70009
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
62 |
fun message thy path = |
435fb018e8ee
"export_code ... file_prefix ..." is the preferred way to produce output within the logical file-system within the theory context, as well as session exports;
wenzelm
parents:
69788
diff
changeset
|
63 |
"See " ^ Markup.markup (markup thy path) "theory exports"; |
69648 | 64 |
|
68090 | 65 |
end; |