Commit a3a0db2e by Arnaud Charlet

prj-makr.adb (Process_Directory): Put file name in canonical case before…

prj-makr.adb (Process_Directory): Put file name in canonical case before matching against the patterns.

	* prj-makr.adb (Process_Directory): Put file name in canonical case
	before matching against the patterns.
	If gnatname has been invoked as <prefix>-gnatname
	then invoke the compiler as <prefix>-gcc, not just "gcc".

From-SVN: r94819
parent 3536d406
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2004 Free Software Foundation, Inc. -- -- Copyright (C) 2001-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -44,14 +44,13 @@ with GNAT.OS_Lib; use GNAT.OS_Lib; ...@@ -44,14 +44,13 @@ with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Regexp; use GNAT.Regexp; with GNAT.Regexp; use GNAT.Regexp;
with System.Case_Util; use System.Case_Util; with System.Case_Util; use System.Case_Util;
with System.CRTL;
package body Prj.Makr is package body Prj.Makr is
function Dup (Fd : File_Descriptor) return File_Descriptor; function Dup (Fd : File_Descriptor) return File_Descriptor;
pragma Import (C, Dup);
procedure Dup2 (Old_Fd, New_Fd : File_Descriptor); procedure Dup2 (Old_Fd, New_Fd : File_Descriptor);
pragma Import (C, Dup2);
Gcc : constant String := "gcc"; Gcc : constant String := "gcc";
Gcc_Path : String_Access := null; Gcc_Path : String_Access := null;
...@@ -64,11 +63,11 @@ package body Prj.Makr is ...@@ -64,11 +63,11 @@ package body Prj.Makr is
Naming_File_Suffix : constant String := "_naming"; Naming_File_Suffix : constant String := "_naming";
Source_List_File_Suffix : constant String := "_source_list.txt"; Source_List_File_Suffix : constant String := "_source_list.txt";
Output_FD : File_Descriptor; Output_FD : File_Descriptor;
-- To save the project file and its naming project file. -- To save the project file and its naming project file
procedure Write_Eol; procedure Write_Eol;
-- Output an empty line. -- Output an empty line
procedure Write_A_Char (C : Character); procedure Write_A_Char (C : Character);
-- Write one character to Output_FD -- Write one character to Output_FD
...@@ -84,6 +83,26 @@ package body Prj.Makr is ...@@ -84,6 +83,26 @@ package body Prj.Makr is
Table_Increment => 10, Table_Increment => 10,
Table_Name => "Prj.Makr.Processed_Directories"); Table_Name => "Prj.Makr.Processed_Directories");
---------
-- Dup --
---------
function Dup (Fd : File_Descriptor) return File_Descriptor is
begin
return File_Descriptor (System.CRTL.dup (Integer (Fd)));
end Dup;
----------
-- Dup2 --
----------
procedure Dup2 (Old_Fd, New_Fd : File_Descriptor) is
Fd : Integer;
pragma Warnings (Off, Fd);
begin
Fd := System.CRTL.dup2 (Integer (Old_Fd), Integer (New_Fd));
end Dup2;
---------- ----------
-- Make -- -- Make --
---------- ----------
...@@ -160,19 +179,17 @@ package body Prj.Makr is ...@@ -160,19 +179,17 @@ package body Prj.Makr is
----------------------- -----------------------
procedure Process_Directory (Dir_Name : String; Recursively : Boolean) is procedure Process_Directory (Dir_Name : String; Recursively : Boolean) is
Matched : Matched_Type := False; Matched : Matched_Type := False;
Str : String (1 .. 2_000); Str : String (1 .. 2_000);
Last : Natural; Canon : String (1 .. 2_000);
Dir : Dir_Type; Last : Natural;
Process : Boolean := True; Dir : Dir_Type;
Process : Boolean := True;
Temp_File_Name : String_Access := null;
Temp_File_Name : String_Access := null;
Save_Last_Pragma_Index : Natural := 0; Save_Last_Pragma_Index : Natural := 0;
File_Name_Id : Name_Id := No_Name;
File_Name_Id : Name_Id := No_Name; SFN_Prag : SFN_Pragma;
SFN_Prag : SFN_Pragma;
begin begin
-- Avoid processing the same directory more than once -- Avoid processing the same directory more than once
...@@ -195,12 +212,11 @@ package body Prj.Makr is ...@@ -195,12 +212,11 @@ package body Prj.Makr is
Processed_Directories.Table (Processed_Directories.Last) := Processed_Directories.Table (Processed_Directories.Last) :=
new String'(Dir_Name); new String'(Dir_Name);
-- Get the source file names from the directory. -- Get the source file names from the directory. Fails if the
-- Fails if the directory does not exist. -- directory does not exist.
begin begin
Open (Dir, Dir_Name); Open (Dir, Dir_Name);
exception exception
when Directory_Error => when Directory_Error =>
Prj.Com.Fail ("cannot open directory """, Dir_Name, """"); Prj.Com.Fail ("cannot open directory """, Dir_Name, """");
...@@ -212,6 +228,13 @@ package body Prj.Makr is ...@@ -212,6 +228,13 @@ package body Prj.Makr is
Read (Dir, Str, Last); Read (Dir, Str, Last);
exit File_Loop when Last = 0; exit File_Loop when Last = 0;
-- Copy the file name and put it in canonical case to match
-- against the patterns that have themselves already been put
-- in canonical case.
Canon (1 .. Last) := Str (1 .. Last);
Canonical_Case_File_Name (Canon (1 .. Last));
if Is_Regular_File if Is_Regular_File
(Dir_Name & Directory_Separator & Str (1 .. Last)) (Dir_Name & Directory_Separator & Str (1 .. Last))
then then
...@@ -226,7 +249,7 @@ package body Prj.Makr is ...@@ -226,7 +249,7 @@ package body Prj.Makr is
for Index in Excluded_Expressions'Range loop for Index in Excluded_Expressions'Range loop
if if
Match (Str (1 .. Last), Excluded_Expressions (Index)) Match (Canon (1 .. Last), Excluded_Expressions (Index))
then then
Matched := Excluded; Matched := Excluded;
exit; exit;
...@@ -242,7 +265,8 @@ package body Prj.Makr is ...@@ -242,7 +265,8 @@ package body Prj.Makr is
for Index in Regular_Expressions'Range loop for Index in Regular_Expressions'Range loop
if if
Match (Str (1 .. Last), Regular_Expressions (Index)) Match
(Canon (1 .. Last), Regular_Expressions (Index))
then then
Matched := True; Matched := True;
exit; exit;
...@@ -270,10 +294,18 @@ package body Prj.Makr is ...@@ -270,10 +294,18 @@ package body Prj.Makr is
begin begin
-- If we don't have the path of the compiler yet, -- If we don't have the path of the compiler yet,
-- get it now. -- get it now. The compiler name may have a prefix,
-- so we get the potentially prefixed name.
if Gcc_Path = null then if Gcc_Path = null then
Gcc_Path := Locate_Exec_On_Path (Gcc); declare
Prefix_Gcc : String_Access :=
Program_Name (Gcc);
begin
Gcc_Path :=
Locate_Exec_On_Path (Prefix_Gcc.all);
Free (Prefix_Gcc);
end;
if Gcc_Path = null then if Gcc_Path = null then
Prj.Com.Fail ("could not locate " & Gcc); Prj.Com.Fail ("could not locate " & Gcc);
...@@ -538,7 +570,7 @@ package body Prj.Makr is ...@@ -538,7 +570,7 @@ package body Prj.Makr is
if Matched /= Excluded then if Matched /= Excluded then
for Index in Foreign_Expressions'Range loop for Index in Foreign_Expressions'Range loop
if Match (Str (1 .. Last), if Match (Canon (1 .. Last),
Foreign_Expressions (Index)) Foreign_Expressions (Index))
then then
Matched := True; Matched := True;
......
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