Commit 3acc39d3 authored by julien.delange's avatar julien.delange

begin to generate ASN1 files

add -asn1 option, when used, it generates ASN1 deployment file
in the generated directory



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@671 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent d1bb5901
......@@ -31,17 +31,22 @@
-- --
------------------------------------------------------------------------------
with Namet; use Namet;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.ASN1_Tree.Nutils;
package body Ocarina.Backends.ASN1.Deployment is
use Ocarina.ME_AADL;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.ASN1_Tree.Nutils;
package AAU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
procedure Visit_Architecture_Instance (E : Node_Id);
......@@ -76,6 +81,9 @@ package body Ocarina.Backends.ASN1.Deployment is
procedure Visit_Architecture_Instance (E : Node_Id) is
begin
ASN1_Root := Make_ASN1_File
(Make_Defining_Identifier
(Get_String_Name ("deployment")));
Visit (Root_System (E));
end Visit_Architecture_Instance;
......
......@@ -35,9 +35,9 @@ with Ocarina.Instances;
with Ocarina.Backends.Expander;
with Ocarina.Backends.Messages;
with Ocarina.Backends.ASN1_Tree.Generator;
with Ocarina.Backends.ASN1_Tree.Nutils;
with Ocarina.Backends.ASN1.Deployment;
with Ocarina.Backends.Utils;
with Ocarina.Backends.Build_Utils;
with GNAT.Command_Line;
with Namet;
......@@ -50,11 +50,11 @@ package body Ocarina.Backends.ASN1 is
use Ocarina.Backends.Messages;
use Ocarina.Backends.ASN1_Tree.Generator;
use Ocarina.Backends.ASN1_Tree.Nutils;
use Ocarina.Backends.Utils;
use Ocarina.Backends.Expander;
use Ocarina.Instances;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
......@@ -88,13 +88,7 @@ package body Ocarina.Backends.ASN1 is
Enter_Directory (Generated_Sources_Directory);
if Remove_Generated_Sources then
Build_Utils.Makefiles.Clean (Instance_Root);
else
-- Create the source files
ASN1_Tree.Generator.Generate (ASN1_Root);
end if;
ASN1_Tree.Generator.Generate (ASN1_Root);
-- Leave the output directory
Leave_Directory;
......@@ -106,6 +100,7 @@ package body Ocarina.Backends.ASN1 is
procedure Init is
begin
ASN1_Tree.Nutils.Initialize;
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
......@@ -113,9 +108,6 @@ package body Ocarina.Backends.ASN1 is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
......
......@@ -31,6 +31,8 @@
-- --
------------------------------------------------------------------------------
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Outfiles; use Outfiles;
with Namet; use Namet;
with Output; use Output;
......@@ -47,7 +49,8 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
procedure Write (T : Token_Type);
procedure Write_Line (T : Token_Type);
pragma Unreferenced (Write_Line);
procedure Generate_ASN1_File (N : Node_Id);
procedure Generate_Module (N : Node_Id);
-----------
-- Write --
......@@ -75,10 +78,45 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
procedure Generate (N : Node_Id) is
begin
case Kind (N) is
when K_ASN1_File =>
Generate_ASN1_File (N);
when K_ASN1_Module =>
Generate_Module (N);
when others =>
Display_Error ("other element in generator", Fatal => False);
null;
end case;
end Generate;
------------------------
-- Generate_ASN1_File --
------------------------
procedure Generate_ASN1_File (N : Node_Id) is
Fd : File_Descriptor;
begin
if No (N) then
return;
end if;
Get_Name_String (Name (Defining_Identifier (N)));
Fd := Create_File (Name_Buffer (1 .. Name_Len) & ".asn1", Text);
Set_Output (Fd);
Generate (Module_Node (N));
Release_Output (Fd);
end Generate_ASN1_File;
---------------------
-- Generate_Module --
---------------------
procedure Generate_Module (N : Node_Id) is
pragma Unreferenced (N);
begin
Write_Line (Tok_Module);
end Generate_Module;
end Ocarina.Backends.ASN1_Tree.Generator;
......@@ -33,6 +33,9 @@ module Ocarina::Backends::ASN1_Tree::Nodes {
boolean Is_Pointer;
};
interface ASN1_File : Definition {
Node_Id Module_Node;
};
interface ASN1_Module : Node_Id {
Name_Id Name;
......
......@@ -39,10 +39,13 @@ with Locations; use Locations;
with Ocarina.Backends;
with Ocarina.Backends.ASN1_Tree.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.Backends;
use Ocarina.Backends.ASN1_Tree.Nodes;
package body Ocarina.Backends.ASN1_Tree.Nutils is
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
......@@ -242,6 +245,7 @@ package body Ocarina.Backends.ASN1_Tree.Nutils is
end loop;
-- Graphic Characters
New_Token (Tok_Module, "MODULE");
New_Token (Tok_And, "&&");
New_Token (Tok_Xor, "^");
New_Token (Tok_Sharp, "#");
......@@ -410,4 +414,33 @@ package body Ocarina.Backends.ASN1_Tree.Nutils is
Operator_Image (Operator_Type'Pos (O)) := Name_Find;
end New_Operator;
--------------------
-- Make_ASN1_File --
--------------------
function Make_ASN1_File (Identifier : Node_Id) return Node_Id is
File : Node_Id;
begin
File := New_Node (K_ASN1_File);
Set_Defining_Identifier (File, Identifier);
Set_Corresponding_Node (Identifier, File);
Set_Module_Node (File, New_Node (K_ASN1_Module));
return File;
end Make_ASN1_File;
------------------------------
-- Make_Defining_Identifier --
------------------------------
function Make_Defining_Identifier (Name : Name_Id)
return Node_Id
is
N : Node_Id;
begin
N := New_Node (K_Defining_Identifier);
Set_Name (N, Name);
return N;
end Make_Defining_Identifier;
end Ocarina.Backends.ASN1_Tree.Nutils;
......@@ -156,4 +156,8 @@ package Ocarina.Backends.ASN1_Tree.Nutils is
procedure New_Token (T : Token_Type; I : String := "");
function Make_ASN1_File (Identifier : Node_Id) return Node_Id;
function Make_Defining_Identifier (Name : Name_Id) return Node_Id;
end Ocarina.Backends.ASN1_Tree.Nutils;
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009, GET-Telecom Paris. --
-- Copyright (C) 2008-2010, GET-Telecom Paris. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -38,6 +38,7 @@ with Ocarina.Instances;
with Ocarina.Backends.Expander;
with Ocarina.Backends.Messages;
with Ocarina.Backends.C_Tree.Generator;
with Ocarina.Backends.C_Tree.Nodes;
with Ocarina.Backends.PO_HI_C.Activity;
with Ocarina.Backends.PO_HI_C.Main;
with Ocarina.Backends.PO_HI_C.Naming;
......@@ -52,6 +53,7 @@ with Ocarina.Backends.Build_Utils;
with Ocarina.Backends.Execution_Utils;
with Ocarina.Backends.Execution_Tests;
with Ocarina.Backends.Properties;
with Ocarina.Backends.ASN1;
with GNAT.Command_Line;
with Namet;
......@@ -75,6 +77,7 @@ package body Ocarina.Backends.PO_HI_C is
use Ocarina.Backends.PO_HI_C.Marshallers;
use Ocarina.Backends.Messages;
use Ocarina.Backends.C_Tree.Generator;
use Ocarina.Backends.ASN1;
use Ocarina.Backends.Utils;
use Ocarina.Backends.Expander;
use Ocarina.Instances;
......@@ -82,6 +85,9 @@ package body Ocarina.Backends.PO_HI_C is
use Ocarina.Backends.Execution_Utils;
use Ocarina.Backends.Execution_Tests;
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;
......@@ -262,6 +268,12 @@ package body Ocarina.Backends.PO_HI_C is
Generate_PolyORB_HI_C_Makefile (Instance_Root);
if Generate_ASN1_Deployment then
Enter_Directory (CTN.Name (C_Root));
ASN1.Generate (Instance_Root);
Leave_Directory;
end if;
-- If the user requested to build the applications then we
-- build it.
......@@ -327,10 +339,15 @@ package body Ocarina.Backends.PO_HI_C is
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z ec er o: perf") is
case Getopt ("* b z ec er o: perf asn1") is
when ASCII.NUL =>
exit;
when 'a' =>
if Full_Switch = "asn1" then
Generate_ASN1_Deployment := True;
end if;
when 'b' =>
Compile_Generated_Sources := True;
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009, GET-Telecom Paris. --
-- Copyright (C) 2008-2010, GET-Telecom Paris. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -113,7 +113,8 @@ package body Ocarina.Backends.XML_Tree.Generator is
-- Create a new file and overwrites existing file with
-- the same name
Fd := Create_File (Name_Buffer (1 .. Name_Len), Text);
Fd := Create_File
(Name_Buffer (1 .. Name_Len) & ".asn1", Text);
if Fd = Invalid_FD then
raise Program_Error;
......
......@@ -287,6 +287,8 @@ package body Ocarina.Backends is
Write_Line (" -g Generate code from the AADL instance tree");
Ocarina.Backends.Write_Backends (7);
Write_Line (" -perf Enable profiling with gprof (PolyORB-HI-C only)");
Write_Line
(" -asn1 Generate ASN1 deployment file (PolyORB-HI-C only)");
Ocarina.Backends.Write_Backends (7);
Write_Line
(" -arinc653 Generate code for ARINC653 API (POK backend only)");
......
Markdown is supported
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