Commit 999d714c authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add code to generate makefiles

parent ae9ef3de
......@@ -39,6 +39,14 @@ package body TASTE.Backend.Skeletons is
Exists (Path & "body-filename.tmplt") and then
Exists (Path & "header-filename.tmplt"));
-- Generate the content of the Makefile per function
function Process_Makefile (Path : String;
Content : Translate_Set) return String is
Tmplt_Makefile : constant String := Path & "makefile.tmplt";
begin
return Parse (Tmplt_Makefile, Content);
end Process_Makefile;
function Process_Interfaces (Interfaces : Interface_Vectors.Vector;
Path : String;
Target : Output) return Tag
......@@ -84,6 +92,11 @@ package body TASTE.Backend.Skeletons is
Path : constant String := Prefix & To_Lower (Language) & "/";
Proceed : constant Boolean := Is_Template_Present (Path);
Hdr_Tmpl : constant Translate_Set := +Assoc ("Name", Each.Name);
Make_Tmpl : constant Translate_Set := Makefile_Template
(F => Each,
Modules => Get_Module_List,
Files => Get_ASN1_File_List);
Make_Text : constant String := Process_Makefile (Path, Make_Tmpl);
Func_Tmpl : constant Func_As_Template :=
Template.Funcs.Element (To_String (Each.Name));
......@@ -126,6 +139,7 @@ package body TASTE.Backend.Skeletons is
(if Proceed then Parse
(Path & "body-filename.tmplt", Hdr_Tmpl)
else "");
Make_File : constant String := "Makefile";
Output : File_Type;
begin
if Proceed then
......@@ -147,6 +161,13 @@ package body TASTE.Backend.Skeletons is
else
Put_Info (Body_File & " already exists, ignoring");
end if;
Put_Info ("Generating " & Make_File & " for function "
& To_String (Each.Name));
Create (File => Output,
Mode => Out_File,
Name => Output_Src & Make_File);
Put_Line (Output, Make_Text);
Close (Output);
else
Put_Info ("Ignoring function " & To_String (Each.Name));
end if;
......@@ -163,12 +184,20 @@ package body TASTE.Backend.Skeletons is
end loop;
end Generate;
function Parameter_Template (Param : ASN1_Parameter; TI : Taste_Interface)
return Translate_Set
is
(+Assoc ("Type", Param.Sort) & Assoc ("Name", Param.Name)
& Assoc ("Interface_Kind", TI.RCM'Img)
& Assoc ("Direction", Param.Direction'Img));
-- function Parameter_Template (Param : ASN1_Parameter; TI : Taste_Interface)
-- return Translate_Set
-- is
-- (+Assoc ("Type", Param.Sort) & Assoc ("Name", Param.Name)
-- & Assoc ("Interface_Kind", TI.RCM'Img)
-- & Assoc ("Direction", Param.Direction'Img));
-- Makefiles need the function name and the list of ASN.1 files/modules
function Makefile_Template (F : Taste_Terminal_Function;
Modules : Tag;
Files : Tag) return Translate_Set
is (Translate_Set'(+Assoc ("Name", F.Name)
& Assoc ("ASN1_Files", Files)
& Assoc ("ASN1_Modules", Modules)));
function Interface_Template (TI : Taste_Interface)
return Interface_As_Template
......@@ -183,7 +212,7 @@ package body TASTE.Backend.Skeletons is
& Assoc ("Kind", TI.RCM'Img)
& Assoc ("Parent_Function", TI.Parent_Function);
for Each of TI.Params loop
Result.Params := Result.Params & Parameter_Template (Each, TI);
-- Result.Params := Result.Params & Parameter_Template (Each, TI);
Param_Names := Param_Names & Each.Name;
Param_Types := Param_Types & Each.Sort;
Param_Directions := Param_Directions & Each.Direction'Img;
......
......@@ -16,7 +16,7 @@ private
type Interface_As_Template is
record
Header : Translate_Set;
Params : Template_Vectors.Vector;
-- Params : Template_Vectors.Vector;
end record;
package Interface_Vectors is new Indefinite_Vectors (Natural,
......@@ -37,12 +37,15 @@ private
end record;
-- Set of functions translating the AST into Templates_Parser mappings
function Parameter_Template (Param : ASN1_Parameter; TI : Taste_Interface)
return Translate_Set;
-- function Parameter_Template (Param : ASN1_Parameter; TI : Taste_Interface)
-- return Translate_Set;
function Interface_Template (TI : Taste_Interface)
return Interface_As_Template;
function Func_Template (F : Taste_Terminal_Function)
return Func_As_Template;
function Makefile_Template (F : Taste_Terminal_Function;
Modules : Tag;
Files : Tag) return Translate_Set;
function Interface_View_Template (IV : Complete_Interface_View)
return IV_As_Template;
......
package TASTE.Parser_Version is
Parser_Release : constant String :=
"9ee5b52 ; Commit Date: Sat Feb 24 09:45:08 2018 ";
"ae9ef3d ; Commit Date: Thu Mar 1 08:54:53 2018 ";
Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from r61c0f39)";
end TASTE.Parser_Version;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment