Skip to content

Commit 7e418f0

Browse files
committed
Rework the usage of the 'Should_Use_Codepeer_Target' function to correctly fallback on the 'codepeer' target
1 parent bc8bf8f commit 7e418f0

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lkql_checker/src/gnatcheck-compiler.adb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,17 +1640,18 @@ package body Gnatcheck.Compiler is
16401640
begin
16411641
return
16421642
Available_Targets.Length = 1
1643-
and then (Available_Targets.Contains ("codepeer")
1644-
or else Available_Targets.Contains ("gnatsas"));
1643+
and then (Available_Targets.Contains ("gnatsas")
1644+
or else Available_Targets.Contains ("codepeer"));
16451645
end Should_Use_Codepeer_Target;
16461646

16471647
-------------------
16481648
-- GPRbuild_Exec --
16491649
-------------------
16501650

16511651
function GPRbuild_Exec return String is
1652+
use Ada.Strings.Unbounded;
16521653
begin
1653-
if Should_Use_Codepeer_Target then
1654+
if Target = "gnatsas" or else Target = "codepeer" then
16541655
return "codepeer-gprbuild";
16551656
else
16561657
return "gprbuild";
@@ -1756,9 +1757,6 @@ package body Gnatcheck.Compiler is
17561757
if Target /= Null_Unbounded_String then
17571758
Num_Args := @ + 1;
17581759
Args (Num_Args) := new String'("--target=" & To_String (Target));
1759-
elsif Should_Use_Codepeer_Target then
1760-
Num_Args := @ + 1;
1761-
Args (Num_Args) := new String'("--target=codepeer");
17621760
end if;
17631761
else
17641762
-- Target and runtime will be taken from config project anyway
@@ -1781,8 +1779,7 @@ package body Gnatcheck.Compiler is
17811779

17821780
for Dir of Arg.Rules_Dirs.Get loop
17831781
Num_Args := @ + 1;
1784-
Args (Num_Args) :=
1785-
new String'("--rules-dir=" & Ada.Strings.Unbounded.To_String (Dir));
1782+
Args (Num_Args) := new String'("--rules-dir=" & To_String (Dir));
17861783
end loop;
17871784

17881785
Num_Args := @ + 1;
@@ -1886,6 +1883,7 @@ package body Gnatcheck.Compiler is
18861883
Args : Argument_List (1 .. 128 + Integer (Last_Source));
18871884
Num_Args : Integer := 0;
18881885

1886+
use Ada.Strings.Unbounded;
18891887
begin
18901888
if GPRbuild = null then
18911889
Error ("cannot locate gprbuild executable");
@@ -1903,9 +1901,9 @@ package body Gnatcheck.Compiler is
19031901
Args (8) := new String'("--restricted-to-languages=ada");
19041902
Num_Args := 8;
19051903

1906-
if Should_Use_Codepeer_Target then
1904+
if Target /= Null_Unbounded_String then
19071905
Num_Args := @ + 1;
1908-
Args (Num_Args) := new String'("--target=codepeer");
1906+
Args (Num_Args) := new String'("--target=" & To_String (Target));
19091907
end if;
19101908

19111909
if Arg.Jobs.Get > 1 then

lkql_checker/src/gnatcheck-projects.adb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ package body Gnatcheck.Projects is
557557
Project_Options.Add_Switch (GPR2.Options.Resolve_Links);
558558
end if;
559559

560+
if Should_Use_Codepeer_Target then
561+
GPR2.KB.Set_Default_Target ("codepeer");
562+
end if;
563+
560564
if not My_Project.Tree.Load
561565
(Project_Options,
562566
Reporter => Gpr2_Reporter,

0 commit comments

Comments
 (0)