8sa1-gcc/gcc/ada/mdll-utl.adb
Robert Dewar bfc8aa81e4 fmap.adb: Put routines in alpha order
2006-10-31  Robert Dewar  <dewar@adacore.com>
	    Thomas Quinot  <quinot@adacore.com>
	    Arnaud Charlet  <charlet@adacore.com>

	* fmap.adb: Put routines in alpha order

	* g-boumai.ads: Remove redundant 'in' keywords

	* g-cgi.adb: Minor reformatting

	* g-cgi.ads: Remove redundant 'in' keywords

	* get_targ.adb: Put routines in alpha order

	* prj-attr.ads: Minor reformatting

	* s-atacco.ads: Minor reformatting

	* scn.adb: Put routines in alpha order

	* sinput-l.adb: Minor comment fix

	* sinput-p.adb: Minor comment fix

	* s-maccod.ads: Minor reformatting

	* s-memory.adb: Minor reformatting

	* s-htable.adb: Fix typo in comment.

	* s-secsta.adb: Minor comment update.

	* s-soflin.adb: Minor reformatting

	* s-stoele.ads: 
	Add comment about odd qualification in Storage_Offset declaration

	* s-strxdr.adb: 
	Remove unnecessary 'in' keywords for formal parameters.

	* treeprs.adt: Minor reformatting

	* urealp.adb: Put routines in alpha order

	* s-wchcon.ads, s-wchcon.adb (Get_WC_Encoding_Method): New version
	taking string.

	* s-asthan-vms-alpha.adb: Remove redundant 'in' keywords

	* g-trasym-vms-ia64.adb: Remove redundant 'in' keywords

	* env.c (__gnat_unsetenv): Unsetenv is unavailable on LynxOS, so
	workaround as on other platforms.

	* g-eacodu-vms.adb: Remove redundant 'in' keywords
	* g-expect-vms.adb: Remove redundant 'in' keywords

	* gnatdll.adb (Add_Files_From_List): Handle Name_Error and report a
	clear error message if the list-of-files file cannot be opened.

	* g-thread.adb (Unregister_Thread_Id): Add use type Thread_Id so the
	equality operator is always visible.

	* lang.opt: Woverlength-strings: New option.

	* nmake.adt: 
	Update copyright, since nmake.ads and nmake.adb have changed.

	* osint-b.ads, osint-b.adb (Time_From_Last_Bind): removed function .
	(Binder_Output_Time_Stamps_Set): removed.
	(Old_Binder_Output_Time_Stamp): idem.
	(New_Binder_Output_Time_Stamp): idem.
	(Recording_Time_From_Last_Bind): idem.
	(Recording_Time_From_Last_Bind): Make constant.

	* output.ads, output.adb (Write_Str): Allow LF characters
	(Write_Spaces): New procedure

	* prepcomp.adb (Preproc_Data_Table): Change Increment from 5% to 100%

	* inline.adb: Minor reformatting

	* s-asthan-vms-alpha.adb: Remove redundant 'in' keywords

	* s-mastop-vms.adb: Remove redundant 'in' keywords

	* s-osprim-vms.adb: Remove redundant 'in' keywords

	* s-trafor-default.adb: Remove redundant 'in' keywords

	* 9drpc.adb: Remove redundant 'in' keywords

	* s-osinte-mingw.ads: Minor reformatting

	* s-inmaop-posix.adb: Minor reformatting

	* a-direio.ads: Remove quotes from Compile_Time_Warning message

	* a-exexda.adb: Minor code reorganization

	* a-filico.adb: Minor reformatting

	* a-finali.adb: Minor reformatting

	* a-nudira.ads: Remove quote from Compile_Time_Warning message

	* a-numeri.ads: Minor reformatting

	* a-sequio.ads: Remove quotes from Compile_Time_Warning message

	* exp_pakd.ads: Fix obsolete comment

	* a-ztenau.adb, a-ztenio.adb, a-wtenau.adb, a-tienau.adb,
	a-wtenio.adb (Put): Avoid assuming low bound of string is 1.
	Probably not a bug, but certainly neater and more efficient.

	* a-tienio.adb: Minor reformatting

	* comperr.adb (Compiler_Abort): Call Cancel_Special_Output at start
	Avoid assuming low bound of string is 1.

	* gnatbind.adb: Change Bindusg to package and rename procedure as
	Display, which now ensures that it only outputs usage information once.
	(Scan_Bind_Arg): Avoid assuming low bound of string is 1.

	* g-pehage.adb (Build_Identical_Keysets): Replace use of 1 by
	Table'First.

	* g-regpat.adb (Insert_Operator): Add pragma Warnings (Off) to kill
	warning.
	(Match): Add pragma Assert to ensure that Matches'First is zero

	* g-regpat.ads (Match): Document that Matches lower bound must be zero

	* makeutl.adb (Is_External_Assignment): Add pragma Assert's to check
	documented preconditions (also kills warnings about bad indexes).

	* mdll.adb (Build_Dynamic_Library): Avoid assumption that Afiles'First
	is 1.
	(Build_Import_Library): Ditto;

	* mdll-utl.adb: (Gnatbind): Avoid assumption that Alis'First = 1

	* rtsfind.adb (RTE_Error_Msg): Avoid assuming low bound of string is 1.

	* sem_case.adb (Analyze_Choices): Add pragma Assert to check that
	lower bound of choice table is 1.

	* sem_case.ads (Analyze_Choices): Document that lower bound of
	Choice_Table is 1.

	* s-imgdec.adb (Set_Decimal_Digits): Avoid assuming low bound of
	string is 1.

	* uintp.adb (Init_Operand): Document that low bound of Vec is always 1,
	and add appropriate Assert pragma to suppress warnings.

	* atree.h, atree.ads, atree.adb
	Change Elist24 to Elist25
	Add definitions of Field28 and Node28
	(Traverse_Field): Use new syntactic parent table in sinfo.

	* cstand.adb: Change name Is_Ada_2005 to Is_Ada_2005_Only

	* itypes.adb: Change name Is_Ada_2005 to Is_Ada_2005_Only

	* exp_tss.adb: Put routines in alpha order

	* fe.h: Remove redundant declarations.

From-SVN: r118330
2006-10-31 19:16:03 +01:00

368 lines
11 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M D L L . T O O L S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2006, 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- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Interface to externals tools used to build DLL and import libraries
with Ada.Text_IO;
with Ada.Exceptions;
with GNAT.Directory_Operations;
with Osint;
package body MDLL.Utl is
use Ada;
use GNAT;
Dlltool_Name : constant String := "dlltool";
Dlltool_Exec : OS_Lib.String_Access;
Gcc_Name : constant String := "gcc";
Gcc_Exec : OS_Lib.String_Access;
Gnatbind_Name : constant String := "gnatbind";
Gnatbind_Exec : OS_Lib.String_Access;
Gnatlink_Name : constant String := "gnatlink";
Gnatlink_Exec : OS_Lib.String_Access;
procedure Print_Command
(Tool_Name : String;
Arguments : OS_Lib.Argument_List);
-- display the command runned when in Verbose mode
-------------------
-- Print_Command --
-------------------
procedure Print_Command
(Tool_Name : String;
Arguments : OS_Lib.Argument_List)
is
begin
if Verbose then
Text_IO.Put (Tool_Name);
for K in Arguments'Range loop
Text_IO.Put (" " & Arguments (K).all);
end loop;
Text_IO.New_Line;
end if;
end Print_Command;
-------------
-- Dlltool --
-------------
procedure Dlltool
(Def_Filename : String;
DLL_Name : String;
Library : String;
Exp_Table : String := "";
Base_File : String := "";
Build_Import : Boolean)
is
Arguments : OS_Lib.Argument_List (1 .. 11);
A : Positive;
Success : Boolean;
Def_Opt : aliased String := "--def";
Def_V : aliased String := Def_Filename;
Dll_Opt : aliased String := "--dllname";
Dll_V : aliased String := DLL_Name;
Lib_Opt : aliased String := "--output-lib";
Lib_V : aliased String := Library;
Exp_Opt : aliased String := "--output-exp";
Exp_V : aliased String := Exp_Table;
Bas_Opt : aliased String := "--base-file";
Bas_V : aliased String := Base_File;
No_Suf_Opt : aliased String := "-k";
begin
Arguments (1 .. 4) := (1 => Def_Opt'Unchecked_Access,
2 => Def_V'Unchecked_Access,
3 => Dll_Opt'Unchecked_Access,
4 => Dll_V'Unchecked_Access);
A := 4;
if Kill_Suffix then
A := A + 1;
Arguments (A) := No_Suf_Opt'Unchecked_Access;
end if;
if Library /= "" and then Build_Import then
A := A + 1;
Arguments (A) := Lib_Opt'Unchecked_Access;
A := A + 1;
Arguments (A) := Lib_V'Unchecked_Access;
end if;
if Exp_Table /= "" then
A := A + 1;
Arguments (A) := Exp_Opt'Unchecked_Access;
A := A + 1;
Arguments (A) := Exp_V'Unchecked_Access;
end if;
if Base_File /= "" then
A := A + 1;
Arguments (A) := Bas_Opt'Unchecked_Access;
A := A + 1;
Arguments (A) := Bas_V'Unchecked_Access;
end if;
Print_Command ("dlltool", Arguments (1 .. A));
OS_Lib.Spawn (Dlltool_Exec.all, Arguments (1 .. A), Success);
if not Success then
Exceptions.Raise_Exception
(Tools_Error'Identity, Dlltool_Name & " execution error.");
end if;
end Dlltool;
---------
-- Gcc --
---------
procedure Gcc
(Output_File : String;
Files : Argument_List;
Options : Argument_List;
Base_File : String := "";
Build_Lib : Boolean := False)
is
use Osint;
Arguments : OS_Lib.Argument_List
(1 .. 5 + Files'Length + Options'Length);
A : Natural := 0;
Success : Boolean;
C_Opt : aliased String := "-c";
Out_Opt : aliased String := "-o";
Out_V : aliased String := Output_File;
Bas_Opt : aliased String := "-Wl,--base-file," & Base_File;
Lib_Opt : aliased String := "-mdll";
Lib_Dir : aliased String := "-L" & Object_Dir_Default_Prefix;
begin
A := A + 1;
if Build_Lib then
Arguments (A) := Lib_Opt'Unchecked_Access;
else
Arguments (A) := C_Opt'Unchecked_Access;
end if;
A := A + 1;
Arguments (A .. A + 2) := (Out_Opt'Unchecked_Access,
Out_V'Unchecked_Access,
Lib_Dir'Unchecked_Access);
A := A + 2;
if Base_File /= "" then
A := A + 1;
Arguments (A) := Bas_Opt'Unchecked_Access;
end if;
A := A + 1;
Arguments (A .. A + Files'Length - 1) := Files;
A := A + Files'Length - 1;
if Build_Lib then
A := A + 1;
Arguments (A .. A + Options'Length - 1) := Options;
A := A + Options'Length - 1;
else
declare
Largs : Argument_List (Options'Range);
L : Natural := Largs'First - 1;
begin
for K in Options'Range loop
if Options (K) (1 .. 2) /= "-l" then
L := L + 1;
Largs (L) := Options (K);
end if;
end loop;
A := A + 1;
Arguments (A .. A + L - 1) := Largs (1 .. L);
A := A + L - 1;
end;
end if;
Print_Command ("gcc", Arguments (1 .. A));
OS_Lib.Spawn (Gcc_Exec.all, Arguments (1 .. A), Success);
if not Success then
Exceptions.Raise_Exception
(Tools_Error'Identity, Gcc_Name & " execution error.");
end if;
end Gcc;
--------------
-- Gnatbind --
--------------
procedure Gnatbind
(Alis : Argument_List;
Args : Argument_List := Null_Argument_List)
is
Arguments : OS_Lib.Argument_List (1 .. 1 + Alis'Length + Args'Length);
Success : Boolean;
No_Main_Opt : aliased String := "-n";
begin
Arguments (1) := No_Main_Opt'Unchecked_Access;
Arguments (2 .. 1 + Alis'Length) := Alis;
Arguments (2 + Alis'Length .. Arguments'Last) := Args;
Print_Command ("gnatbind", Arguments);
OS_Lib.Spawn (Gnatbind_Exec.all, Arguments, Success);
-- Delete binder files on failure
if not Success then
declare
Base_Name : constant String :=
Directory_Operations.Base_Name (Alis (Alis'First).all, ".ali");
begin
OS_Lib.Delete_File ("b~" & Base_Name & ".ads", Success);
OS_Lib.Delete_File ("b~" & Base_Name & ".adb", Success);
end;
Exceptions.Raise_Exception
(Tools_Error'Identity, Gnatbind_Name & " execution error.");
end if;
end Gnatbind;
--------------
-- Gnatlink --
--------------
procedure Gnatlink
(Ali : String;
Args : Argument_List := Null_Argument_List)
is
Arguments : OS_Lib.Argument_List (1 .. 1 + Args'Length);
Success : Boolean;
Ali_Name : aliased String := Ali;
begin
Arguments (1) := Ali_Name'Unchecked_Access;
Arguments (2 .. Arguments'Last) := Args;
Print_Command ("gnatlink", Arguments);
OS_Lib.Spawn (Gnatlink_Exec.all, Arguments, Success);
if not Success then
-- Delete binder files
declare
Base_Name : constant String :=
Directory_Operations.Base_Name (Ali, ".ali");
begin
OS_Lib.Delete_File ("b~" & Base_Name & ".ads", Success);
OS_Lib.Delete_File ("b~" & Base_Name & ".adb", Success);
OS_Lib.Delete_File ("b~" & Base_Name & ".ali", Success);
OS_Lib.Delete_File ("b~" & Base_Name & ".o", Success);
end;
Exceptions.Raise_Exception
(Tools_Error'Identity, Gnatlink_Name & " execution error.");
end if;
end Gnatlink;
------------
-- Locate --
------------
procedure Locate is
use type OS_Lib.String_Access;
begin
-- dlltool
if Dlltool_Exec = null then
Dlltool_Exec := OS_Lib.Locate_Exec_On_Path (Dlltool_Name);
if Dlltool_Exec = null then
Exceptions.Raise_Exception
(Tools_Error'Identity, Dlltool_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Dlltool_Exec.all);
end if;
end if;
-- gcc
if Gcc_Exec = null then
Gcc_Exec := OS_Lib.Locate_Exec_On_Path (Gcc_Name);
if Gcc_Exec = null then
Exceptions.Raise_Exception
(Tools_Error'Identity, Gcc_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Gcc_Exec.all);
end if;
end if;
-- gnatbind
if Gnatbind_Exec = null then
Gnatbind_Exec := OS_Lib.Locate_Exec_On_Path (Gnatbind_Name);
if Gnatbind_Exec = null then
Exceptions.Raise_Exception
(Tools_Error'Identity, Gnatbind_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Gnatbind_Exec.all);
end if;
end if;
-- gnatlink
if Gnatlink_Exec = null then
Gnatlink_Exec := OS_Lib.Locate_Exec_On_Path (Gnatlink_Name);
if Gnatlink_Exec = null then
Exceptions.Raise_Exception
(Tools_Error'Identity, Gnatlink_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Gnatlink_Exec.all);
Text_IO.New_Line;
end if;
end if;
end Locate;
end MDLL.Utl;