Skip to content

Commit

Permalink
Merge branch 'topic/unified_driver' into 'master'
Browse files Browse the repository at this point in the history
Unified `lkql` driver

See merge request eng/libadalang/langkit-query-language!129
  • Loading branch information
raph-amiard committed Nov 20, 2023
2 parents e1cc9f5 + a4848ed commit 516c429
Show file tree
Hide file tree
Showing 23 changed files with 980 additions and 1,612 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ lkql_jit: lkql

lkql_native_jit: lkql
$(MAVEN) -f lkql/build/java/ install
$(MAVEN) -f lkql_jit/ clean install -P native-all
$(MAVEN) -f lkql_jit/ clean install -P native

.PHONY: lkql_checker

Expand Down
54 changes: 12 additions & 42 deletions lkql_checker/lalcheck/gnatcheck-compiler.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1372,11 +1372,11 @@ package body Gnatcheck.Compiler is
end if;
end Set_Compiler_Checks;

---------------------
-- Spawn_Gnatcheck --
---------------------
----------------------------
-- Spawn_Gnatcheck_Worker --
----------------------------

function Spawn_Gnatcheck
function Spawn_Gnatcheck_Worker
(Rule_File : String;
Msg_File : String;
Source_File : String) return Process_Id
Expand Down Expand Up @@ -1405,9 +1405,6 @@ package body Gnatcheck.Compiler is
end if;
end loop;

Num_Args := @ + 1;
Args (Num_Args) := new String'("--subprocess");

if Prj /= "" then
Num_Args := @ + 1;
Args (Num_Args) := new String'("-P" & Prj);
Expand All @@ -1428,14 +1425,6 @@ package body Gnatcheck.Compiler is
Args (Num_Args) := new String'("-A");
Num_Args := @ + 1;
Args (Num_Args) := new String'(Get_Aggregated_Project);

if XML_Report_ON then
Num_Args := @ + 1;
Args (Num_Args) := new String'("-ox=" & Get_XML_Report_File_Name);
else
Num_Args := @ + 1;
Args (Num_Args) := new String'("-o=" & Get_Report_File_Name);
end if;
end if;

if RTS_Path.all /= "" then
Expand All @@ -1458,48 +1447,29 @@ package body Gnatcheck.Compiler is
Args (Num_Args) := new String'("-eL");
end if;

if No_Object_Dir then
Num_Args := @ + 1;
Args (Num_Args) := new String'("--no_objects_dir");
end if;

for Dir of Additional_Rules_Dirs loop
Num_Args := @ + 1;
Args (Num_Args) := new String'("--rules-dir=" & Dir);
end loop;

if U_Option_Set then
Num_Args := @ + 1;
Args (Num_Args) := new String'("-U");
end if;

if not Main_Unit.Is_Empty then
for MU of Main_Unit loop
Num_Args := @ + 1;
Args (Num_Args) := new String'(String (MU.Name));
end loop;
end if;

Num_Args := @ + 1;
Args (Num_Args) := new String'("-files=" & Source_File);
Args (Num_Args) := new String'("--files-from=" & Source_File);

Append_Variables (Args, Num_Args);

Num_Args := @ + 1;
Args (Num_Args) := new String'("-rules");
Num_Args := @ + 1;
Args (Num_Args) := new String'("-from=" & Rule_File);

if LKQL_Rule_File_Name /= null then
Num_Args := @ + 1;
Args (Num_Args) := new String'("-from-lkql=" &
LKQL_Rule_File_Name.all);
Args (Num_Args) :=
new String'("--rules-from=" & LKQL_Rule_File_Name.all);
else
Num_Args := @ + 1;
Args (Num_Args) := new String'("--rules-from=" & Rule_File);
end if;

if Debug_Mode then
-- For debug purposes, we don't want to put the full path to the
-- worker command, if it is a full path. We just want the base name
Put (Base_Name (Worker_Command));
Put (Base_Name (Worker.all));

for J in 1 .. Num_Args loop
Put (" " & Args (J).all);
Expand All @@ -1518,7 +1488,7 @@ package body Gnatcheck.Compiler is
end loop;

return Pid;
end Spawn_Gnatcheck;
end Spawn_Gnatcheck_Worker;

--------------------
-- Spawn_GPRbuild --
Expand Down
10 changes: 5 additions & 5 deletions lkql_checker/lalcheck/gnatcheck-compiler.ads
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ package Gnatcheck.Compiler is
-- format of restriction rules and places the output into the specified
-- file that is supposed to be an opened out file.

function Spawn_Gnatcheck
function Spawn_Gnatcheck_Worker
(Rule_File : String;
Msg_File : String;
Source_File : String) return Process_Id;
-- Spawn gnatcheck on the main project file with the relevant options
-- on the rules given by Rule_File, redirecting the output to Msg_File.
-- Source_File is the name of a file listing all the source files to
-- analyze.
-- Spawn a gnatcheck worker (LKQL) on the main project file with the
-- relevant options on the rules given by Rule_File, redirecting the
-- output to Msg_File. Source_File is the name of a file listing all the
-- source files to analyze.

function Spawn_GPRbuild (Output_File : String) return Process_Id;
-- Spawn gprbuild on the main project file with the relevant options,
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/lalcheck/gnatcheck-options.ads
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ package Gnatcheck.Options is
-- The name of the environment variable used to define a custom worker
-- executable.

Default_Worker : constant String := "native_gnatcheck_worker";
Default_Worker : constant String := "lkql gnatcheck_worker";
-- The name of the worker executable to use.

Worker_Name : constant String :=
Expand Down
2 changes: 1 addition & 1 deletion lkql_checker/lalcheck/lalcheck.adb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ procedure Lalcheck is
-- -rules -from=rules0.txt -files=files?.txt

Pids (Job) :=
Spawn_Gnatcheck
Spawn_Gnatcheck_Worker
(File_Name ("rules", 0),
File_Name ("out", Job),
File_Name ("files", Job));
Expand Down
Loading

0 comments on commit 516c429

Please sign in to comment.