Commit fd8e2150660bc8be47d6237f7821f0de2a30ccf6
1 parent
7f333a2a
now generate all files in given destination directory
Showing
3 changed files
with
36 additions
and
27 deletions
Show diff stats
src/generation/create_table.anubis
| ... | ... | @@ -101,14 +101,15 @@ define String |
| 101 | 101 | public define Maybe(One) |
| 102 | 102 | generate_create_table |
| 103 | 103 | ( |
| 104 | - List(HK_App) apps //list of the table model description | |
| 104 | + List(HK_App) apps, //list of the table model description | |
| 105 | + String dest_dir | |
| 105 | 106 | )= |
| 106 | 107 | //TODO manage version |
| 107 | 108 | with version = "1.0.0.0", |
| 108 | 109 | version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language |
| 109 | 110 | |
| 110 | - with file_name = "database/generated/migration/to_"+version+".anubis", | |
| 111 | - with script_file_name = "database/generated/migration/to_"+version+"_scripts.anubis", | |
| 111 | + with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis", | |
| 112 | + with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_scripts.anubis", | |
| 112 | 113 | |
| 113 | 114 | //create all necessary directories if doesn't exist. |
| 114 | 115 | make_directories(file_name); | ... | ... |
src/generation/files.anubis
| ... | ... | @@ -24,7 +24,8 @@ read check.anubis |
| 24 | 24 | define Maybe(One) |
| 25 | 25 | generate_table |
| 26 | 26 | ( |
| 27 | - HK_Table org_table | |
| 27 | + HK_Table org_table, //table to generate | |
| 28 | + String dest_dir //root directory of the generation | |
| 28 | 29 | ) |
| 29 | 30 | = |
| 30 | 31 | since org_table is hk_table(name, short_name, old_model, display), |
| ... | ... | @@ -34,7 +35,7 @@ define Maybe(One) |
| 34 | 35 | with model = hk_model([hk_column("id", p_key, []). columns], show_string ), |
| 35 | 36 | with table = hk_table(name, short_name, model, display), |
| 36 | 37 | println("Generating file for table ["+name+"]"); |
| 37 | - with file_name = "database/generated/"+name+".anubis", | |
| 38 | + with file_name = dest_dir+"database/generated/"+name+".anubis", | |
| 38 | 39 | |
| 39 | 40 | //create all necessary directories if doesn't exist. |
| 40 | 41 | make_directories(file_name); |
| ... | ... | @@ -62,39 +63,43 @@ define Maybe(One) |
| 62 | 63 | define One |
| 63 | 64 | make_all_tables |
| 64 | 65 | ( |
| 65 | - List(HK_Table) tables //list of the table model description | |
| 66 | + List(HK_Table) tables, //list of the table model description | |
| 67 | + String dest_dir | |
| 66 | 68 | ) |
| 67 | 69 | = |
| 68 | 70 | if tables is |
| 69 | 71 | { |
| 70 | 72 | [] then println("Generation finished"), |
| 71 | 73 | [h . t] then |
| 72 | - if generate_table(h) is | |
| 74 | + if generate_table(h, dest_dir) is | |
| 73 | 75 | { |
| 74 | 76 | failure then println("Generation error") |
| 75 | - success(_) then make_all_tables(t) | |
| 77 | + success(_) then make_all_tables(t, dest_dir) | |
| 76 | 78 | } |
| 77 | 79 | }. |
| 78 | 80 | |
| 79 | 81 | define One |
| 80 | 82 | make_all_tables |
| 81 | 83 | ( |
| 82 | - List(HK_App) apps | |
| 84 | + List(HK_App) apps, | |
| 85 | + String dest_dir | |
| 86 | + | |
| 83 | 87 | )= |
| 84 | 88 | map_forget((HK_App app) |-> since app is hk_app(app_name, _, _, tables), |
| 85 | 89 | println("generating tables for App ["+app_name+"]"); |
| 86 | - make_all_tables(tables), apps). | |
| 90 | + make_all_tables(tables, dest_dir), apps). | |
| 87 | 91 | |
| 88 | 92 | |
| 89 | 93 | define Maybe(One) |
| 90 | 94 | generate_vtm_file |
| 91 | 95 | ( |
| 92 | - List(String) transmit, | |
| 93 | - List(String) view, | |
| 94 | - List(String) edit, | |
| 95 | - List(String) writer | |
| 96 | + List(String) transmit, | |
| 97 | + List(String) view, | |
| 98 | + List(String) edit, | |
| 99 | + List(String) writer, | |
| 100 | + String dest_dir | |
| 96 | 101 | )= |
| 97 | - with file_name = "database/generated/vtm.anubis", | |
| 102 | + with file_name = dest_dir+"database/generated/vtm.anubis", | |
| 98 | 103 | if file(file_name, new) is |
| 99 | 104 | { |
| 100 | 105 | failure then println("can't create file "+file_name);failure, |
| ... | ... | @@ -138,16 +143,17 @@ define One |
| 138 | 143 | List(String) so_far_transmit, |
| 139 | 144 | List(String) so_far_view, |
| 140 | 145 | List(String) so_far_edit, |
| 141 | - List(String) so_far_writer | |
| 146 | + List(String) so_far_writer, | |
| 147 | + String dest_dir | |
| 142 | 148 | )= |
| 143 | 149 | if tables is |
| 144 | 150 | { |
| 145 | 151 | [] then |
| 146 | 152 | if apps is |
| 147 | 153 | { |
| 148 | - [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_writer));println("Generation finished"), | |
| 154 | + [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_writer, dest_dir));println("Generation finished"), | |
| 149 | 155 | [app . apps_t] then |
| 150 | - _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_writer) | |
| 156 | + _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_writer, dest_dir) | |
| 151 | 157 | |
| 152 | 158 | }, |
| 153 | 159 | |
| ... | ... | @@ -158,16 +164,17 @@ define One |
| 158 | 164 | with edit = "vtm_edit(\""+name+"\", get_editable_"+name+")", |
| 159 | 165 | with writer = "tm_writer(\""+name+"\", update_"+name+")", |
| 160 | 166 | |
| 161 | - _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [writer . so_far_writer]) | |
| 167 | + _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [writer . so_far_writer], dest_dir) | |
| 162 | 168 | }. |
| 163 | 169 | |
| 164 | 170 | define One |
| 165 | 171 | make_vtm |
| 166 | 172 | ( |
| 167 | - List(HK_App) apps //list of the applications | |
| 173 | + List(HK_App) apps, //list of the applications | |
| 174 | + String dest_dir | |
| 168 | 175 | ) |
| 169 | 176 | = |
| 170 | - _make_vtm(apps, [], [], [], [], []). | |
| 177 | + _make_vtm(apps, [], [], [], [], [], dest_dir). | |
| 171 | 178 | |
| 172 | 179 | |
| 173 | 180 | define Maybe(One) |
| ... | ... | @@ -183,13 +190,13 @@ define Maybe(One) |
| 183 | 190 | success(database) then |
| 184 | 191 | since database is hk_database(name, apps), |
| 185 | 192 | println("Generating models for Database "+name); |
| 186 | - make_all_tables(apps); | |
| 193 | + make_all_tables(apps, destination_dir); | |
| 187 | 194 | println("Generating VTM for Database "+name); |
| 188 | - make_vtm(apps); | |
| 195 | + make_vtm(apps, destination_dir); | |
| 189 | 196 | println("Generating create for Database "+name); |
| 190 | - if generate_create_table(apps) is failure then println("failure");failure else | |
| 197 | + if generate_create_table(apps, destination_dir) is failure then println("failure");failure else | |
| 191 | 198 | println("Generating menu for Database "+name); |
| 192 | - if generate_menus(apps) is failure then println("failure");failure else | |
| 199 | + if generate_menus(apps, destination_dir) is failure then println("failure");failure else | |
| 193 | 200 | success(unique) |
| 194 | 201 | }. |
| 195 | 202 | ... | ... |
src/generation/menu.anubis
| ... | ... | @@ -51,10 +51,11 @@ define String |
| 51 | 51 | public define Maybe(One) |
| 52 | 52 | generate_menus |
| 53 | 53 | ( |
| 54 | - List(HK_App) apps //list of the table model description | |
| 54 | + List(HK_App) apps, //list of the table model description | |
| 55 | + String dest_dir | |
| 55 | 56 | )= |
| 56 | 57 | |
| 57 | - with file_name = "web_pages/generated/apps_menu.anubis", | |
| 58 | + with file_name = dest_dir+"web_pages/generated/apps_menu.anubis", | |
| 58 | 59 | |
| 59 | 60 | //create all necessary directories if doesn't exist. |
| 60 | 61 | make_directories(file_name); | ... | ... |