files.anubis
2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 15/01/2017
* Time: 23:40
* © David RENÉ
*/
read system/parameter/inifile.anubis
read densaku_lib/types/densaku.anubis
read densaku_lib/ds_generator.anubis
read tools/basis.anubis
read types_checking.anubis
read generation/types.anubis //generate all types and the message for these types
read generation/messages.anubis //generate all messages collection
public define Maybe(One)
generate_message_files
(
List(DS_Type) types, //Types description
List(DS_Message) messages,
String destination_dir
)=
//before processing the generation we check if we need to do it, by checking the SHA1 generated with the
//previous generation. If SHA1 is same, this means the database is exactly same and we have nothing to do.
//This behaviour prevent to generate same database during automatic generation on compilation time.
//process. We serialize the types and messages model and make SHA1 of the result. This result is stored in file densaku.ini
//in root of destination_dir
with current_types_SHA1 = to_ascii(sha1(serialize(types))),
with current_messages_SHA1 = to_ascii(sha1(serialize(messages))),
println("\nDensaku Generator");
println("Destination dir: "+destination_dir);
with ini = loadIniFile(destination_dir+"/densaku.ini"),
with types_SHA1 = readString(ini, "TYPES", "SHA1", "N/A"),
with messages_SHA1 = readString(ini, "MESSAGES", "SHA1", "N/A"),
println("Saved Types SHA1 = "+types_SHA1);
println("Current Types SHA1 = "+current_types_SHA1);
println("Saved Messages SHA1 = "+messages_SHA1);
println("Current Messages SHA1 = "+messages_SHA1);
if types_SHA1 = current_types_SHA1 & messages_SHA1 = current_messages_SHA1 then
success(println("Types and messages already generated, nothing to do"))
else
if check_types(types) is
{
failure then failure,
success(_) then
println("Generating types and message files");
make_all_types(types, destination_dir);
println("Generating messages collection");
make_all_messages(messages, destination_dir);
writeString(ini, "TYPES", "SHA1", current_types_SHA1);
writeString(ini, "MESSAGES", "SHA1", current_messages_SHA1);
writeIniInfo(ini);
success(unique)
}.
global define DS_Generator_API
ds_gen =
ds_api(generate_message_files).