@@ -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 ;
0 commit comments