diff --git a/src/generation/files.anubis b/src/generation/files.anubis index 8bc4b1b..9656d27 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -6,6 +6,7 @@ * © David RENÉ */ +read system/parameter/inifile.anubis read densaku_lib/types/densaku.anubis read densaku_lib/ds_generator.anubis read tools/basis.anubis @@ -20,7 +21,32 @@ public define Maybe(One) 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 then + success(println("Types and messages already generated, nothing to do")) + else if check_types(types) is { failure then failure, @@ -31,7 +57,9 @@ public define Maybe(One) 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) }. -- libgit2 0.21.4