diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index f20e895..af00812 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -47,12 +47,12 @@ public define String if t is { //anubis(_T) then "ByteArray", - p_key then "extern_type(\"DB_id\", \"calexium_lib/model/db_types.anubis\")", + p_key then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")", //binary then "ByteArray", boolean_field then "bool", - date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/model/db_types.anubis\")", - time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/model/db_types.anubis\")", - datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/model/db_types.anubis\")", + date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")", + time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")", + datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/database/db_types.anubis\")", foreign_key(_,_) then "int", integer_field(_) then "int", char_field(_,_) then "string", diff --git a/src/generation/files.anubis b/src/generation/files.anubis index fad1353..a8ce8fd 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -8,6 +8,7 @@ read system/string.anubis read system/files.anubis +read system/parameter/inifile.anubis read hayamiki_lib/types/hayamiki.anubis read hayamiki_lib/hk_generator.anubis @@ -206,8 +207,25 @@ define Maybe(One) String destination_dir, Bool use_densaku )= - - if check_database(db) is + //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 database model and make SHA1 of the result. This result is stored in file hayamiki.ini + //in root of destination_dir + + println("\nHayamiki Generator"); + println("Destination dir: "+destination_dir); + with ini = loadIniFile(destination_dir+"/hayamiki.ini"), + + with db_SHA1 = readString(ini, "DB_MODEL", "SHA1", "N/A"), + println("Saved DB model SHA1 = "+db_SHA1); + with current_db_SHA1 = to_ascii(sha1(serialize(db))), + println("Current DB model SHA1 = "+current_db_SHA1); + + if db_SHA1 = current_db_SHA1 then + success(println("Model already generated, nothing to do")) + else if check_database(db) is { failure then println("Check database error");failure, success(database) then @@ -220,7 +238,9 @@ define Maybe(One) if generate_create_table(apps, destination_dir) is failure then println("failure");failure else println("Generating menu for Database "+name); if generate_menus(apps, destination_dir) is failure then println("failure");failure else - success(unique) + writeString(ini, "DB_MODEL", "SHA1", current_db_SHA1); + writeIniInfo(ini); + success(unique) }. diff --git a/src/generation/types.anubis b/src/generation/types.anubis index e50910e..1ddb439 100644 --- a/src/generation/types.anubis +++ b/src/generation/types.anubis @@ -44,7 +44,7 @@ public define Maybe(One) //if we use densaku for generating the type, we insert the read of that type after densaku generation if use_densaku then write_string(stream, - "\n\nread types/generated/ "+to_lower(type_name)+".anubis\n") //read of the type declaration + "\n\ntransmit types/generated/"+to_lower(type_name)+".anubis\n") //read of the type declaration else -- libgit2 0.21.4