Skip to content

Commit a802de5

Browse files
committed
Merge branch 'topic/revert/mr_501' into 'master'
Revert MR !501 See merge request eng/libadalang/langkit-query-language!503
2 parents d5a37cd + de62c0e commit a802de5

File tree

4 files changed

+30
-48
lines changed

4 files changed

+30
-48
lines changed

lkql_checker/src/gnatcheck-compiler.adb

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,41 +1552,14 @@ package body Gnatcheck.Compiler is
15521552
--------------------------------
15531553

15541554
function Should_Use_Codepeer_Target return Boolean is
1555+
Regular_Gnatls : String_Access := Locate_Exec_On_Path ("gnatls");
15551556
begin
1556-
-- If an explicit toolchain has been provided to the tool (through the
1557-
-- CLI, the project file of the config file), we need to never fallback
1558-
-- to the codepeer target.
1559-
if Gnatcheck_Prj.Tree.Is_Defined
1560-
and then Gnatcheck_Prj.Tree.Has_Explicit_Target
1561-
then
1562-
return
1563-
Ada.Strings.Unbounded."=" (Target, "codepeer")
1564-
or else Ada.Strings.Unbounded."=" (Target, "gnatsas");
1565-
end if;
1566-
15671557
-- If we could find a regular gnatls, it means there is a native
15681558
-- toolchain, that takes precedence over a potential codepeer toolchain.
1569-
declare
1570-
Regular_Gnatls : String_Access := Locate_Exec_On_Path ("gnatls");
1571-
begin
1572-
if Regular_Gnatls /= null then
1573-
Free (Regular_Gnatls);
1574-
return False;
1575-
else
1576-
declare
1577-
Regular_Gprbuild : String_Access :=
1578-
Locate_Exec_On_Path ("gprbuild");
1579-
begin
1580-
-- If we could find a regular "gprbuild", it means there is a
1581-
-- cross toolchain available, thus we don't want to fallback on
1582-
-- the codepeer target
1583-
if Regular_Gprbuild /= null then
1584-
Free (Regular_Gprbuild);
1585-
return False;
1586-
end if;
1587-
end;
1588-
end if;
1589-
end;
1559+
if Regular_Gnatls /= null then
1560+
Free (Regular_Gnatls);
1561+
return False;
1562+
end if;
15901563

15911564
-- If we couldn't, look for a codepeer toolchain.
15921565
declare
@@ -1715,7 +1688,7 @@ package body Gnatcheck.Compiler is
17151688
Args (Num_Args) := new String'("--target=" & To_String (Target));
17161689
elsif Should_Use_Codepeer_Target then
17171690
Num_Args := @ + 1;
1718-
Args (Num_Args) := new String'("--target=gnatsas");
1691+
Args (Num_Args) := new String'("--target=codepeer");
17191692
end if;
17201693
else
17211694
-- Target and runtime will be taken from config project anyway
@@ -1860,12 +1833,9 @@ package body Gnatcheck.Compiler is
18601833
Args (8) := new String'("--restricted-to-languages=ada");
18611834
Num_Args := 8;
18621835

1863-
Num_Args := @ + 1;
18641836
if Should_Use_Codepeer_Target then
1865-
Args (Num_Args) := new String'("--target=gnatsas");
1866-
else
1867-
Args (Num_Args) :=
1868-
new String'("--target=" & Ada.Strings.Unbounded.To_String (Target));
1837+
Num_Args := @ + 1;
1838+
Args (Num_Args) := new String'("--target=codepeer");
18691839
end if;
18701840

18711841
if Arg.Jobs.Get > 1 then

lkql_checker/src/gnatcheck-projects.adb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ package body Gnatcheck.Projects is
536536
use GPR2.Containers;
537537
use Ada.Strings.Unbounded;
538538
begin
539+
-- In case of autoconf, restrict to the Ada language
540+
541+
My_Project.Tree.Restrict_Autoconf_To_Languages
542+
(Language_Id_Set.To_Set (GPR2.Ada_Language));
543+
539544
-- Apply the options
540545

541546
if My_Project.Source_Prj /= null then
@@ -558,22 +563,12 @@ package body Gnatcheck.Projects is
558563

559564
if Target /= Null_Unbounded_String then
560565
Project_Options.Add_Switch (GPR2.Options.Target, To_String (Target));
561-
elsif not Gnatkp_Mode and then Should_Use_Codepeer_Target then
562-
GPR2.KB.Set_Default_Target ("gnatsas");
563566
end if;
564567

565568
if Arg.Follow_Symbolic_Links.Get then
566569
Project_Options.Add_Switch (GPR2.Options.Resolve_Links);
567570
end if;
568571

569-
-- In case of autoconf, restrict to the Ada language
570-
-- We do this just before loading the project because calling this
571-
-- procedure will set the `Tree.Is_Defined` to `True`. For now there is
572-
-- no other ways to know if a project has been loaded or not.
573-
-- (see https://gitlab.adacore-it.com/eng/gpr/gpr-issues/-/issues/627)
574-
My_Project.Tree.Restrict_Autoconf_To_Languages
575-
(Language_Id_Set.To_Set (GPR2.Ada_Language));
576-
577572
if not My_Project.Tree.Load
578573
(Project_Options,
579574
Reporter => Gpr2_Reporter,
@@ -802,6 +797,17 @@ package body Gnatcheck.Projects is
802797
GPR2.Project.Registry.Pack.Check_Attributes (+"Check");
803798
end Register_Tool_Attributes;
804799

800+
------------------------
801+
-- Set_Default_Target --
802+
------------------------
803+
804+
procedure Set_Default_Target is
805+
begin
806+
if not Gnatkp_Mode and then Should_Use_Codepeer_Target then
807+
GPR2.KB.Set_Default_Target ("codepeer");
808+
end if;
809+
end Set_Default_Target;
810+
805811
-------------------------
806812
-- Set_External_Values --
807813
-------------------------

lkql_checker/src/gnatcheck-projects.ads

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ package Gnatcheck.Projects is
324324
-- General project file processing --
325325
-------------------------------------
326326

327+
procedure Set_Default_Target;
328+
-- If codepeer is on PATH, replaces default target with "codepeer",
329+
-- does nothing in gnatkp mode.
330+
327331
procedure Initialize_Environment;
328332
-- Initializes the environment for extracting the information from the
329333
-- project file. This includes setting the parameters specific for the

lkql_checker/src/gnatcheck_main.adb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ begin
462462
end if;
463463
end if;
464464

465+
Gnatcheck.Projects.Set_Default_Target;
466+
465467
-- If we have the project file specified as a tool parameter, analyze it.
466468

467469
Gnatcheck.Projects.Process_Project_File (Gnatcheck_Prj);

0 commit comments

Comments
 (0)