-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
Mapping_File : String_Ptr := null;
+ package Closure_Sources is new Table.Table
+ (Table_Component_Type => File_Name_Type,
+ Table_Index_Type => Natural,
+ Table_Low_Bound => 1,
+ Table_Initial => 10,
+ Table_Increment => 100,
+ Table_Name => "Gnatbind.Closure_Sources");
+ -- Table to record the sources in the closure, to avoid duplications. Used
+ -- only with switch -R.
+
function Gnatbind_Supports_Auto_Init return Boolean;
-- Indicates if automatic initialization of elaboration procedure
-- through the constructor mechanism is possible on the platform.
-- should not be listed.
No_Restriction_List : constant array (All_Restrictions) of Boolean :=
- (No_Exception_Propagation => True,
+ (No_Allocators_After_Elaboration => True,
+ -- This involves run-time conditions not checkable at compile time
+
+ No_Anonymous_Allocators => True,
+ -- Premature, since we have not implemented this yet
+
+ No_Exception_Propagation => True,
-- Modifies code resulting in different exception semantics
- No_Exceptions => True,
+ No_Exceptions => True,
-- Has unexpected Suppress (All_Checks) effect
- No_Implicit_Conditionals => True,
+ No_Implicit_Conditionals => True,
-- This could modify and pessimize generated code
- No_Implicit_Dynamic_Code => True,
+ No_Implicit_Dynamic_Code => True,
-- This could modify and pessimize generated code
- No_Implicit_Loops => True,
+ No_Implicit_Loops => True,
-- This could modify and pessimize generated code
- No_Recursion => True,
+ No_Recursion => True,
-- Not checkable at compile time
- No_Reentrancy => True,
+ No_Reentrancy => True,
-- Not checkable at compile time
- Max_Entry_Queue_Length => True,
+ Max_Entry_Queue_Length => True,
-- Not checkable at compile time
- Max_Storage_At_Blocking => True,
+ Max_Storage_At_Blocking => True,
-- Not checkable at compile time
- others => False);
+ others => False);
Additional_Restrictions_Listed : Boolean := False;
-- Set True if we have listed header for restrictions
end Scan_Bind_Arg;
procedure Check_Version_And_Help is
- new Check_Version_And_Help_G (Bindusg.Display);
+ new Check_Version_And_Help_G (Bindusg.Display);
-- Start of processing for Gnatbind
begin
-
-- Set default for Shared_Libgnat option
declare
Check_Extensions : declare
Length : constant Natural := Output_File_Name'Length;
Last : constant Natural := Output_File_Name'Last;
-
begin
- if Ada_Bind_File then
- if Length <= 4
- or else Output_File_Name (Last - 3 .. Last) /= ".adb"
- then
- Fail ("output file name should have .adb extension");
- end if;
-
- else
- if Length <= 2
- or else Output_File_Name (Last - 1 .. Last) /= ".c"
- then
- Fail ("output file name should have .c extension");
- end if;
+ if Length <= 4
+ or else Output_File_Name (Last - 3 .. Last) /= ".adb"
+ then
+ Fail ("output file name should have .adb extension");
end if;
end Check_Extensions;
end if;
Osint.Add_Default_Search_Dirs;
-- Carry out package initializations. These are initializations which
- -- might logically be performed at elaboration time, but Namet at least
- -- can't be done that way (because it is used in the Compiler), and we
- -- decide to be consistent. Like elaboration, the order in which these
- -- calls are made is in some cases important.
+ -- might logically be performed at elaboration time, and we decide to be
+ -- consistent. Like elaboration, the order in which these calls are made
+ -- is in some cases important.
Csets.Initialize;
- Namet.Initialize;
Snames.Initialize;
-- Acquire target parameters
Free (Text);
end if;
- -- Acquire all information in ALI files that have been read in
+ -- Load ALIs for all dependent units
for Index in ALIs.First .. ALIs.Last loop
- Read_ALI (Index);
+ Read_Withed_ALIs (Index);
end loop;
-- Quit if some file needs compiling
raise Unrecoverable_Error;
end if;
+ -- Output list of ALI files in closure
+
+ if Output_ALI_List then
+ if ALI_List_Filename /= null then
+ Set_List_File (ALI_List_Filename.all);
+ end if;
+
+ for Index in ALIs.First .. ALIs.Last loop
+ declare
+ Full_Afile : constant File_Name_Type :=
+ Find_File (ALIs.Table (Index).Afile, Library);
+ begin
+ Write_Name (Full_Afile);
+ Write_Eol;
+ end;
+ end loop;
+
+ if ALI_List_Filename /= null then
+ Close_List_File;
+ end if;
+ end if;
+
-- Build source file table from the ALI files we have read in
Set_Source_Table;
and then ALIs.Table (ALIs.First).Main_Program = None
and then not No_Main_Subprogram
then
- Error_Msg_File_1 := Main_Lib_File;
- Error_Msg ("{ does not contain a unit that can be a main program");
+ Get_Name_String
+ (Units.Table (ALIs.Table (ALIs.First).First_Unit).Uname);
+
+ declare
+ Unit_Name : String := Name_Buffer (1 .. Name_Len - 2);
+ begin
+ To_Mixed (Unit_Name);
+ Get_Name_String (ALIs.Table (ALIs.First).Sfile);
+ Add_Str_To_Name_Buffer (":1: ");
+ Add_Str_To_Name_Buffer (Unit_Name);
+ Add_Str_To_Name_Buffer (" cannot be used as a main program");
+ Write_Line (Name_Buffer (1 .. Name_Len));
+ Errors_Detected := Errors_Detected + 1;
+ end;
end if;
-- Perform consistency and correctness checks
-- sources) if -R was used.
if List_Closure then
- declare
- package Sources is new Table.Table
- (Table_Component_Type => File_Name_Type,
- Table_Index_Type => Natural,
- Table_Low_Bound => 1,
- Table_Initial => 10,
- Table_Increment => 100,
- Table_Name => "Gnatbind.Sources");
- -- Table to record the sources in the closure, to avoid
- -- dupications.
-
+ List_Closure_Display : declare
Source : File_Name_Type;
function Put_In_Sources (S : File_Name_Type) return Boolean;
-- Put_In_Sources --
--------------------
- function Put_In_Sources (S : File_Name_Type)
- return Boolean
- is
+ function Put_In_Sources
+ (S : File_Name_Type) return Boolean is
begin
- for J in 1 .. Sources.Last loop
- if Sources.Table (J) = S then
+ for J in 1 .. Closure_Sources.Last loop
+ if Closure_Sources.Table (J) = S then
return False;
end if;
end loop;
- Sources.Append (S);
+ Closure_Sources.Append (S);
return True;
end Put_In_Sources;
+ -- Start of processing for List_Closure_Display
+
begin
+ Closure_Sources.Init;
+
if not Zero_Formatting then
Write_Eol;
Write_Str ("REFERENCED SOURCES");
end if;
for J in reverse Elab_Order.First .. Elab_Order.Last loop
-
Source := Units.Table (Elab_Order.Table (J)).Sfile;
-- Do not include the sources of the runtime and do not
Write_Str (" ");
end if;
- Write_Str (Get_Name_String (Source));
+ Write_Str (Get_Name_String (Source));
Write_Eol;
end if;
end loop;
if not Zero_Formatting then
Write_Eol;
end if;
- end;
+ end List_Closure_Display;
end if;
end if;
end if;
null;
end if;
-
end Gnatbind;