Previously we used to create the SARIF file next to the specified
source file e.g. "<Specified_Source_File_Path>.gnat.sarif"
Now the SARIF file is always generated in the cwd
"<Source_File_Name>.gnat.sarif" similarly to how gcc handles its sarif
files.
gcc/ada/ChangeLog:
* errout.adb (Output_Messages): use the source file name without
the directory path when constructing the name of the SARIF file.
* osint.adb (Strip_Directory): New method for extracting the file name
from a given path.
* osint.ads (Strip_Directory): Likewise.
E : Error_Msg_Id;
Err_Flag : Boolean;
- Sarif_File_Name : constant String :=
- Get_First_Main_File_Name & ".gnat.sarif";
+ Sarif_File_Name : constant String :=
+ Strip_Directory (Get_First_Main_File_Name) & ".gnat.sarif";
Printer : Erroutc.SARIF_Emitter.SARIF_Printer;
return Name;
end Strip_Directory;
+ ---------------------
+ -- Strip_Directory --
+ ---------------------
+
+ function Strip_Directory (Name : String) return String is
+ begin
+ pragma Assert (not Is_Directory_Separator (Name (Name'Last)));
+
+ for I in reverse Name'Range loop
+ if Is_Directory_Separator (Name (I)) then
+ return Name (I + 1 .. Name'Last);
+ end if;
+ end loop;
+
+ return Name;
+ end Strip_Directory;
+
------------------
-- Strip_Suffix --
------------------
-- Strips the prefix directory name (if any) from Name. Returns the
-- stripped name. Name cannot end with a directory separator.
+ function Strip_Directory (Name : String) return String;
+ -- Strips the prefix directory name (if any) from Name. Returns the
+ -- stripped name. Name cannot end with a directory separator.
+
function Strip_Suffix (Name : File_Name_Type) return File_Name_Type;
-- Strips the suffix (the last '.' and whatever comes after it) from Name.
-- Returns the stripped name.