@@ -1547,28 +1547,40 @@ package body Gnatcheck.Compiler is
1547
1547
end if ;
1548
1548
end Restriction_Rule_Parameter ;
1549
1549
1550
- -- --------------------------
1551
- -- Has_Access_To_Codepeer --
1552
- -- --------------------------
1550
+ -- ------------------------------
1551
+ -- Should_Use_Codepeer_Target --
1552
+ -- ------------------------------
1553
1553
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" );
1557
1556
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;
1561
1562
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 ;
1564
1576
1565
1577
-- -----------------
1566
1578
-- GPRbuild_Exec --
1567
1579
-- -----------------
1568
1580
1569
1581
function GPRbuild_Exec return String is
1570
1582
begin
1571
- if Has_Access_To_Codepeer then
1583
+ if Should_Use_Codepeer_Target then
1572
1584
return " codepeer-gprbuild" ;
1573
1585
else
1574
1586
return " gprbuild" ;
@@ -1674,7 +1686,7 @@ package body Gnatcheck.Compiler is
1674
1686
if Target /= Null_Unbounded_String then
1675
1687
Num_Args := @ + 1 ;
1676
1688
Args (Num_Args) := new String'(" --target=" & To_String (Target));
1677
- elsif Has_Access_To_Codepeer then
1689
+ elsif Should_Use_Codepeer_Target then
1678
1690
Num_Args := @ + 1 ;
1679
1691
Args (Num_Args) := new String'(" --target=codepeer" );
1680
1692
end if ;
@@ -1821,7 +1833,7 @@ package body Gnatcheck.Compiler is
1821
1833
Args (8 ) := new String'(" --restricted-to-languages=ada" );
1822
1834
Num_Args := 8 ;
1823
1835
1824
- if Has_Access_To_Codepeer then
1836
+ if Should_Use_Codepeer_Target then
1825
1837
Num_Args := @ + 1 ;
1826
1838
Args (Num_Args) := new String'(" --target=codepeer" );
1827
1839
end if ;
0 commit comments