Commit e27fb2ef authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Generate skeletons in files

parent 89bf5a8b
......@@ -166,6 +166,7 @@ package body TASTE.AADL_Parser is
| No_RCM_Error
| Deployment_View_Error
| Data_View_Error
| TASTE.Backend.Skeletons.Skeleton_Error
| Device_Driver_Error =>
Put (Red_Bold & "[ERROR] " & White_Bold);
Put_Line (Exception_Message (Error) & No_Color);
......
with Text_IO; use Text_IO;
with Ada.Strings.Unbounded,
Ada.Characters.Handling,
Ada.Exceptions,
Ada.Directories;
use Ada.Characters.Handling,
Ada.Exceptions,
Ada.Directories;
-- This package covers the generation of skeletons for all supported languages
......@@ -103,21 +105,48 @@ package body TASTE.Backend.Skeletons is
else "");
Output_Src : constant String :=
Model.Configuration.Output_Dir.all
& "/" & To_String (Each.Name)
& "/" & To_Lower (To_String (Each.Name))
& "/" & Language
& "/" & "src";
& "/" & "src" & "/";
-- Get header and body filenames from templates
Header_File : constant String :=
(if Proceed then Parse
(Path & "header-filename.tmplt", Hdr_Tmpl)
else "");
Body_File : constant String :=
(if Proceed then Parse
(Path & "body-filename.tmplt", Hdr_Tmpl)
else "");
Output : File_Type;
begin
if Proceed then
-- Create directory tree (output/function/language/src)
Create_Path (Output_Src);
Put ("*** Generating ");
Put_Line (Parse (Path & "header-filename.tmplt", Hdr_Tmpl));
Put_Line (Header_Text);
Put ("*** Generating ");
Put_Line (Parse (Path & "body-filename.tmplt", Hdr_Tmpl));
Put_Line (Body_Text);
Put_Line ("*** Generating " & Header_File);
Create (File => Output,
Mode => Out_File,
Name => Output_Src & Header_File);
Put_Line (Output, Header_Text);
Close (Output);
if not Exists (Output_Src & Body_File) then
Put_Line ("*** Generating " & Body_File);
Create (File => Output,
Mode => Out_File,
Name => Output_Src & Body_File);
Put_Line (Output, Body_Text);
Close (Output);
end if;
else
Put_Line ("Ignoring function " & To_String (Each.Name));
end if;
exception
when E : End_Error =>
if Is_Open (Output) then
Close (Output);
end if;
raise Skeleton_Error with "Generation of skeleton for function "
& To_String (Each.Name) & " failed : "
& Exception_Message (E);
end;
end loop;
end Generate;
......
......@@ -9,6 +9,7 @@ use Ada.Containers,
package TASTE.Backend.Skeletons is
procedure Generate (Model : TASTE_Model);
Skeleton_Error : exception;
private
package Template_Vectors is new Indefinite_Vectors (Natural, Translate_Set);
......
package TASTE.Parser_Version is
Parser_Release : constant String :=
"d47249d ; Commit Date: Tue Jan 23 22:13:30 2018 ";
"89bf5a8 ; Commit Date: Wed Jan 24 10:54:55 2018 ";
Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from r0b92ed3)";
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