Commit 354e6571 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Rename generated template documentation

parent f4c9cf64
with System.OS_Lib, with Text_IO,
Text_IO,
Ada.Exceptions, Ada.Exceptions,
Ada.Directories, Ada.Directories,
Templates_Parser, Templates_Parser,
TASTE.Parser_Utils; TASTE.Parser_Utils;
use System.OS_Lib, use Text_IO,
Text_IO,
Ada.Exceptions, Ada.Exceptions,
Ada.Directories, Ada.Directories,
Templates_Parser, Templates_Parser,
...@@ -15,61 +13,21 @@ package body TASTE.Backend.Build_Script is ...@@ -15,61 +13,21 @@ package body TASTE.Backend.Build_Script is
procedure Generate (Model : TASTE_Model) is procedure Generate (Model : TASTE_Model) is
Prefix : constant String := Prefix : constant String :=
Model.Configuration.Binary_Path.Element & "templates/"; Model.Configuration.Binary_Path.Element & "templates/";
Vec_Code : Tag;
Vec_Zip : Tag;
Vec_Func : Tag;
begin begin
for Each of Model.Interface_View.Flat_Functions loop Put_Info ("Generating legacy build-script.sh");
declare
Template_Data : constant Translate_Table :=
(1 => Assoc ("Function_Name", Each.Name),
2 => Assoc ("Language", Language_Spelling (Each)));
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);
begin
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;
end;
end loop;
Put_Info ("Generating build script");
declare declare
Template_Data : constant Translate_Set := Template_Data : constant Translate_Set :=
+Assoc ("Interface_View_Path", +Assoc ("Interface_View_Path",
Model.Configuration.Interface_View.Element) Model.Configuration.Interface_View.Element)
& Assoc ("Output_Path", Model.Configuration.Output_Dir.Element) & Assoc ("Output_Path", Model.Configuration.Output_Dir.Element);
& Assoc ("Generate_Code", Vec_Code)
& Assoc ("Zip_Code", Vec_Zip)
& Assoc ("Functions", Vec_Func)
& Assoc ("CodeCoverage", "# TODO");
Result : constant String := Parse (Prefix & "build-script.tmplt", Result : constant String := Parse (Prefix & "build-script.tmplt",
Template_Data); Template_Data);
Output_Path : constant String := Output_Path : constant String :=
Model.Configuration.Output_Dir.Element; Model.Configuration.Output_Dir.Element;
Filename : constant String := Output_Path & "/build-script.sh"; Filename : constant String := Output_Path & "/build-script.sh";
Output : File_Type; Output : File_Type;
Success : Boolean;
begin begin
Create_Path (Output_Path); Create_Path (Output_Path);
if Exists (Filename) then
Put_Info ("Making backup of build script (build-script.sh.old)");
Rename_File (Old_Name => Filename,
New_Name => Output_Path & "/build-script.sh.old",
Success => Success);
if not Success then
raise Backend_Error with "Impossible to rename build-script.sh";
end if;
end if;
Create (File => Output, Mode => Out_File, Name => Filename); Create (File => Output, Mode => Out_File, Name => Filename);
Put_Line (Output, Result); Put_Line (Output, Result);
Close (Output); Close (Output);
......
...@@ -2,5 +2,9 @@ with TASTE.AADL_Parser; ...@@ -2,5 +2,9 @@ with TASTE.AADL_Parser;
use TASTE.AADL_Parser; use TASTE.AADL_Parser;
package TASTE.Backend.Build_Script is package TASTE.Backend.Build_Script is
-- The generation of the build script is there for legacy purpose only
-- It is deprecated and only ensures backward compatibility with
-- Buildsupport/Orchestrator build habits.
-- Kazoo generates a Makefile in place of this build script.
procedure Generate (Model : TASTE_Model); procedure Generate (Model : TASTE_Model);
end TASTE.Backend.Build_Script; end TASTE.Backend.Build_Script;
...@@ -104,7 +104,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -104,7 +104,7 @@ package body TASTE.Backend.Code_Generators is
Create (File => Output_File, Create (File => Output_File,
Mode => Out_File, Mode => Out_File,
Name => Model.Configuration.Output_Dir.Element & "/Makefile"); Name => Model.Configuration.Output_Dir.Element & "/Makefile");
Document_Template (Template_Main_Makefile, Content_Set); Document_Template (Templates_Skeletons_Makefile, Content_Set);
Put_Line (Output_File, Parse (Tmplt, Content_Set)); Put_Line (Output_File, Parse (Tmplt, Content_Set));
Close (Output_File); Close (Output_File);
end Generate_Global_Makefile; end Generate_Global_Makefile;
...@@ -117,7 +117,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -117,7 +117,7 @@ package body TASTE.Backend.Code_Generators is
Tmplt_Sign : constant String := Path & "interface.tmplt"; Tmplt_Sign : constant String := Path & "interface.tmplt";
begin begin
for Each of Interfaces loop for Each of Interfaces loop
Document_Template (Template_Skeleton_Interface, Each); Document_Template (Templates_Skeletons_Sub_Interface, Each);
Result := Result & String'(Parse (Tmplt_Sign, Each)); Result := Result & String'(Parse (Tmplt_Sign, Each));
end loop; end loop;
return Result; return Result;
...@@ -137,7 +137,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -137,7 +137,7 @@ package body TASTE.Backend.Code_Generators is
CP_File_Dash : Unbounded_String; CP_File_Dash : Unbounded_String;
begin begin
Document_Template (Template_Context_Parameters, CP_Tmpl); Document_Template (Templates_Skeletons_Context_Parameters, CP_Tmpl);
-- To keep backward compatibility, file name uses dash -- To keep backward compatibility, file name uses dash
for C of CP_File loop for C of CP_File loop
CP_File_Dash := CP_File_Dash & (if C = '_' then '-' else C); CP_File_Dash := CP_File_Dash & (if C = '_' then '-' else C);
...@@ -203,7 +203,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -203,7 +203,7 @@ package body TASTE.Backend.Code_Generators is
Output_Dir : constant String := Output_Lang & Output_Sub; Output_Dir : constant String := Output_Lang & Output_Sub;
begin begin
Document_Template (Template_Skeleton_Makefile, Make_Tmpl); Document_Template (Templates_Skeletons_Sub_Makefile, Make_Tmpl);
-- Create directory tree (output/function/language/src) -- Create directory tree (output/function/language/src)
Create_Path (Output_Dir); Create_Path (Output_Dir);
if File_Name /= "" then if File_Name /= "" then
...@@ -332,12 +332,12 @@ package body TASTE.Backend.Code_Generators is ...@@ -332,12 +332,12 @@ package body TASTE.Backend.Code_Generators is
and then Strip_String (Parse and then Strip_String (Parse
(Path & "/trigger.tmplt", Trig_Tmpl)) = "TRUE"); (Path & "/trigger.tmplt", Trig_Tmpl)) = "TRUE");
begin begin
Document_Template (Template_Skeleton_Function_Filename, Document_Template
File_Tmpl); (Templates_Skeletons_Sub_Function_Filename, File_Tmpl);
Document_Template (Template_Skeleton_Makefile_Filename, Document_Template
File_Tmpl); (Templates_Skeletons_Sub_Makefile_Filename, File_Tmpl);
Document_Template (Template_Skeleton_And_Glue_Trigger, Document_Template
Trig_Tmpl); (Templates_Skeletons_Sub_Trigger, Trig_Tmpl);
if Trigger then if Trigger then
-- Output code and Makefile from this template folder -- Output code and Makefile from this template folder
Process_Template (F => Each, Process_Template (F => Each,
......
...@@ -252,7 +252,8 @@ package body TASTE.Concurrency_View is ...@@ -252,7 +252,8 @@ package body TASTE.Concurrency_View is
-- Part_File_Name may contain a subfolder -- Part_File_Name may contain a subfolder
Subfolder : Unbounded_String; Subfolder : Unbounded_String;
begin begin
Document_Template (Template_CV_File_Part, Part_Tag); Document_Template
(Templates_Concurrency_View_Sub_File_Part, Part_Tag);
for Each of Partition.In_Ports loop for Each of Partition.In_Ports loop
Input_Port_Names := Input_Port_Names & Each.Port_Name; Input_Port_Names := Input_Port_Names & Each.Port_Name;
Input_Port_Type_Name := Input_Port_Type_Name Input_Port_Type_Name := Input_Port_Type_Name
...@@ -294,8 +295,11 @@ package body TASTE.Concurrency_View is ...@@ -294,8 +295,11 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Thread_File_Id, Thread_Tag)) then Strip_String (Parse (Thread_File_Id, Thread_Tag))
else ""); else "");
begin begin
Document_Template (Template_CV_Thread, Thread_Assoc); Document_Template
Document_Template (Template_CV_File_Thread, Thread_Tag); (Templates_Concurrency_View_Sub_Thread, Thread_Assoc);
Document_Template
(Templates_Concurrency_View_Sub_File_Thread,
Thread_Tag);
Threads := Threads & Newline & Result; Threads := Threads & Newline & Result;
Part_Threads := Part_Threads & Newline & Result; Part_Threads := Part_Threads & Newline & Result;
...@@ -362,7 +366,8 @@ package body TASTE.Concurrency_View is ...@@ -362,7 +366,8 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Block_File_Id, Block_Tag)) then Strip_String (Parse (Block_File_Id, Block_Tag))
else ""); else "");
begin begin
Document_Template (Template_CV_File_Block, Block_Tag); Document_Template
(Templates_Concurrency_View_Sub_File_Block, Block_Tag);
Block_Names := Block_Names & Block_Name; Block_Names := Block_Names & Block_Name;
All_Block_Names := All_Block_Names & Block_Name; All_Block_Names := All_Block_Names & Block_Name;
Block_Languages := Block_Languages Block_Languages := Block_Languages
...@@ -372,7 +377,7 @@ package body TASTE.Concurrency_View is ...@@ -372,7 +377,7 @@ package body TASTE.Concurrency_View is
for PI_Assoc of Tmpl.Protected_Provided loop for PI_Assoc of Tmpl.Protected_Provided loop
Document_Template Document_Template
(Template_CV_PI, (Templates_Concurrency_View_Sub_PI,
PI_Assoc & Assoc ("Partition_Name", "")); PI_Assoc & Assoc ("Partition_Name", ""));
Pro_PI_Tag := Pro_PI_Tag & Newline Pro_PI_Tag := Pro_PI_Tag & Newline
& String'(Parse (Path & "/pi.tmplt", & String'(Parse (Path & "/pi.tmplt",
...@@ -387,7 +392,7 @@ package body TASTE.Concurrency_View is ...@@ -387,7 +392,7 @@ package body TASTE.Concurrency_View is
end loop; end loop;
for RI_Assoc of Tmpl.Required loop for RI_Assoc of Tmpl.Required loop
Document_Template Document_Template
(Template_CV_RI, (Templates_Concurrency_View_Sub_RI,
RI_Assoc & Assoc ("Partition_Name", "")); RI_Assoc & Assoc ("Partition_Name", ""));
RI_Tag := RI_Tag & Newline RI_Tag := RI_Tag & Newline
...@@ -405,7 +410,8 @@ package body TASTE.Concurrency_View is ...@@ -405,7 +410,8 @@ package body TASTE.Concurrency_View is
& Assoc ("Required", RI_Tag); & Assoc ("Required", RI_Tag);
Result := Parse (Path & "/block.tmplt", Block_Assoc); Result := Parse (Path & "/block.tmplt", Block_Assoc);
Document_Template (Template_CV_Block, Block_Assoc); Document_Template
(Templates_Concurrency_View_Sub_Block, Block_Assoc);
Blocks := Blocks & Newline & To_String (Result); Blocks := Blocks & Newline & To_String (Result);
...@@ -451,7 +457,8 @@ package body TASTE.Concurrency_View is ...@@ -451,7 +457,8 @@ package body TASTE.Concurrency_View is
Part_Content := Part_Content :=
Parse (Path & "/partition.tmplt", Partition_Assoc); Parse (Path & "/partition.tmplt", Partition_Assoc);
Document_Template (Template_CV_Partition, Partition_Assoc); Document_Template
(Templates_Concurrency_View_Sub_Partition, Partition_Assoc);
-- Save the content of the partition in a file -- Save the content of the partition in a file
-- (if required at template folder level) -- (if required at template folder level)
...@@ -532,7 +539,8 @@ package body TASTE.Concurrency_View is ...@@ -532,7 +539,8 @@ package body TASTE.Concurrency_View is
CV.Nodes (Node_Name).Deployment_Node.Package_Name) CV.Nodes (Node_Name).Deployment_Node.Package_Name)
& Assoc ("Ada_Runtime", & Assoc ("Ada_Runtime",
CV.Nodes (Node_Name).Deployment_Node.Ada_Runtime); CV.Nodes (Node_Name).Deployment_Node.Ada_Runtime);
Document_Template (Template_CV_Node, Node_Assoc); Document_Template
(Templates_Concurrency_View_Sub_Node, Node_Assoc);
return Parse (Path & "/node.tmplt", Node_Assoc); return Parse (Path & "/node.tmplt", Node_Assoc);
end Generate_Node; end Generate_Node;
...@@ -656,8 +664,10 @@ package body TASTE.Concurrency_View is ...@@ -656,8 +664,10 @@ package body TASTE.Concurrency_View is
(if Trigger then Generate_Node (Node_Name) (if Trigger then Generate_Node (Node_Name)
else ""); else "");
begin begin
Document_Template (Template_CV_File_Node, Filename_Set); Document_Template
Document_Template (Template_CV_Trigger, Trig_Tmpl); (Templates_Concurrency_View_Sub_File_Node, Filename_Set);
Document_Template
(Templates_Concurrency_View_Sub_Trigger, Trig_Tmpl);
if Trigger then if Trigger then
-- Associate node name, CPU name and CPU classifier -- Associate node name, CPU name and CPU classifier
...@@ -824,7 +834,8 @@ package body TASTE.Concurrency_View is ...@@ -824,7 +834,8 @@ package body TASTE.Concurrency_View is
Mode => Out_File, Mode => Out_File,
Name => CV_Out_Dir & File_Sys); Name => CV_Out_Dir & File_Sys);
Put_Line (Output_File, Parse (Tmpl_Sys, Set_Sys)); Put_Line (Output_File, Parse (Tmpl_Sys, Set_Sys));
Document_Template (Template_CV_System, Set_Sys); Document_Template
(Templates_Concurrency_View_Sub_System, Set_Sys);
Close (Output_File); Close (Output_File);
end if; end if;
end; end;
......
...@@ -249,8 +249,10 @@ package body TASTE.Dump is ...@@ -249,8 +249,10 @@ package body TASTE.Dump is
& Assoc ("Dest_Ports", Dest_Ports); & Assoc ("Dest_Ports", Dest_Ports);
-- Output is made of interface, deployment and data views -- Output is made of interface, deployment and data views
Document_Template (Category => Template_Dump_Interface_View, Document_Template (Category => Templates_Dump_Interfaceview,
Tags => IV_Tags); Tags => IV_Tags);
Document_Template (Category => Templates_Dump_Deploymentview,
Tags => DV_Tags);
-- interfaceview.tmplt -- interfaceview.tmplt
Output_Tags := +Assoc ("Interface_View", Output_Tags := +Assoc ("Interface_View",
String'(Parse (IV_Template, IV_Tags))) String'(Parse (IV_Template, IV_Tags)))
......
...@@ -6,6 +6,7 @@ with Ada.Characters.Latin_1, ...@@ -6,6 +6,7 @@ with Ada.Characters.Latin_1,
Ada.Strings.Maps, Ada.Strings.Maps,
Ada.Strings.Fixed, Ada.Strings.Fixed,
Ada.Strings, Ada.Strings,
Ada.Characters.Handling,
Ada.Directories, Ada.Directories,
Ada.Command_Line, Ada.Command_Line,
Ada.Environment_Variables, Ada.Environment_Variables,
...@@ -23,7 +24,8 @@ with Ada.Characters.Latin_1, ...@@ -23,7 +24,8 @@ with Ada.Characters.Latin_1,
package body TASTE.Parser_Utils is package body TASTE.Parser_Utils is
use GNAT.OS_Lib, use Ada.Characters.Handling,
GNAT.OS_Lib,
GNAT.Command_Line, GNAT.Command_Line,
Ada.Directories, Ada.Directories,
Templates_Parser.Utils, Templates_Parser.Utils,
...@@ -104,7 +106,7 @@ package body TASTE.Parser_Utils is ...@@ -104,7 +106,7 @@ package body TASTE.Parser_Utils is
Put_Debug ("Dump documentation of " & Key (Each)'Img); Put_Debug ("Dump documentation of " & Key (Each)'Img);
Create (File => Output_File, Create (File => Output_File,
Mode => Out_File, Mode => Out_File,
Name => Output_Folder & "/" & Key (Each)'Img & ".tmplt_doc"); Name => Output_Folder & "/" & To_Lower (Key (Each)'Img));
Put_Line (Output_File, Element (Each)); Put_Line (Output_File, Element (Each));
Close (Output_File); Close (Output_File);
end loop; end loop;
......
...@@ -84,29 +84,32 @@ package TASTE.Parser_Utils is ...@@ -84,29 +84,32 @@ package TASTE.Parser_Utils is
unused_Context : Filter_Context) return String; unused_Context : Filter_Context) return String;
-- Generate documentation for a translate set -- Generate documentation for a translate set
-- Template_Category enumerants reflect the path containing the template
-- (directory separator is replaced by an underscore)
type Template_Category is type Template_Category is
(Template_Main_Makefile, (Templates_Skeletons_Makefile, -- Main makefile
Template_Context_Parameters, Templates_Skeletons_Context_Parameters, -- Context Parameters
Template_Skeleton_And_Glue_Trigger, Templates_Skeletons_Sub_Trigger, -- Trigger per skeleton folder
Template_Skeleton_Makefile_Filename, Templates_Skeletons_Sub_Makefile_Filename,
Template_Skeleton_Makefile, Templates_Skeletons_Sub_Makefile,
Template_Skeleton_Function_Filename, Templates_Skeletons_Sub_Function_Filename,
Template_Skeleton_Function, Templates_Skeletons_Sub_Function,
Template_Skeleton_Interface, Templates_Skeletons_Sub_Interface,
Template_CV_Trigger, Templates_Concurrency_View_Sub_Trigger,
Template_CV_File_Node, Templates_Concurrency_View_Sub_File_Node,
Template_CV_File_Part, Templates_Concurrency_View_Sub_File_Part,
Template_CV_File_Thread, Templates_Concurrency_View_Sub_File_Thread,
Template_CV_File_Block, Templates_Concurrency_View_Sub_File_Block,
Template_CV_Thread, Templates_Concurrency_View_Sub_Thread,
Template_CV_PI, Templates_Concurrency_View_Sub_PI,
Template_CV_RI, Templates_Concurrency_View_Sub_RI,
Template_CV_Block, Templates_Concurrency_View_Sub_Block,
Template_CV_Partition, Templates_Concurrency_View_Sub_Partition,
Template_CV_Node, Templates_Concurrency_View_Sub_Node,
Template_CV_System, Templates_Concurrency_View_Sub_System,
Template_Dump_Interface_View, Templates_Dump_Interfaceview,
Template_Dump_Deployment_View); Templates_Dump_Deploymentview);
package Template_Doc_Maps is new Indefinite_Ordered_Maps package Template_Doc_Maps is new Indefinite_Ordered_Maps
(Template_Category, String); (Template_Category, String);
......
@@IF@@ @_Language_@ /= GUI
--sub@_REPLACE(SDL/Ada):REPLACE(VDM/C):Language_@ @_Function_Name_@ \
@@END_IF@@
# Generate code for function "@_Function_Name_@ implemented in "@_Language_@
# Zip code of function @_Function_Name_@
...@@ -2,15 +2,11 @@ ...@@ -2,15 +2,11 @@
# This script will build your system # This script will build your system
# DO NOT EDIT THIS FILE # DO NOT EDIT THIS FILE
# Generated by kazoo on @_Now_@
# If you need additional pre-processing, there are three hook files # this file was genrated for backward compatibility (legacy)
# that you can provide and that are called dring the build: # but it is deprecated in favour of the Makefile
# user_init_pre.sh, user_init_post.sh and user_init_last.sh
# These files will never get overwritten by TASTE. # Generated by kazoo on @_Now_@
# Inside these files you may set some environment variables:
# C_INCLUDE_PATH=/usr/include/xenomai/analogy/:${C_INCLUDE_PATH}
# unset USE_POHIC
CWD=$(pwd) CWD=$(pwd)
...@@ -24,43 +20,4 @@ fi ...@@ -24,43 +20,4 @@ fi
INFO="${COLORON}[INFO]${COLOROFF}" INFO="${COLORON}[INFO]${COLOROFF}"
if [ -f user_init_pre.sh ] make
then
echo -e "${INFO} Executing user-defined init script"
source user_init_pre.sh
fi
INTERFACEVIEW=@_Interface_View_Path_@
if [ -f ConcurrencyView.pro ]
then
ORCHESTRATOR_OPTIONS+=" -w ConcurrencyView.pro "
elif [ -f ../ConcurrencyView_Properties.aadl ]
then
ORCHESTRATOR_OPTIONS+=" -w ConcurrencyView_Properties.aadl "
fi
if [ -f user_init_post.sh ]
then
echo -e "${INFO} Executing user-defined post-init script"
source user_init_post.sh
fi
if [ -f additionalCommands.sh ]
then
source additionalCommands.sh
fi
# Execute the makefile to update dataviews, if needed, then call ocarina and build everything
make && \
cd build && \
ocarina -x main.aadl &&
make -f Makefile.taste
if [ -f user_init_last.sh ]
then
echo -e "${INFO} Executing user-defined post-build script"
source user_init_last.sh
fi
# End of build script
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