From c63b580c0cb764b55cb9c6d80390caac5771f175 Mon Sep 17 00:00:00 2001 From: yoogx Date: Wed, 14 Aug 2013 13:55:32 +0200 Subject: [PATCH] * Generate top-level Makefiles only in existing directories. --- src/backends/ocarina-backends-build_utils.adb | 106 ++++++++++-------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/src/backends/ocarina-backends-build_utils.adb b/src/backends/ocarina-backends-build_utils.adb index c9e4ec79..62b22743 100644 --- a/src/backends/ocarina-backends-build_utils.adb +++ b/src/backends/ocarina-backends-build_utils.adb @@ -1387,66 +1387,76 @@ package body Ocarina.Backends.Build_Utils is ------------------------------ procedure Generate_System_Instance (E : Node_Id) is + Dir_Name : constant Name_Id + := Normalize_Name (Name (Identifier (E))); + S : Node_Id; Fd : File_Descriptor; + begin - -- Create the file - Enter_Directory (Normalize_Name (Name (Identifier (E)))); - Fd := Create_File ("Makefile", Text); + if Is_Directory (Get_Name_String (Dir_Name)) then + -- Create the file + Enter_Directory (Dir_Name); + Fd := Create_File ("Makefile", Text); - Write_Eol; + Write_Eol; - if Fd = Invalid_FD then - raise Program_Error; - end if; + if Fd = Invalid_FD then + raise Program_Error; + end if; - -- Setting the output + -- 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))))); - Set_Output (Fd); + end if; + S := Next_Node (S); + end loop; + end if; + Write_Eol; - 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_Line ("all:"); + Write_Line + (ASCII.HT + & "set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done"); - Write_Str ("SUBDIRS = "); - if not AAU.Is_Empty (Subcomponents (E)) then - S := First_Node (Subcomponents (E)); + Write_Line ("clean:"); + Write_Line + (ASCII.HT & " set -e; for d in $(SUBDIRS); do $(MAKE) " + & "clean -C $$d ; done"); - while Present (S) loop - if AAU.Is_Process (Corresponding_Instance (S)) then - Write_Name - (Normalize_Name - (Name (Identifier (S)))); - Write_Str (" "); - -- Corresponding_Instance (S))))); + -- Close the file - end if; - S := Next_Node (S); - end loop; + Close (Fd); + Set_Standard_Output; + Leave_Directory; end if; - Write_Eol; - - Write_Line ("all:"); - Write_Line - (ASCII.HT - & "set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done"); - - Write_Line ("clean:"); - Write_Line - (ASCII.HT - & - " set -e; for d in $(SUBDIRS); do $(MAKE) clean -C $$d ; done" - ); - - -- Close the file - - Close (Fd); - Set_Standard_Output; - Leave_Directory; -- Generate the makefiles of all process subcomponents -- GitLab