Skip to content

Commit ae1af50

Browse files
committed
Merge branch 'topic/gnatcheck/migrate_cli_sections' into 'master'
Migrate CLI sections handling to Opt_Parse Closes #310 See merge request eng/libadalang/langkit-query-language!556
2 parents b3e1867 + 21bbda0 commit ae1af50

File tree

8 files changed

+223
-221
lines changed

8 files changed

+223
-221
lines changed

lkql_checker/src/gnatcheck-compiler.adb

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,13 +1924,23 @@ package body Gnatcheck.Compiler is
19241924
--------------------
19251925

19261926
function Spawn_GPRbuild (Output_File : String) return Process_Id is
1927+
19271928
Pid : Process_Id;
19281929
GPRbuild : String_Access := Locate_Exec_On_Path (GPRbuild_Exec);
19291930
Prj : constant String := Gnatcheck_Prj.Source_Prj;
19301931
Last_Source : constant SF_Id := Last_Argument_Source;
19311932
Args : Argument_List (1 .. 128 + Integer (Last_Source));
19321933
Num_Args : Integer := 0;
19331934

1935+
procedure Add_Arg (Arg : String);
1936+
-- Add an argument to the local argument list ``Args``.
1937+
1938+
procedure Add_Arg (Arg : String) is
1939+
begin
1940+
Num_Args := @ + 1;
1941+
Args (Num_Args) := new String'(Arg);
1942+
end Add_Arg;
1943+
19341944
use Ada.Strings.Unbounded;
19351945
begin
19361946
if GPRbuild = null then
@@ -1950,51 +1960,67 @@ package body Gnatcheck.Compiler is
19501960
Num_Args := 8;
19511961

19521962
if Target /= Null_Unbounded_String then
1953-
Num_Args := @ + 1;
1954-
Args (Num_Args) := new String'("--target=" & To_String (Target));
1963+
Add_Arg ("--target=" & To_String (Target));
19551964
end if;
19561965

19571966
if Arg.Jobs.Get > 1 then
1958-
Num_Args := @ + 1;
1959-
Args (Num_Args) := new String'("-j" & Image (Arg.Jobs.Get));
1967+
Add_Arg ("-j" & Image (Arg.Jobs.Get));
19601968
end if;
19611969

19621970
if Prj /= "" then
1963-
Num_Args := @ + 1;
1964-
Args (Num_Args) := new String'("-P" & Prj);
1971+
Add_Arg ("-P" & Prj);
19651972
end if;
19661973

19671974
if Arg.Follow_Symbolic_Links.Get then
1968-
Num_Args := @ + 1;
1969-
Args (Num_Args) := new String'("-eL");
1975+
Add_Arg ("-eL");
19701976
end if;
19711977

19721978
-- If files are specified explicitly, only compile these files
19731979

19741980
if (Argument_File_Specified and then not Arg.Transitive_Closure.Get)
19751981
or else Arg.Source_Files_Specified
19761982
then
1977-
Num_Args := @ + 1;
1978-
Args (Num_Args) := new String'("-u");
1983+
Add_Arg ("-u");
19791984

19801985
for SF in First_SF_Id .. Last_Source loop
1981-
Num_Args := @ + 1;
1982-
Args (Num_Args) := new String'(Short_Source_Name (SF));
1986+
Add_Arg (Short_Source_Name (SF));
19831987
end loop;
19841988
else
19851989
if Arg.Transitive_Closure.Get then
1986-
Num_Args := @ + 1;
1987-
Args (Num_Args) := new String'("-U");
1990+
Add_Arg ("-U");
19881991
end if;
19891992

19901993
if not Main_Unit.Is_Empty then
19911994
for MU of Main_Unit loop
1992-
Num_Args := @ + 1;
1993-
Args (Num_Args) := new String'(String (MU));
1995+
Add_Arg (String (MU));
19941996
end loop;
19951997
end if;
19961998
end if;
19971999

2000+
-- Append options specified through the "-cargs" section
2001+
for Option of Arg.Cargs_Section.Get loop
2002+
Add_Arg (To_String (Option));
2003+
end loop;
2004+
2005+
if Analyze_Compiler_Output then
2006+
Add_Arg ("-gnatec=" & Gnatcheck_Config_File.all);
2007+
Add_Arg ("-gnatcU");
2008+
Add_Arg ("-gnatwnA.d");
2009+
2010+
if Use_gnatw_Option then
2011+
Add_Arg (Get_Warning_Option);
2012+
end if;
2013+
2014+
Add_Arg ("-gnatyN");
2015+
2016+
if Use_gnaty_Option then
2017+
for S of Split (Get_Style_Option, ' ') loop
2018+
Add_Arg (S);
2019+
end loop;
2020+
end if;
2021+
end if;
2022+
2023+
-- Add scenario variables to the compiler command
19982024
Append_Variables (Args, Num_Args);
19992025

20002026
if Arg.Debug_Mode.Get then
@@ -2004,17 +2030,13 @@ package body Gnatcheck.Compiler is
20042030
Put (" " & Args (J).all);
20052031
end loop;
20062032

2007-
for S of Compiler_Arg_List.all loop
2008-
Put (" " & S.all);
2009-
end loop;
2010-
20112033
New_Line;
20122034
end if;
20132035

20142036
Pid :=
20152037
Non_Blocking_Spawn
20162038
(GPRbuild.all,
2017-
Args (1 .. Num_Args) & Compiler_Arg_List.all,
2039+
Args (1 .. Num_Args),
20182040
Output_File & ".out",
20192041
Output_File);
20202042
Free (GPRbuild);

lkql_checker/src/gnatcheck-diagnoses.adb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,8 +1280,6 @@ package body Gnatcheck.Diagnoses is
12801280

12811281
procedure Print_Active_Rules_File is
12821282
Rule_List_File : Ada.Text_IO.File_Type;
1283-
1284-
use all type GNAT.OS_Lib.String_Access;
12851283
begin
12861284
if Arg.Text_Report_Enabled then
12871285
Report_No_EOL ("coding standard : ");
@@ -1292,13 +1290,15 @@ package body Gnatcheck.Diagnoses is
12921290
("<coding-standard from-file=""", Indent_Level => 1);
12931291
end if;
12941292

1295-
if not Individual_Rules_Set and then Legacy_Rule_File_Name /= null then
1293+
if not Individual_Rules_Set
1294+
and then Legacy_Rule_File_Name /= Null_Unbounded_String
1295+
then
12961296
if Arg.Text_Report_Enabled then
1297-
Report (Legacy_Rule_File_Name.all);
1297+
Report (To_String (Legacy_Rule_File_Name));
12981298
end if;
12991299

13001300
if Arg.XML_Report_Enabled then
1301-
XML_Report (Legacy_Rule_File_Name.all & """>");
1301+
XML_Report (To_String (Legacy_Rule_File_Name) & """>");
13021302
end if;
13031303
else
13041304
-- Creating the list of active rules

0 commit comments

Comments
 (0)