Commit 8dbaec92 authored by Jerome Hugues's avatar Jerome Hugues
Browse files

* Rework circuitry to handle the case of system-in-system models

        For issue #61
parent 77687a24
...@@ -31,10 +31,9 @@ ...@@ -31,10 +31,9 @@
with Ada.Unchecked_Deallocation; with Ada.Unchecked_Deallocation;
with GNAT.Table;
with GNAT.OS_Lib;
with GNAT.Directory_Operations; with GNAT.Directory_Operations;
with GNAT.OS_Lib;
with GNAT.Table;
with Ocarina.Namet; with Ocarina.Namet;
with Ocarina.Output; with Ocarina.Output;
...@@ -306,6 +305,9 @@ package body Ocarina.Backends.Build_Utils is ...@@ -306,6 +305,9 @@ package body Ocarina.Backends.Build_Utils is
Current_Process : Node_Id := No_Node; Current_Process : Node_Id := No_Node;
Appli_Name : Name_Id := No_Name;
-- Denotes the application name, derived from the AADL root system name
type Makefile_Rec is record type Makefile_Rec is record
Appli_Name : Name_Id; Appli_Name : Name_Id;
-- The distributed application name -- The distributed application name
...@@ -314,7 +316,7 @@ package body Ocarina.Backends.Build_Utils is ...@@ -314,7 +316,7 @@ package body Ocarina.Backends.Build_Utils is
-- The node name (in lower case) -- The node name (in lower case)
Execution_Platform : Supported_Execution_Platform := Platform_None; Execution_Platform : Supported_Execution_Platform := Platform_None;
Execution_Platform_Name : Name_Id := No_Name; Execution_Platform_Name : Name_Id := No_Name;
-- The execution platform of the processor the current node -- The execution platform of the processor the current node
-- is bound to. -- is bound to.
...@@ -924,7 +926,6 @@ package body Ocarina.Backends.Build_Utils is ...@@ -924,7 +926,6 @@ package body Ocarina.Backends.Build_Utils is
procedure Visit_Process_Instance (E : Node_Id) is procedure Visit_Process_Instance (E : Node_Id) is
C : Node_Id; C : Node_Id;
S : constant Node_Id := Parent_Subcomponent (E); S : constant Node_Id := Parent_Subcomponent (E);
A : constant Node_Id := Parent_Component (Parent_Subcomponent (E));
M : constant Makefile_Type := new Makefile_Rec; M : constant Makefile_Type := new Makefile_Rec;
SC : Node_Id; SC : Node_Id;
Current_Device : Node_Id; Current_Device : Node_Id;
...@@ -945,7 +946,7 @@ package body Ocarina.Backends.Build_Utils is ...@@ -945,7 +946,7 @@ package body Ocarina.Backends.Build_Utils is
Makefiles.Set (E, M); Makefiles.Set (E, M);
M.Appli_Name := Normalize_Name (Name (Identifier (A))); M.Appli_Name := Appli_Name;
M.Node_Name := Normalize_Name (Name (Identifier (S))); M.Node_Name := Normalize_Name (Name (Identifier (S)));
M.Use_Transport := False; M.Use_Transport := False;
M.Use_Simulink := False; M.Use_Simulink := False;
...@@ -1075,6 +1076,15 @@ package body Ocarina.Backends.Build_Utils is ...@@ -1075,6 +1076,15 @@ package body Ocarina.Backends.Build_Utils is
S : Node_Id; S : Node_Id;
begin begin
if Appli_Name = No_Name then
-- We need a unique application name, derived from the
-- root system. The application name is used to derive
-- the name of the root directory in which files are
-- generated.
Appli_Name := Normalize_Name (Name (Identifier (E)));
end if;
-- Visit all the subcomponents of the system -- Visit all the subcomponents of the system
if not AAU.Is_Empty (Subcomponents (E)) then if not AAU.Is_Empty (Subcomponents (E)) then
...@@ -1382,68 +1392,53 @@ package body Ocarina.Backends.Build_Utils is ...@@ -1382,68 +1392,53 @@ package body Ocarina.Backends.Build_Utils is
Fd : File_Descriptor; Fd : File_Descriptor;
begin begin
if Is_Directory (Get_Name_String (Dir_Name)) then -- If the current system is not the root system
-- Create the file -- (e.g. case of a deep hierarchy with systems inside
Enter_Directory (Dir_Name); -- systems, no source has been generated, we exit
Fd := Create_File ("Makefile", Text); -- immediatly,
Write_Eol;
if Fd = Invalid_FD then
raise Program_Error;
end if;
-- Setting the output
Set_Output (Fd); if not Is_Directory (Get_Name_String (Dir_Name)) then
return;
end if;
Write_Line -- else, we create the makefile
("###################################################");
Write_Line
("# This Makefile has been generated automatically #");
Write_Line
("# by the Ocarina AADL toolsuite. #");
Write_Line
("# Do not edit this file, all your changes will #");
Write_Line
("# be overridden at the next code generation. #");
Write_Line
("###################################################");
Write_Eol;
Write_Str ("SUBDIRS = "); Enter_Directory (Dir_Name);
if not AAU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop Fd := Create_File ("Makefile", Text);
if AAU.Is_Process (Corresponding_Instance (S)) then if Fd = Invalid_FD then
Write_Name (Normalize_Name (Name (Identifier (S)))); raise Program_Error;
Write_Str (" "); end if;
-- Corresponding_Instance (S)))));
end if; -- Setting the output
S := Next_Node (S);
end loop;
end if;
Write_Eol;
Write_Line ("all:"); Set_Output (Fd);
Write_Line
(ASCII.HT &
"set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done");
Write_Line ("clean:"); Write_Line ("###################################################");
Write_Line Write_Line ("# This Makefile has been generated automatically #");
(ASCII.HT & Write_Line ("# by the Ocarina AADL toolsuite. #");
" set -e; for d in $(SUBDIRS); do $(MAKE) " & Write_Line ("# Do not edit this file, all your changes will #");
"clean -C $$d ; done"); Write_Line ("# be overridden at the next code generation. #");
Write_Line ("###################################################");
Write_Eol;
Write_Str ("SUBDIRS = $(filter-out Makefile, $(wildcard *))");
Write_Eol;
Write_Line ("all:");
Write_Line
(ASCII.HT &
"set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done");
Write_Eol;
Write_Line ("clean:");
Write_Line
(ASCII.HT &
"set -e; for d in $(SUBDIRS); do $(MAKE) " &
"clean -C $$d ; done");
-- Close the file -- Close the file
Close (Fd); Close (Fd);
Set_Standard_Output; Set_Standard_Output;
Leave_Directory; Leave_Directory;
end if;
-- Generate the makefiles of all process subcomponents -- Generate the makefiles of all process subcomponents
......
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