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

Rename generated template documentation

parent f4c9cf64
with System.OS_Lib,
Text_IO,
with Text_IO,
Ada.Exceptions,
Ada.Directories,
Templates_Parser,
TASTE.Parser_Utils;
use System.OS_Lib,
Text_IO,
use Text_IO,
Ada.Exceptions,
Ada.Directories,
Templates_Parser,
......@@ -15,61 +13,21 @@ package body TASTE.Backend.Build_Script is
procedure Generate (Model : TASTE_Model) is
Prefix : constant String :=
Model.Configuration.Binary_Path.Element & "templates/";
Vec_Code : Tag;
Vec_Zip : Tag;
Vec_Func : Tag;
begin
for Each of Model.Interface_View.Flat_Functions loop
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");
Put_Info ("Generating legacy build-script.sh");
declare
Template_Data : constant Translate_Set :=
+Assoc ("Interface_View_Path",
Model.Configuration.Interface_View.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");
& Assoc ("Output_Path", Model.Configuration.Output_Dir.Element);
Result : constant String := Parse (Prefix & "build-script.tmplt",
Template_Data);
Output_Path : constant String :=
Model.Configuration.Output_Dir.Element;
Filename : constant String := Output_Path & "/build-script.sh";
Output : File_Type;
Success : Boolean;
begin
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);
Put_Line (Output, Result);
Close (Output);
......
......@@ -2,5 +2,9 @@ with TASTE.AADL_Parser;
use TASTE.AADL_Parser;
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);
end TASTE.Backend.Build_Script;
......@@ -104,7 +104,7 @@ package body TASTE.Backend.Code_Generators is
Create (File => Output_File,
Mode => Out_File,
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));
Close (Output_File);
end Generate_Global_Makefile;
......@@ -117,7 +117,7 @@ package body TASTE.Backend.Code_Generators is
Tmplt_Sign : constant String := Path & "interface.tmplt";
begin
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));
end loop;
return Result;
......@@ -137,7 +137,7 @@ package body TASTE.Backend.Code_Generators is
CP_File_Dash : Unbounded_String;
begin
Document_Template (Template_Context_Parameters, CP_Tmpl);
Document_Template (Templates_Skeletons_Context_Parameters, CP_Tmpl);
-- To keep backward compatibility, file name uses dash
for C of CP_File loop
CP_File_Dash := CP_File_Dash & (if C = '_' then '-' else C);
......@@ -203,7 +203,7 @@ package body TASTE.Backend.Code_Generators is
Output_Dir : constant String := Output_Lang & Output_Sub;
begin
Document_Template (Template_Skeleton_Makefile, Make_Tmpl);
Document_Template (Templates_Skeletons_Sub_Makefile, Make_Tmpl);
-- Create directory tree (output/function/language/src)
Create_Path (Output_Dir);
if File_Name /= "" then
......@@ -332,12 +332,12 @@ package body TASTE.Backend.Code_Generators is
and then Strip_String (Parse
(Path & "/trigger.tmplt", Trig_Tmpl)) = "TRUE");
begin
Document_Template (Template_Skeleton_Function_Filename,
File_Tmpl);
Document_Template (Template_Skeleton_Makefile_Filename,
File_Tmpl);
Document_Template (Template_Skeleton_And_Glue_Trigger,
Trig_Tmpl);
Document_Template
(Templates_Skeletons_Sub_Function_Filename, File_Tmpl);
Document_Template
(Templates_Skeletons_Sub_Makefile_Filename, File_Tmpl);
Document_Template
(Templates_Skeletons_Sub_Trigger, Trig_Tmpl);
if Trigger then
-- Output code and Makefile from this template folder
Process_Template (F => Each,
......
......@@ -252,7 +252,8 @@ package body TASTE.Concurrency_View is
-- Part_File_Name may contain a subfolder
Subfolder : Unbounded_String;
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
Input_Port_Names := Input_Port_Names & Each.Port_Name;
Input_Port_Type_Name := Input_Port_Type_Name
......@@ -294,8 +295,11 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Thread_File_Id, Thread_Tag))
else "");
begin
Document_Template (Template_CV_Thread, Thread_Assoc);
Document_Template (Template_CV_File_Thread, Thread_Tag);
Document_Template
(Templates_Concurrency_View_Sub_Thread, Thread_Assoc);
Document_Template
(Templates_Concurrency_View_Sub_File_Thread,
Thread_Tag);
Threads := Threads & Newline & Result;
Part_Threads := Part_Threads & Newline & Result;
......@@ -362,7 +366,8 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Block_File_Id, Block_Tag))
else "");
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;
All_Block_Names := All_Block_Names & Block_Name;
Block_Languages := Block_Languages
......@@ -372,7 +377,7 @@ package body TASTE.Concurrency_View is
for PI_Assoc of Tmpl.Protected_Provided loop
Document_Template
(Template_CV_PI,
(Templates_Concurrency_View_Sub_PI,
PI_Assoc & Assoc ("Partition_Name", ""));
Pro_PI_Tag := Pro_PI_Tag & Newline
& String'(Parse (Path & "/pi.tmplt",
......@@ -387,7 +392,7 @@ package body TASTE.Concurrency_View is
end loop;
for RI_Assoc of Tmpl.Required loop
Document_Template
(Template_CV_RI,
(Templates_Concurrency_View_Sub_RI,
RI_Assoc & Assoc ("Partition_Name", ""));
RI_Tag := RI_Tag & Newline
......@@ -405,7 +410,8 @@ package body TASTE.Concurrency_View is
& Assoc ("Required", RI_Tag);
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);
......@@ -451,7 +457,8 @@ package body TASTE.Concurrency_View is
Part_Content :=
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
-- (if required at template folder level)
......@@ -532,7 +539,8 @@ package body TASTE.Concurrency_View is
CV.Nodes (Node_Name).Deployment_Node.Package_Name)
& Assoc ("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);
end Generate_Node;
......@@ -656,8 +664,10 @@ package body TASTE.Concurrency_View is
(if Trigger then Generate_Node (Node_Name)
else "");
begin
Document_Template (Template_CV_File_Node, Filename_Set);
Document_Template (Template_CV_Trigger, Trig_Tmpl);
Document_Template
(Templates_Concurrency_View_Sub_File_Node, Filename_Set);
Document_Template
(Templates_Concurrency_View_Sub_Trigger, Trig_Tmpl);
if Trigger then
-- Associate node name, CPU name and CPU classifier
......@@ -824,7 +834,8 @@ package body TASTE.Concurrency_View is
Mode => Out_File,
Name => CV_Out_Dir & File_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);
end if;
end;
......
......@@ -249,8 +249,10 @@ package body TASTE.Dump is
& Assoc ("Dest_Ports", Dest_Ports);
-- 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);
Document_Template (Category => Templates_Dump_Deploymentview,
Tags => DV_Tags);
-- interfaceview.tmplt
Output_Tags := +Assoc ("Interface_View",
String'(Parse (IV_Template, IV_Tags)))
......
......@@ -6,6 +6,7 @@ with Ada.Characters.Latin_1,
Ada.Strings.Maps,
Ada.Strings.Fixed,
Ada.Strings,
Ada.Characters.Handling,
Ada.Directories,
Ada.Command_Line,
Ada.Environment_Variables,
......@@ -23,7 +24,8 @@ with Ada.Characters.Latin_1,
package body TASTE.Parser_Utils is
use GNAT.OS_Lib,
use Ada.Characters.Handling,
GNAT.OS_Lib,
GNAT.Command_Line,
Ada.Directories,
Templates_Parser.Utils,
......@@ -104,7 +106,7 @@ package body TASTE.Parser_Utils is
Put_Debug ("Dump documentation of " & Key (Each)'Img);
Create (File => Output_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));
Close (Output_File);
end loop;
......
......@@ -84,29 +84,32 @@ package TASTE.Parser_Utils is
unused_Context : Filter_Context) return String;
-- 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
(Template_Main_Makefile,
Template_Context_Parameters,
Template_Skeleton_And_Glue_Trigger,
Template_Skeleton_Makefile_Filename,
Template_Skeleton_Makefile,
Template_Skeleton_Function_Filename,
Template_Skeleton_Function,
Template_Skeleton_Interface,
Template_CV_Trigger,
Template_CV_File_Node,
Template_CV_File_Part,
Template_CV_File_Thread,
Template_CV_File_Block,
Template_CV_Thread,
Template_CV_PI,
Template_CV_RI,
Template_CV_Block,
Template_CV_Partition,
Template_CV_Node,
Template_CV_System,
Template_Dump_Interface_View,
Template_Dump_Deployment_View);
(Templates_Skeletons_Makefile, -- Main makefile
Templates_Skeletons_Context_Parameters, -- Context Parameters
Templates_Skeletons_Sub_Trigger, -- Trigger per skeleton folder
Templates_Skeletons_Sub_Makefile_Filename,
Templates_Skeletons_Sub_Makefile,
Templates_Skeletons_Sub_Function_Filename,
Templates_Skeletons_Sub_Function,
Templates_Skeletons_Sub_Interface,
Templates_Concurrency_View_Sub_Trigger,
Templates_Concurrency_View_Sub_File_Node,
Templates_Concurrency_View_Sub_File_Part,
Templates_Concurrency_View_Sub_File_Thread,
Templates_Concurrency_View_Sub_File_Block,
Templates_Concurrency_View_Sub_Thread,
Templates_Concurrency_View_Sub_PI,
Templates_Concurrency_View_Sub_RI,
Templates_Concurrency_View_Sub_Block,
Templates_Concurrency_View_Sub_Partition,
Templates_Concurrency_View_Sub_Node,
Templates_Concurrency_View_Sub_System,
Templates_Dump_Interfaceview,
Templates_Dump_Deploymentview);
package Template_Doc_Maps is new Indefinite_Ordered_Maps
(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 @@
# This script will build your system
# DO NOT EDIT THIS FILE
# Generated by kazoo on @_Now_@
# If you need additional pre-processing, there are three hook files
# that you can provide and that are called dring the build:
# user_init_pre.sh, user_init_post.sh and user_init_last.sh
# These files will never get overwritten by TASTE.
# Inside these files you may set some environment variables:
# C_INCLUDE_PATH=/usr/include/xenomai/analogy/:${C_INCLUDE_PATH}
# unset USE_POHIC
# this file was genrated for backward compatibility (legacy)
# but it is deprecated in favour of the Makefile
# Generated by kazoo on @_Now_@
CWD=$(pwd)
......@@ -24,43 +20,4 @@ fi
INFO="${COLORON}[INFO]${COLOROFF}"
if [ -f user_init_pre.sh ]
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
make
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