Skip to content

Commit 6a13686

Browse files
committed
setup_rts: fix the loading of projects installed in the toolchain prefix
Trying to resolve the project file name with GPR2.Project.Create is wrong as this only looks up directories listed in the GPR_PROJECT_PATH environment variable: loading projects is also supposed to use the target information to look up projects in the toolchain installation prefix. As a consequence, "gnatcov instrument" fails to load the setup configuration when it is supposed to load gnatcov_rts.gpr as installed by "gnatcov setup" (no --prefix): GPR2 then tries to load gnatcov_rts.gpr in the current directory, which fails. Directly create a GPR2.Path_Name object instead with no resolution, and let project loading do the resolution. Note that our testing infrastructure does not allow us to install projects in the toolchain prefix, so it is unfortunately not possible to add an automatic regression test for this. TN: V921-005 Change-Id: I1e720177fded95c004fcbaff9bcc5fae23ea8a14
1 parent d523319 commit 6a13686

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

tools/gnatcov/setup_rts.adb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,19 +816,35 @@ package body Setup_RTS is
816816
Result : Setup_Config := Default_Setup_Config;
817817
Setup_Config_File : Virtual_File;
818818

819+
Prj_Ext : constant String := ".gpr";
820+
Prj_Filename : constant String :=
821+
(if not Has_Suffix (Runtime_Project, Prj_Ext)
822+
and then Exists (Runtime_Project & Prj_Ext)
823+
then Runtime_Project & Prj_Ext
824+
else Runtime_Project);
825+
-- Name of the runtime project file to load it with GPR2.
826+
--
827+
-- TODO??? (V921-006) While the call to Prj.Load below is responsible
828+
-- for resolving GPR file base names to full names, it is not able to
829+
-- append the ".gpr" extension when missing, whereas command-line tools
830+
-- are supposed to accept this case. Add ".gpr" ourselves when needed
831+
-- for now, and remove this special case when GPR2 is able to do it
832+
819833
Prj : GPR2.Project.Tree.Object;
820834

821835
Project_File : Virtual_File;
836+
-- Name of the runtime project file after it has been loaded
837+
-- (i.e. resolved file name).
822838
begin
823839
-- Load the runtime project file, only to locate the prefix where it has
824840
-- been installed: do not print any error message, and if the project
825841
-- fails to load, just return the default setup config.
826842

827843
begin
828844
Prj.Load
829-
(Filename => GPR2.Project.Create
830-
(GPR2.Filename_Type (Runtime_Project),
831-
GPR2.Project.Default_Search_Paths (True)),
845+
(Filename => GPR2.Path_Name.Create_File
846+
(GPR2.Filename_Type (Prj_Filename),
847+
GPR2.Path_Name.No_Resolution),
832848
Context => GPR2.Context.Empty,
833849
Config => Create_Config
834850
(Target, RTS, Config_File, Runtime_Project));

0 commit comments

Comments
 (0)