Commit 50f14063 authored by yoogx's avatar yoogx

* Clean up command line interfaces, concentrate all machinery

          in new package Ocarina.Cmd_Line, rework all
          frontend/backends to avoid code duplication.

          For issue #33

          Also fix for issue #54
parent aa036ede
......@@ -37,9 +37,6 @@ with Ocarina.Backends.Utils;
with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.XML_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.AADL_XML is
......@@ -51,8 +48,6 @@ package body Ocarina.Backends.AADL_XML is
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -99,27 +94,6 @@ package body Ocarina.Backends.AADL_XML is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* o:") is
when ASCII.NUL =>
exit;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("aadl_xml", Generate'Access, AADLXML);
end Init;
......
......@@ -37,7 +37,6 @@ with Ocarina.Instances; use Ocarina.Instances;
with Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.ME_AADL.AADL_Instances.Entities;
with GNAT.Command_Line;
with Ocarina.Backends.Utils;
with Ada.Text_IO;
......@@ -224,9 +223,8 @@ package body Ocarina.Backends.Alloy is
--------------
procedure Generate (AADL_Root : Node_Id) is
use GNAT.Command_Line;
Instance_Root : Node_Id;
begin
-- Instantiate the AADL tree
......@@ -235,18 +233,6 @@ package body Ocarina.Backends.Alloy is
raise Program_Error;
end if;
Initialize_Option_Scan;
loop
case Getopt ("* ") is
when ASCII.NUL =>
exit;
when others =>
null;
end case;
end loop;
-- Open a new .als file
Create (File => FD, Name => "con_model.als");
......
......@@ -44,8 +44,6 @@ with Ocarina.Backends.ARINC653_Conf.System_HM;
with Ocarina.Backends.ARINC653_Conf.Module_HM;
with Ocarina.Backends.Utils;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.ARINC653_Conf is
......@@ -59,9 +57,6 @@ package body Ocarina.Backends.ARINC653_Conf is
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
--------------
-- Generate --
--------------
......@@ -107,30 +102,6 @@ package body Ocarina.Backends.ARINC653_Conf is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("ARINC653_Conf", Generate'Access, Statistics);
end Init;
......
......@@ -36,16 +36,9 @@ with Ocarina.Backends.ASN1_Tree.Generator;
with Ocarina.Backends.ASN1_Tree.Nutils;
with Ocarina.Backends.ASN1.Deployment;
with Ocarina.Backends.Utils;
with GNAT.Command_Line;
with Ocarina.Namet;
package body Ocarina.Backends.ASN1 is
use GNAT.Command_Line;
use Ocarina.Namet;
use Ocarina.Backends.Messages;
use Ocarina.Backends.ASN1_Tree.Generator;
use Ocarina.Backends.ASN1_Tree.Nutils;
......@@ -53,8 +46,6 @@ package body Ocarina.Backends.ASN1 is
use Ocarina.Backends.Expander;
use Ocarina.Instances;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -99,27 +90,6 @@ package body Ocarina.Backends.ASN1 is
procedure Init is
begin
ASN1_Tree.Nutils.Initialize;
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z ec er o: perf") is
when ASCII.NUL =>
exit;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("asn1_deployment", Generate'Access, ASN1_Deployment);
end Init;
......
......@@ -39,7 +39,7 @@ with Ocarina.Instances; use Ocarina.Instances;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.Properties; use Ocarina.Backends.Properties;
with Ocarina.Options; use Ocarina.Options;
with GNAT.Command_Line;
with Utils; use Utils;
with Ada.Text_IO;
......@@ -290,8 +290,6 @@ package body Ocarina.Backends.BoundT is
procedure Init is
begin
-- Registration of the generator
Register_Backend ("boundt", Generate'Access, Bound_T);
end Init;
......@@ -300,9 +298,8 @@ package body Ocarina.Backends.BoundT is
--------------
procedure Generate (AADL_Root : Node_Id) is
use GNAT.Command_Line;
Instance_Root : Node_Id;
begin
-- Instantiate the AADL tree
......@@ -311,23 +308,6 @@ package body Ocarina.Backends.BoundT is
raise Program_Error;
end if;
Initialize_Option_Scan;
loop
case Getopt ("* boundt_process:") is
when ASCII.NUL =>
exit;
when 'b' =>
if Full_Switch = "boundt_process" then
Boundt_Process := To_Lower (Get_String_Name (Parameter));
end if;
when others =>
null;
end case;
end loop;
-- Open a new TPO file
if Boundt_Process = No_Name then
......
......@@ -37,7 +37,6 @@ with Ocarina.Backends.Utils;
with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.XML_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
......@@ -51,9 +50,6 @@ package body Ocarina.Backends.Carts is
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Generated_Sources_Directory : Name_Id := No_Name;
Remove_Generated_Sources : Boolean := False;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -97,30 +93,6 @@ package body Ocarina.Backends.Carts is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("carts", Generate'Access, Carts_XML);
end Init;
......
......@@ -38,10 +38,6 @@ with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.XML_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Cheddar is
use Ocarina.Instances;
......@@ -52,8 +48,6 @@ package body Ocarina.Backends.Cheddar is
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -102,27 +96,6 @@ package body Ocarina.Backends.Cheddar is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b o:") is
when ASCII.NUL =>
exit;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("cheddar", Generate'Access, Cheddar_XML);
end Init;
......
......@@ -36,10 +36,6 @@ with Ocarina.Backends.XML_Tree.Generator;
with Ocarina.Backends.Utils;
with Ocarina.Backends.Connection_Matrix.Main;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Connection_Matrix is
use Ocarina.Instances;
......@@ -48,9 +44,6 @@ package body Ocarina.Backends.Connection_Matrix is
use Ocarina.Backends.XML_Tree.Generator;
use Ocarina.Backends.Utils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -99,30 +92,6 @@ package body Ocarina.Backends.Connection_Matrix is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend
("Connection_Matrix",
Generate'Access,
......
......@@ -41,8 +41,6 @@ with Ocarina.Backends.Deos_Conf.Naming;
with Ocarina.Backends.Deos_Conf.Partitions;
with Ocarina.Backends.Utils;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Deos_Conf is
......@@ -58,9 +56,6 @@ package body Ocarina.Backends.Deos_Conf is
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
--------------
-- Generate --
--------------
......@@ -106,30 +101,6 @@ package body Ocarina.Backends.Deos_Conf is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("Deos_Conf", Generate'Access, Deos_XML);
end Init;
......
......@@ -36,10 +36,6 @@ with Ocarina.Backends.XML_Tree.Generator;
with Ocarina.Backends.Utils;
with Ocarina.Backends.Functions_Matrix.Main;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Functions_Matrix is
use Ocarina.Instances;
......@@ -48,9 +44,6 @@ package body Ocarina.Backends.Functions_Matrix is
use Ocarina.Backends.XML_Tree.Generator;
use Ocarina.Backends.Utils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -101,34 +94,8 @@ package body Ocarina.Backends.Functions_Matrix is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend
("Function_Matrix",
Generate'Access,
Functions_Matrix_Analysis);
("Function_Matrix", Generate'Access, Functions_Matrix_Analysis);
end Init;
-----------
......
......@@ -33,11 +33,9 @@ with Ocarina.Instances;
with Ocarina.Backends.Expander;
with Ocarina.Backends.Messages;
with Ocarina.Backends.Utils;
-- with Ocarina.Backends.MAST_Tree.Nodes;
with Ocarina.Backends.MAST_Tree.Nutils;
with Ocarina.Backends.MAST.Main;
with Ocarina.Backends.MAST_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
......@@ -48,12 +46,8 @@ package body Ocarina.Backends.MAST is
use Ocarina.Backends.Utils;
use Ocarina.Backends.Expander;
-- package MTN renames Ocarina.Backends.MAST_Tree.Nodes;
package MTU renames Ocarina.Backends.MAST_Tree.Nutils;
Generated_Sources_Directory : Name_Id := No_Name;
Remove_Generated_Sources : Boolean := False;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -85,8 +79,8 @@ package body Ocarina.Backends.MAST is
if not Remove_Generated_Sources then
MAST_Tree.Generator.Generate (MAST_File);
end if;
Leave_Directory;
Leave_Directory;
end Generate;
----------
......@@ -95,30 +89,6 @@ package body Ocarina.Backends.MAST is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* z o:") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("mast", Generate'Access, MAST_Scheduling);
end Init;
......
......@@ -54,8 +54,6 @@ with Ocarina.Backends.Build_Utils;
with Ocarina.Backends.Execution_Utils;
with Ocarina.Backends.Execution_Tests;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.PO_HI_Ada is
......@@ -73,12 +71,6 @@ package body Ocarina.Backends.PO_HI_Ada is
use Ocarina.Backends.Execution_Utils;
use Ocarina.Backends.Execution_Tests;
Compile_Generated_Sources : Boolean := False;
Remove_Generated_Sources : Boolean := False;
Do_Coverage_Test : Boolean := False;
Do_Regression_Test : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -392,7 +384,9 @@ package body Ocarina.Backends.PO_HI_Ada is
end loop;
end if;
Write_Line (");");
Write_Line
(") & external_as_list(""" & "ADA_INCLUDE_PATH" & """, """ & ":" &
""");");
Decrement_Indentation;
......@@ -641,41 +635,6 @@ package body Ocarina.Backends.PO_HI_Ada is
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z ec er o:") is
when ASCII.NUL =>
exit;
when 'b' =>
Compile_Generated_Sources := True;
when 'z' =>
Remove_Generated_Sources := True;
when 'e' =>
Compile_Generated_Sources := True;
if Full_Switch = "ec" then
Do_Coverage_Test := True;
elsif Full_Switch = "er" then
Do_Regression_Test := True;
end if;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
-- Registration of the generator
Register_Backend ("polyorb_hi_ada", Generate'Access, PolyORB_HI_Ada);
......
......@@ -58,13 +58,11 @@ with Ocarina.Backends.Execution_Utils;
with Ocarina.Backends.Execution_Tests;
with Ocarina.Backends.Properties;
with Ocarina.Backends.ASN1;
with GNAT.Command_Line;
with Ocarina.Namet;
package body Ocarina.Backends.PO_HI_C is
use GNAT.Command_Line;
use GNAT.OS_Lib;
use Ocarina.Namet;
......@@ -98,15 +96,6 @@ package body Ocarina.Backends.PO_HI_C is
package AAU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package CTN renames Ocarina.Backends.C_Tree.Nodes;
Generate_ASN1_Deployment : Boolean := False;
Compile_Generated_Sources : Boolean := False;
Remove_Generated_Sources : Boolean := False;
Add_Performance_Analysis : Boolean := False;
Do_Regression_Test : Boolean := False;
Do_Coverage_Test : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
Verbose_Mode : Boolean := False;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
......@@ -540,13 +529,6 @@ package body Ocarina.Backends.PO_HI_C is
-- Enter the output directory
Enter_Directory (Generated_Sources_Directory);
if Verbose_Mode then
Set_Standard_Error;
Write_Str ("Generating code in directory: ");
Write_Name (Generated_Sources_Directory);
Write_Eol;
Set_Standard_Output;
end if;
if Remove_Generated_Sources then
Build_Utils.Makefiles.Clean (Instance_Root);
......@@ -640,54 +622,6 @@ package body Ocarina.Backends.PO_HI_C is