Skip to content

Commit 868b1c9

Browse files
raph-amiardthvnx
authored andcommitted
Only use codeper-gprbuild/gcc as fallback
1 parent cd0838b commit 868b1c9

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

lkql_checker/src/gnatcheck-compiler.adb

+26-14
Original file line numberDiff line numberDiff line change
@@ -1547,28 +1547,40 @@ package body Gnatcheck.Compiler is
15471547
end if;
15481548
end Restriction_Rule_Parameter;
15491549

1550-
----------------------------
1551-
-- Has_Access_To_Codepeer --
1552-
----------------------------
1550+
--------------------------------
1551+
-- Should_Use_Codepeer_Target --
1552+
--------------------------------
15531553

1554-
function Has_Access_To_Codepeer return Boolean is
1555-
Gnatls : String_Access := Locate_Exec_On_Path ("codepeer-gnatls");
1556-
Res : Boolean := False;
1554+
function Should_Use_Codepeer_Target return Boolean is
1555+
Regular_Gnatls : String_Access := Locate_Exec_On_Path ("gnatls");
15571556
begin
1558-
if Gnatls /= null then
1559-
Res := True;
1560-
Free (Gnatls);
1557+
-- If we could find a regular gnatls, it means there is a native
1558+
-- toolchain, that takes precedence over a potential codepeer toolchain.
1559+
if Regular_Gnatls /= null then
1560+
Free (Regular_Gnatls);
1561+
return False;
15611562
end if;
1562-
return Res;
1563-
end Has_Access_To_Codepeer;
1563+
1564+
-- If we couldn't, look for a codepeer toolchain.
1565+
declare
1566+
Gnatls : String_Access := Locate_Exec_On_Path ("codepeer-gnatls");
1567+
begin
1568+
if Gnatls /= null then
1569+
Free (Gnatls);
1570+
return True;
1571+
end if;
1572+
end;
1573+
1574+
return False;
1575+
end Should_Use_Codepeer_Target;
15641576

15651577
-------------------
15661578
-- GPRbuild_Exec --
15671579
-------------------
15681580

15691581
function GPRbuild_Exec return String is
15701582
begin
1571-
if Has_Access_To_Codepeer then
1583+
if Should_Use_Codepeer_Target then
15721584
return "codepeer-gprbuild";
15731585
else
15741586
return "gprbuild";
@@ -1674,7 +1686,7 @@ package body Gnatcheck.Compiler is
16741686
if Target /= Null_Unbounded_String then
16751687
Num_Args := @ + 1;
16761688
Args (Num_Args) := new String'("--target=" & To_String (Target));
1677-
elsif Has_Access_To_Codepeer then
1689+
elsif Should_Use_Codepeer_Target then
16781690
Num_Args := @ + 1;
16791691
Args (Num_Args) := new String'("--target=codepeer");
16801692
end if;
@@ -1821,7 +1833,7 @@ package body Gnatcheck.Compiler is
18211833
Args (8) := new String'("--restricted-to-languages=ada");
18221834
Num_Args := 8;
18231835

1824-
if Has_Access_To_Codepeer then
1836+
if Should_Use_Codepeer_Target then
18251837
Num_Args := @ + 1;
18261838
Args (Num_Args) := new String'("--target=codepeer");
18271839
end if;

lkql_checker/src/gnatcheck-compiler.ads

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ package Gnatcheck.Compiler is
1818
-- Runtime helpers --
1919
---------------------
2020

21-
function Has_Access_To_Codepeer return Boolean;
22-
-- Returns whether the current gnatcheck process can access to the codepeer
21+
function Should_Use_Codepeer_Target return Boolean;
22+
-- Returns whether the current gnatcheck process should use the codepeer
2323
-- tools. This function tests if the `codepeer-gnatls` executable can be
24-
-- accessed.
24+
-- accessed when no other regular toolchain can be found.
2525

2626
function GPRbuild_Exec return String;
2727
-- Return the executable name to use in order to spawn a GPRBuild process

lkql_checker/src/gnatcheck-projects.adb

+1-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ package body Gnatcheck.Projects is
804804

805805
procedure Set_Default_Target is
806806
begin
807-
if not Gnatkp_Mode and then Has_Access_To_Codepeer then
807+
if not Gnatkp_Mode and then Should_Use_Codepeer_Target then
808808
GPR2.KB.Set_Default_Target ("codepeer");
809809
end if;
810810
end Set_Default_Target;

0 commit comments

Comments
 (0)