taste-backend-build_script.adb 2.03 KB
Newer Older
1
with Text_IO,
2
3
     Templates_Parser,
     TASTE.Parser_Utils;
4
use  Text_IO,
5
6
     Templates_Parser,
     TASTE.Parser_Utils;
7
8
9

package body TASTE.Backend.Build_Script is
   procedure Generate (Model : TASTE_Model) is
Maxime Perrotin's avatar
Maxime Perrotin committed
10
11
      Prefix : constant String := Model.Configuration.Binary_Path.all
                                  & "templates/";
12
13
14
      Vec_Code : Tag;
      Vec_Zip  : Tag;
      Vec_Func : Tag;
15
   begin
16
17
      for Each of Model.Interface_View.Flat_Functions loop
         declare
Maxime Perrotin's avatar
Maxime Perrotin committed
18
19
            Template_Data : constant Translate_Table :=
               (1 => Assoc ("Function_Name", Each.Name),
20
                2 => Assoc ("Language", Language_Spelling (Each)));
Maxime Perrotin's avatar
Maxime Perrotin committed
21
22
23
24
25
26
            Element_Code : constant String :=
               Parse (Prefix & "build-script-gencode.tmplt", Template_Data);
            Element_Zip : constant String :=
               Parse (Prefix & "build-script-zip.tmplt", Template_Data);
            Element_Func : constant String :=
               Parse (Prefix & "build-script-func.tmplt", Template_Data);
27
         begin
Maxime Perrotin's avatar
Maxime Perrotin committed
28
29
30
31
32
33
34
35
36
            if Element_Code'Length > 0 then
               Vec_Code := Vec_Code & Element_Code;
            end if;
            if Element_Zip'Length > 0 then
               Vec_Zip  := Vec_Zip  & Element_Zip;
            end if;
            if Element_Func'Length > 0 then
               Vec_Func := Vec_Func & Element_Func;
            end if;
37
38
         end;
      end loop;
39
      Put_Info ("Generating build script");
Maxime Perrotin's avatar
Maxime Perrotin committed
40
41
42
43
44
45
46
47
48
49
50
51
      declare
         Template_Data : constant Translate_Table :=
            (1 => Assoc ("Interface_View_Path",
                         Model.Configuration.Interface_View.all),
             2 => Assoc ("Output_Path",   Model.Configuration.Output_Dir.all),
             3 => Assoc ("Generate_Code", Vec_Code),
             4 => Assoc ("Zip_Code",      Vec_Zip),
             5 => Assoc ("Functions",     Vec_Func),
             6 => Assoc ("CodeCoverage",  "# TODO"));
      begin
         Put_Line (Parse (Prefix & "build-script.tmplt", Template_Data));
      end;
52
53
   end Generate;
end TASTE.Backend.Build_Script;