Commit c0a6eb38c3df886dbf303c9cd8a2a38e3d19fb76
1 parent
610b9aa1
add sha1 signature for types and messages saved in file densaku.ini on the root …
…of destination directory. This prevent to generate same files during automatic generation on project compilation time
Showing
1 changed file
with
29 additions
and
1 deletions
Show diff stats
src/generation/files.anubis
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | * © David RENÉ | 6 | * © David RENÉ |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | +read system/parameter/inifile.anubis | ||
| 9 | read densaku_lib/types/densaku.anubis | 10 | read densaku_lib/types/densaku.anubis |
| 10 | read densaku_lib/ds_generator.anubis | 11 | read densaku_lib/ds_generator.anubis |
| 11 | read tools/basis.anubis | 12 | read tools/basis.anubis |
| @@ -20,7 +21,32 @@ public define Maybe(One) | @@ -20,7 +21,32 @@ public define Maybe(One) | ||
| 20 | List(DS_Message) messages, | 21 | List(DS_Message) messages, |
| 21 | String destination_dir | 22 | String destination_dir |
| 22 | )= | 23 | )= |
| 24 | + //before processing the generation we check if we need to do it, by checking the SHA1 generated with the | ||
| 25 | + //previous generation. If SHA1 is same, this means the database is exactly same and we have nothing to do. | ||
| 26 | + //This behaviour prevent to generate same database during automatic generation on compilation time. | ||
| 27 | + | ||
| 28 | + //process. We serialize the types and messages model and make SHA1 of the result. This result is stored in file densaku.ini | ||
| 29 | + //in root of destination_dir | ||
| 30 | + with current_types_SHA1 = to_ascii(sha1(serialize(types))), | ||
| 31 | + with current_messages_SHA1 = to_ascii(sha1(serialize(messages))), | ||
| 32 | + | ||
| 33 | + println("\nDensaku Generator"); | ||
| 34 | + println("Destination dir: "+destination_dir); | ||
| 35 | + with ini = loadIniFile(destination_dir+"/densaku.ini"), | ||
| 36 | + | ||
| 37 | + with types_SHA1 = readString(ini, "TYPES", "SHA1", "N/A"), | ||
| 38 | + with messages_SHA1 = readString(ini, "MESSAGES", "SHA1", "N/A"), | ||
| 39 | + | ||
| 40 | + println("Saved Types SHA1 = "+types_SHA1); | ||
| 41 | + println("Current Types SHA1 = "+current_types_SHA1); | ||
| 42 | + | ||
| 43 | + println("Saved Messages SHA1 = "+messages_SHA1); | ||
| 44 | + println("Current Messages SHA1 = "+messages_SHA1); | ||
| 23 | 45 | ||
| 46 | + | ||
| 47 | + if types_SHA1 = current_types_SHA1 then | ||
| 48 | + success(println("Types and messages already generated, nothing to do")) | ||
| 49 | + else | ||
| 24 | if check_types(types) is | 50 | if check_types(types) is |
| 25 | { | 51 | { |
| 26 | failure then failure, | 52 | failure then failure, |
| @@ -31,7 +57,9 @@ public define Maybe(One) | @@ -31,7 +57,9 @@ public define Maybe(One) | ||
| 31 | 57 | ||
| 32 | println("Generating messages collection"); | 58 | println("Generating messages collection"); |
| 33 | make_all_messages(messages, destination_dir); | 59 | make_all_messages(messages, destination_dir); |
| 34 | - | 60 | + writeString(ini, "TYPES", "SHA1", current_types_SHA1); |
| 61 | + writeString(ini, "MESSAGES", "SHA1", current_messages_SHA1); | ||
| 62 | + writeIniInfo(ini); | ||
| 35 | success(unique) | 63 | success(unique) |
| 36 | }. | 64 | }. |
| 37 | 65 |