Commit 8248f43e authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Dataview checker

parent 5a9ad95c
......@@ -27,46 +27,60 @@ use Ada.Text_IO,
package body TASTE.AADL_Parser is
function Initialize return Taste_Configuration is
File_Name : Name_Id;
File_Descr : Location;
Current_Config : Taste_Configuration;
File_Name : Name_Id;
File_Descr : Location;
Cfg : Taste_Configuration;
begin
Banner;
-- Parse arguments before initializing Ocarina, otherwise Ocarina eats
-- some arguments (all file parameters).
Parse_Command_Line (Current_Config);
Parse_Command_Line (Cfg);
Initialize_Ocarina;
AADL_Language := Get_String_Name ("aadl");
if Current_Config.Interface_View.all'Length = 0 then
Current_Config.Interface_View := Default_Interface_View'Access;
if Cfg.Interface_View.all'Length = 0 and not Cfg.Check_Data_View then
-- Use "InterfaceView.aadl" by default, if nothing else is specified
-- and if the tool is not only called to check the data view
Cfg.Interface_View := Default_Interface_View'Access;
end if;
Set_Str_To_Name_Buffer (Current_Config.Interface_View.all);
-- An interface view is expected, look for it and parse it
if Cfg.Interface_View.all'Length > 0 then
Set_Str_To_Name_Buffer (Cfg.Interface_View.all);
File_Name := Ocarina.Files.Search_File (Name_Find);
if File_Name = No_Name then
raise AADL_Parser_Error
with "File not found : " & Current_Config.Interface_View.all;
end if;
File_Name := Ocarina.Files.Search_File (Name_Find);
if File_Name = No_Name then
raise AADL_Parser_Error
with "File not found : " & Cfg.Interface_View.all;
end if;
File_Descr := Ocarina.Files.Load_File (File_Name);
File_Descr := Ocarina.Files.Load_File (File_Name);
Interface_Root := Ocarina.Parser.Parse
(AADL_Language, Interface_Root, File_Descr);
Interface_Root := Ocarina.Parser.Parse
(AADL_Language, Interface_Root, File_Descr);
-- Parse TASTE_IV_Properties.aadl
Set_Str_To_Name_Buffer ("TASTE_IV_Properties.aadl");
File_Name := Ocarina.Files.Search_File (Name_Find);
File_Descr := Ocarina.Files.Load_File (File_Name);
Interface_Root := Ocarina.Parser.Parse (AADL_Language,
Interface_Root, File_Descr);
end if;
if Current_Config.Glue then
if Current_Config.Deployment_View.all'Length = 0 then
Current_Config.Deployment_View := Default_Deployment_View'Access;
if Cfg.Glue then
-- Look for a deployment view (or DeploymentView.aadl by default)
-- if the glue generation is requested. Not needed for skeletons.
if Cfg.Deployment_View.all'Length = 0 then
Cfg.Deployment_View := Default_Deployment_View'Access;
end if;
Set_Str_To_Name_Buffer (Current_Config.Deployment_View.all);
Set_Str_To_Name_Buffer (Cfg.Deployment_View.all);
File_Name := Ocarina.Files.Search_File (Name_Find);
if File_Name = No_Name then
raise AADL_Parser_Error
with "File not found : " & Current_Config.Deployment_View.all;
with "File not found : " & Cfg.Deployment_View.all;
end if;
File_Descr := Ocarina.Files.Load_File (File_Name);
......@@ -78,7 +92,9 @@ package body TASTE.AADL_Parser is
end if;
end if;
for Each of Current_Config.Other_Files loop
for Each of Cfg.Other_Files loop
-- Add other files to the Interface and (if any) deployment roots
-- (List of files specified in the command line)
Set_Str_To_Name_Buffer (Each);
File_Name := Ocarina.Files.Search_File (Name_Find);
if File_Name = No_Name then
......@@ -86,7 +102,6 @@ package body TASTE.AADL_Parser is
end if;
File_Descr := Ocarina.Files.Load_File (File_Name);
-- Add other files to the Interface and (if any) deployment roots
Interface_Root := Ocarina.Parser.Parse
(AADL_Language, Interface_Root, File_Descr);
if Deployment_Root /= No_Node then
......@@ -95,29 +110,34 @@ package body TASTE.AADL_Parser is
end if;
end loop;
-- Missing data view is actually not an error.
-- Systems can live with parameterless messages
if Current_Config.Data_View.all'Length > 0 then
Set_Str_To_Name_Buffer (Current_Config.Data_View.all);
if Cfg.Data_View.all'Length > 0 then
Set_Str_To_Name_Buffer (Cfg.Data_View.all);
File_Name := Ocarina.Files.Search_File (Name_Find);
if File_Name = No_Name then
raise AADL_Parser_Error with "Cannot find the Data View file";
raise AADL_Parser_Error with "Could not find " & Cfg.Data_View.all;
end if;
else
-- Try with default name
-- Try with default name (DataView.aadl)
Set_Str_To_Name_Buffer (Default_Data_View);
File_Name := Ocarina.Files.Search_File (Name_Find);
if File_Name /= No_Name then
Current_Config.Data_View := Default_Data_View'Access;
Cfg.Data_View := Default_Data_View'Access;
elsif Cfg.Check_Data_View then
-- No dataview found, while user asked explicitly for a check
raise AADL_Parser_Error with "Could not find DataView.aadl";
end if;
end if;
if File_Name /= No_Name then
Put_Info ("Parsing " & Cfg.Data_View.all);
File_Descr := Ocarina.Files.Load_File (File_Name);
-- Add the Data View to the Interface View root
Interface_Root := Ocarina.Parser.Parse
(AADL_Language, Interface_Root, File_Descr);
-- Add the Data View to the Interface View root, if any
if Interface_Root /= No_Node then
Interface_Root := Ocarina.Parser.Parse
(AADL_Language, Interface_Root, File_Descr);
end if;
-- Add the Data View to the Deployment View root, if any
if Deployment_Root /= No_Node then
......@@ -128,7 +148,7 @@ package body TASTE.AADL_Parser is
Dataview_root := Ocarina.Parser.Parse
(AADL_Language, Dataview_root, File_Descr);
end if;
return Current_Config;
return Cfg;
end Initialize;
function Parse_Project return TASTE_Model is
......@@ -136,16 +156,19 @@ package body TASTE.AADL_Parser is
begin
Result.Configuration := Initialize;
begin
Result.Interface_View := Parse_Interface_View (Interface_Root);
exception
when System.Assertions.Assert_Failure =>
raise AADL_Parser_Error with "Interface view parsing error";
end;
if Interface_Root /= No_Node then
-- Parse Interface and Deployment View
begin
Result.Interface_View := Parse_Interface_View (Interface_Root);
exception
when System.Assertions.Assert_Failure =>
raise AADL_Parser_Error with "Interface view parsing error";
end;
if Result.Configuration.Deployment_View.all'Length > 0 then
AADL_Lib.Append (Result.Configuration.Interface_View.all);
Result.Deployment_View := Parse_Deployment_View (Deployment_Root);
if Result.Configuration.Deployment_View.all'Length > 0 then
AADL_Lib.Append (Result.Configuration.Interface_View.all);
Result.Deployment_View := Parse_Deployment_View (Deployment_Root);
end if;
end if;
if Result.Configuration.Data_View.all'Length > 0 then
......@@ -161,6 +184,10 @@ package body TASTE.AADL_Parser is
Ocarina.Configuration.Reset_Modules;
Ocarina.Reset;
if Result.Configuration.Check_Data_View then
raise Quit_Taste;
end if;
return Result;
exception
when Error : AADL_Parser_Error
......
......@@ -34,6 +34,8 @@ package TASTE.Deployment_View is
-- List of Ocarina AADL models needed to parse the deployment view
AADL_Lib : String_Vectors.Vector := Empty_Vector &
"TASTE_DV_Properties.aadl" &
"TASTE_IV_Properties.aadl" &
"aadl_project.aadl" &
"taste_properties.aadl" &
"Cheddar_Properties.aadl" &
......
......@@ -63,40 +63,54 @@ package body TASTE.Parser_Utils is
begin
Result.Binary_Path := new String'(Get_Program_Directory);
Define_Switch (Config, Output => Result.Interface_View'Access,
Switch => "-i:", Long_Switch => "--interfaceview=",
Help => "Mandatory interface view (AADL model)",
Argument => "InterfaceView.aadl");
Switch => "-i:",
Long_Switch => "--interfaceview=",
Help => "Mandatory interface view (AADL model)",
Argument => "InterfaceView.aadl");
Define_Switch (Config, Output => Result.Deployment_View'Access,
Switch => "-c:", Long_Switch => "--deploymentview=",
Help => "Optional deployment view (AADL model)",
Argument => "DeploymentView.aadl");
Switch => "-c:",
Long_Switch => "--deploymentview=",
Help => "Optional deployment view (AADL model)",
Argument => "DeploymentView.aadl");
Define_Switch (Config, Output => Result.Data_View'Access,
Switch => "-d:", Long_Switch => "--dataview=",
Help => "Optional data view (AADL model)",
Argument => "DataView.aadl");
Switch => "-d:",
Long_Switch => "--dataview=",
Help => "Optional data view (AADL model)",
Argument => "DataView.aadl");
Define_Switch (Config, Output => Result.Check_Data_View'Access,
Switch => "-y",
Long_Switch => "--check-dataview",
Help => "Check Data View");
Define_Switch (Config, Output => Result.Output_Dir'Access,
Switch => "-o:", Long_Switch => "--output=",
Help => "Output directory (to be created if absent)",
Argument => "Folder");
Switch => "-o:",
Long_Switch => "--output=",
Help => "Output directory (created if absent)",
Argument => "Folder");
Define_Switch (Config, Output => Result.Skeletons'Access,
Switch => "-w", Long_Switch => "--gw",
Help => "Generate models and code skeletons");
Switch => "-w",
Long_Switch => "--gw",
Help => "Generate models and code skeletons");
Define_Switch (Config, Output => Result.Glue'Access,
Switch => "-l", Long_Switch => "--glue",
Help => "Generate glue code");
Switch => "-l",
Long_Switch => "--glue",
Help => "Generate glue code");
Define_Switch (Config, Output => Result.Use_POHIC'Access,
Switch => "-p", Long_Switch => "--polyorb-hi-c",
Help => "Use PolyORB-HI-C runtime in place of Ada");
Switch => "-p",
Long_Switch => "--polyorb-hi-c",
Help => "Use PolyORB-HI-C runtime");
Define_Switch (Config, Output => Result.Timer_Resolution'Access,
Switch => "-x:", Long_Switch => "--timer=",
Initial => 100,
Help => "Specify timer resolution (default 100 ms)");
Switch => "-x:",
Long_Switch => "--timer=",
Initial => 100,
Help => "Timer resolution (default 100 ms)");
Define_Switch (Config, Output => Result.Debug_Flag'Access,
Switch => "-g", Long_Switch => "--debug",
Help => "Set debug mode");
Switch => "-g",
Long_Switch => "--debug",
Help => "Set debug mode");
Define_Switch (Config, Output => Result.Version'Access,
Switch => "-v", Long_Switch => "--version",
Help => "Display tool version");
Switch => "-v",
Long_Switch => "--version",
Help => "Display tool version");
Getopt (Config);
loop
......
......@@ -110,6 +110,7 @@ package TASTE.Parser_Utils is
Deployment_View : aliased GNAT.Strings.String_Access;
Data_View : aliased GNAT.Strings.String_Access;
Output_Dir : aliased GNAT.Strings.String_Access;
Check_Data_View : aliased Boolean := False;
Skeletons : aliased Boolean := False;
Glue : aliased Boolean := False;
Use_POHIC : aliased Boolean := False;
......
package TASTE.Parser_Version is
Parser_Release : constant String :=
"690de90 ; Commit Date: Mon Mar 12 21:50:07 2018 ";
"5a9ad95 ; Commit Date: Wed Mar 14 14:09:23 2018 ";
Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from r61c0f39)";
"Ocarina 2017.x (Working Copy from r957625a)";
end TASTE.Parser_Version;
\ No newline at end of file
DataView DEFINITIONS ::=
BEGIN
MyInteger ::= INTEGER (0..65535)
END
......@@ -3,7 +3,7 @@ all: test-parse
test-parse: clean
$(AADL_PARSER) -o output -i InterfaceView.aadl -d DataView.aadl ../common/TASTE_IV_Properties.aadl \
$(AADL_PARSER) --check-dataview \
2>&1 | tail -2 | diff expected -
clean:
......
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