Skip to content

Commit 8d6e084

Browse files
committed
Merge branch 'mr/thevenoux/gnatcheck#2' into 'master'
Make gnatcheck and gnatkp separate binaries Closes eng/codepeer/gnatcheck#2 See merge request eng/libadalang/langkit-query-language!594
2 parents 76c2e0e + a701ebb commit 8d6e084

16 files changed

+795
-708
lines changed

lkql_checker/lkql_checker.gpr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ project LKQL_Checker is
1010
for Source_Dirs use ("src");
1111
for Object_Dir use "obj/" & Build_Mode;
1212
for Exec_Dir use "bin";
13-
for Main use ("main.adb");
13+
for Main use ("gnatcheck.adb", "gnatkp.adb");
1414

1515
package Binder is
1616
case Build_Mode is
@@ -22,7 +22,6 @@ project LKQL_Checker is
2222
end Binder;
2323

2424
package Builder is
25-
for Executable ("main.adb") use "gnatcheck";
2625
for Switches ("Ada") use ("-j0");
2726
end Builder;
2827

lkql_checker/src/gnatcheck.adb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
with Lkql_Checker; use Lkql_Checker;
7+
8+
procedure Gnatcheck is
9+
begin
10+
Main (Gnatcheck_Mode);
11+
end Gnatcheck;

lkql_checker/src/gnatcheck.ads

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
procedure Gnatcheck;

lkql_checker/src/gnatkp.adb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
with Lkql_Checker; use Lkql_Checker;
7+
8+
procedure Gnatkp is
9+
begin
10+
Main (Gnatkp_Mode);
11+
end Gnatkp;

lkql_checker/src/gnatkp.ads

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
procedure Gnatkp;

lkql_checker/src/lkql_checker-diagnoses.adb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ package body Lkql_Checker.Diagnoses is
16951695

16961696
procedure Print_Out_Diagnoses is
16971697
Max_Diagnoses : constant Natural :=
1698-
(if Gnatkp_Mode then 0 else Arg.Max_Diagnoses.Get);
1698+
(if Mode = Gnatkp_Mode then 0 else Arg.Max_Diagnoses.Get);
16991699
Diagnoses_Reported : Natural := 0;
17001700
Limit_Exceeded : Boolean := False;
17011701

@@ -1798,7 +1798,7 @@ package body Lkql_Checker.Diagnoses is
17981798

17991799
Report (Trim (Minute_Of_Check'Img, Left));
18001800

1801-
Report (Executable & " version : " & Version_String);
1801+
Report (Lkql_Checker_Mode_Image & " version : " & Version_String);
18021802

18031803
Report_No_EOL ("command line : ");
18041804
Print_Command_Line;
@@ -1922,8 +1922,7 @@ package body Lkql_Checker.Diagnoses is
19221922
is
19231923
Pragma_Name : constant Text_Type := To_Lower (El.F_Id.Text);
19241924
Pragma_Args : constant LAL.Analysis.Base_Assoc_List := El.F_Args;
1925-
Tool_Name : constant Text_Type :=
1926-
(if Gnatkp_Mode then "gnatkp" else "gnatcheck");
1925+
Tool_Name : constant Text_Type := To_Text (Lkql_Checker_Mode_Image);
19271926
begin
19281927
return
19291928
Pragma_Name in "annotate" | "gnat_annotate"
@@ -2270,7 +2269,7 @@ package body Lkql_Checker.Diagnoses is
22702269
return;
22712270
end if;
22722271

2273-
if Gnatkp_Mode then
2272+
if Mode = Gnatkp_Mode then
22742273
Match (Match_Kp_Exempt_Comment, Text, Matches);
22752274
else
22762275
Match (Match_Rule_Exempt_Comment, Text, Matches);

lkql_checker/src/lkql_checker-options.adb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
with GNAT.Command_Line; use GNAT.Command_Line;
2+
with Ada.Command_Line; use Ada.Command_Line;
3+
with Ada.Directories; use Ada.Directories;
24

35
with Lkql_Checker.Output; use Lkql_Checker.Output;
46
with Lkql_Checker.Projects; use Lkql_Checker.Projects;

lkql_checker/src/lkql_checker-options.ads

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
-- This package defines options that are supposed to be of a common interest
77
-- for all the tools.
88

9-
with Ada.Command_Line; use Ada.Command_Line;
10-
with Ada.Directories; use Ada.Directories;
119
with Ada.Environment_Variables;
1210
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
1311

@@ -33,9 +31,6 @@ package Lkql_Checker.Options is
3331
Version_String : constant String :=
3432
Lkql_Checker_Version & " (" & Date & ")";
3533

36-
Executable : constant String := Base_Name (Command_Name);
37-
-- Name of the current executable (e.g. "gnatcheck" or "gnatkp")
38-
3934
Custom_Worker_Var : constant String := "GNATCHECK_WORKER";
4035
-- The name of the environment variable used to define a custom worker
4136
-- executable.
@@ -69,11 +64,6 @@ package Lkql_Checker.Options is
6964
-- tool (includes both wrong parameters and wrong combinations of correct
7065
-- parameters).
7166

72-
Gnatkp_Mode : Boolean := Executable = "gnatkp";
73-
-- Whether we are running in KP detection mode
74-
-- Set either when the executable is called gnatkp or with the debug switch
75-
-- '-dkp'
76-
7767
Legacy : Boolean := False;
7868
-- If True, run in legacy mode, with no support for additional rule files.
7969

@@ -679,7 +669,7 @@ package Lkql_Checker.Options is
679669
function XML_Report_File_Path return String;
680670

681671
function Ignore_Project_Switches return Boolean
682-
is (Ignore_Project_Switches_Opt.Get or Gnatkp_Mode);
672+
is (Ignore_Project_Switches_Opt.Get or Mode = Gnatkp_Mode);
683673

684674
function Source_Files_Specified return Boolean
685675
is (Source_Files.Get /= Null_Unbounded_String);
@@ -706,10 +696,12 @@ package Lkql_Checker.Options is
706696
-- the specified ``Default_Name``.
707697

708698
function Text_Report_File_Path return String
709-
is (Resolve_Report_File (Text_Output.Get, Executable & ".out"));
699+
is (Resolve_Report_File
700+
(Text_Output.Get, Lkql_Checker_Mode_Image & ".out"));
710701

711702
function XML_Report_File_Path return String
712-
is (Resolve_Report_File (XML_Output.Get, Executable & ".xml"));
703+
is (Resolve_Report_File
704+
(XML_Output.Get, Lkql_Checker_Mode_Image & ".xml"));
713705
end Arg;
714706

715707
--------------------------

lkql_checker/src/lkql_checker-output.adb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ package body Lkql_Checker.Output is
126126
Log_Message : Boolean := False)
127127
is
128128
Final_Message : constant String :=
129-
(if Tool_Name then Executable & ": " else "")
129+
(if Tool_Name then Lkql_Checker_Mode_Image & ": " else "")
130130
& (if Location /= "" then Location & ": " else "")
131131
& (case Tag is
132132
when Info => "info: ",
@@ -255,7 +255,7 @@ package body Lkql_Checker.Output is
255255

256256
procedure Print_Version_Info is
257257
begin
258-
Print (Executable & " " & Version_String);
258+
Print (Lkql_Checker_Mode_Image & " " & Version_String);
259259
Print
260260
("Copyright (C) " & "2004" & '-' & Current_Year & ", AdaCore.",
261261
Log_Message => False);
@@ -363,7 +363,8 @@ package body Lkql_Checker.Output is
363363
begin
364364
if Log_File_Name = null then
365365
Log_File_Name :=
366-
new String'(Global_Report_Dir.all & Executable & ".log");
366+
new String'
367+
(Global_Report_Dir.all & Lkql_Checker_Mode_Image & ".log");
367368
end if;
368369

369370
Open_Or_Create (Log_File_Name.all, Out_File, Log_File);
@@ -432,7 +433,7 @@ package body Lkql_Checker.Output is
432433
begin
433434
pragma Style_Checks ("M200"); -- Allow long lines
434435

435-
if Gnatkp_Mode then
436+
if Mode = Gnatkp_Mode then
436437
Put_Line ("gnatkp: the GNAT known problem detector");
437438
Put_Line
438439
("usage: gnatkp -Pproject [options] [-rules [-from=file] {+Rkp_id[:param]}]");

lkql_checker/src/lkql_checker-output.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package Lkql_Checker.Output is
1616
procedure Print_Version_Info;
1717
-- Prints into Stderr the tool version information in the following format:
1818
--
19-
-- (gnatcheck|gnatkp) <version> (<date>)
19+
-- <tool> <version> (<date>)
2020
-- Copyright (C) 2004-<current year>, AdaCore.
2121

2222
procedure Report_Unhandled_Exception (Ex : Exception_Occurrence);

0 commit comments

Comments
 (0)