diff --git a/src/backends/ocarina-backends-build_utils.adb b/src/backends/ocarina-backends-build_utils.adb index ed6dd87dc858e19efcfd551426c5c886811ddaf3..f470de8df5d1daee14548a453a922f49d606e7ad 100644 --- a/src/backends/ocarina-backends-build_utils.adb +++ b/src/backends/ocarina-backends-build_utils.adb @@ -192,8 +192,8 @@ package body Ocarina.Backends.Build_Utils is ----------------------- function Get_Internal_Name (P : Node_Id) return Name_Id is - begin pragma Assert (AAU.Is_Process (P)); + begin Set_Nat_To_Name_Buffer (Nat (P)); Add_Str_To_Name_Buffer ('%' & Id & '%'); @@ -1078,6 +1078,7 @@ package body Ocarina.Backends.Build_Utils is procedure Visit_System_Instance (E : Node_Id) is S : Node_Id; + begin -- Visit all the subcomponents of the system @@ -1386,7 +1387,59 @@ package body Ocarina.Backends.Build_Utils is procedure Generate_System_Instance (E : Node_Id) is S : Node_Id; + Fd : File_Descriptor; begin + -- Create the file + Enter_Directory (Normalize_Name (Name (Identifier (E)))); + Fd := Create_File ("Makefile", Text); + + Write_Eol; + + if Fd = Invalid_FD then + raise Program_Error; + end if; + + -- Setting the output + + Set_Output (Fd); + + Write_Line ("###################################################"); + 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 = "); + if not AAU.Is_Empty (Subcomponents (E)) then + S := First_Node (Subcomponents (E)); + + while Present (S) loop + if AAU.Is_Process (Corresponding_Instance (S)) then + Write_Name + (Normalize_Name + (Name (Identifier (S)))); + Write_Str (" "); + -- Corresponding_Instance (S))))); + + end if; + S := Next_Node (S); + end loop; + end if; + Write_Eol; + + Write_Line ("all:"); + Write_Line + (ASCII.HT + & "set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done"); + + -- Close the file + + Close (Fd); + Set_Standard_Output; + Leave_Directory; + -- Generate the makefiles of all process subcomponents if not AAU.Is_Empty (Subcomponents (E)) then