Commit a8403c5a43986eacbe199ff3a9264b50360068fd

Authored by totoro
1 parent 4248dece

add sha1 signature for db_model saved in file hayamiki.ini on the root of destin…

…ation directory. This prevent to generate same files during automatic generation on project compilation time
change the read path for db_types in calexium_lib
replace read by transmit when including the type declaration file
src/generation/fields.anubis
@@ -47,12 +47,12 @@ public define String @@ -47,12 +47,12 @@ public define String
47 if t is 47 if t is
48 { 48 {
49 //anubis(_T) then "ByteArray", 49 //anubis(_T) then "ByteArray",
50 - p_key then "extern_type(\"DB_id\", \"calexium_lib/model/db_types.anubis\")", 50 + p_key then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")",
51 //binary then "ByteArray", 51 //binary then "ByteArray",
52 boolean_field then "bool", 52 boolean_field then "bool",
53 - date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/model/db_types.anubis\")",  
54 - time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/model/db_types.anubis\")",  
55 - datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/model/db_types.anubis\")", 53 + date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")",
  54 + time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")",
  55 + datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/database/db_types.anubis\")",
56 foreign_key(_,_) then "int", 56 foreign_key(_,_) then "int",
57 integer_field(_) then "int", 57 integer_field(_) then "int",
58 char_field(_,_) then "string", 58 char_field(_,_) then "string",
src/generation/files.anubis
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 8
9 read system/string.anubis 9 read system/string.anubis
10 read system/files.anubis 10 read system/files.anubis
  11 +read system/parameter/inifile.anubis
11 12
12 read hayamiki_lib/types/hayamiki.anubis 13 read hayamiki_lib/types/hayamiki.anubis
13 read hayamiki_lib/hk_generator.anubis 14 read hayamiki_lib/hk_generator.anubis
@@ -206,8 +207,25 @@ define Maybe(One) @@ -206,8 +207,25 @@ define Maybe(One)
206 String destination_dir, 207 String destination_dir,
207 Bool use_densaku 208 Bool use_densaku
208 )= 209 )=
209 -  
210 - if check_database(db) is 210 + //before processing the generation we check if we need to do it, by checking the SHA1 generated with the
  211 + //previous generation. If SHA1 is same, this means the database is exactly same and we have nothing to do.
  212 + //This behaviour prevent to generate same database during automatic generation on compilation time.
  213 +
  214 + //process. We serialize the database model and make SHA1 of the result. This result is stored in file hayamiki.ini
  215 + //in root of destination_dir
  216 +
  217 + println("\nHayamiki Generator");
  218 + println("Destination dir: "+destination_dir);
  219 + with ini = loadIniFile(destination_dir+"/hayamiki.ini"),
  220 +
  221 + with db_SHA1 = readString(ini, "DB_MODEL", "SHA1", "N/A"),
  222 + println("Saved DB model SHA1 = "+db_SHA1);
  223 + with current_db_SHA1 = to_ascii(sha1(serialize(db))),
  224 + println("Current DB model SHA1 = "+current_db_SHA1);
  225 +
  226 + if db_SHA1 = current_db_SHA1 then
  227 + success(println("Model already generated, nothing to do"))
  228 + else if check_database(db) is
211 { 229 {
212 failure then println("Check database error");failure, 230 failure then println("Check database error");failure,
213 success(database) then 231 success(database) then
@@ -220,7 +238,9 @@ define Maybe(One) @@ -220,7 +238,9 @@ define Maybe(One)
220 if generate_create_table(apps, destination_dir) is failure then println("failure");failure else 238 if generate_create_table(apps, destination_dir) is failure then println("failure");failure else
221 println("Generating menu for Database "+name); 239 println("Generating menu for Database "+name);
222 if generate_menus(apps, destination_dir) is failure then println("failure");failure else 240 if generate_menus(apps, destination_dir) is failure then println("failure");failure else
223 - success(unique) 241 + writeString(ini, "DB_MODEL", "SHA1", current_db_SHA1);
  242 + writeIniInfo(ini);
  243 + success(unique)
224 }. 244 }.
225 245
226 246
src/generation/types.anubis
@@ -44,7 +44,7 @@ public define Maybe(One) @@ -44,7 +44,7 @@ public define Maybe(One)
44 //if we use densaku for generating the type, we insert the read of that type after densaku generation 44 //if we use densaku for generating the type, we insert the read of that type after densaku generation
45 if use_densaku then 45 if use_densaku then
46 write_string(stream, 46 write_string(stream,
47 - "\n\nread types/generated/ "+to_lower(type_name)+".anubis\n") //read of the type declaration 47 + "\n\ntransmit types/generated/"+to_lower(type_name)+".anubis\n") //read of the type declaration
48 48
49 else 49 else
50 50