Skip to content

Commit

Permalink
Merge branch 'topic/1349' into 'master'
Browse files Browse the repository at this point in the history
gnat_compare: use GNATCOLL.OS.Process.Run to spawn processes

Closes #1349

See merge request eng/libadalang/libadalang!1607
  • Loading branch information
thvnx committed Apr 11, 2024
2 parents ea03d6b + f1b1c44 commit c860961
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
56 changes: 18 additions & 38 deletions testsuite/ada/gnat_compare/gnat_compare.adb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;

with GNAT.OS_Lib; use GNAT.OS_Lib;

with GNATCOLL.Opt_Parse;
with GNATCOLL.Projects; use GNATCOLL.Projects;
with GNATCOLL.VFS; use GNATCOLL.VFS;
with GNATCOLL.OS;
with GNATCOLL.OS.Process; use GNATCOLL.OS.Process;
with GNATCOLL.Projects; use GNATCOLL.Projects;
with GNATCOLL.VFS; use GNATCOLL.VFS;

with Langkit_Support.Slocs; use Langkit_Support.Slocs;
with Libadalang.Analysis; use Libadalang.Analysis;
Expand Down Expand Up @@ -292,32 +292,22 @@ procedure GNAT_Compare is
------------------

procedure Run_GPRbuild (Project_File : String) is
Path : GNAT.OS_Lib.String_Access := Locate_Exec_On_Path ("gprbuild");
Args : String_Vectors.Vector;
Success : Boolean;
Args : GNATCOLL.OS.Process.Argument_List;
Success : Integer;
begin
if Path = null then
Put_Line ("Could not locate gprbuild on the PATH");
end if;

Args.Append ("gprbuild");
Args.Append (+"-c");
Args.Append (+"-q");
Args.Append (+"-p");
Args.Append (+"-P" & Project_File);
for V of App.Args.Scenario_Vars.Get loop
Args.Append ("-X" & V);
Args.Append ("-X" & To_String (V));
end loop;

declare
Spawn_Args : String_List_Access :=
new String_List'(To_String_List (Args));
begin
Spawn (Path.all, Spawn_Args.all, Success);
Free (Spawn_Args);
Free (Path);
end;
Success := GNATCOLL.OS.Process.Run
(Args, "", FS.Standin, FS.Standerr, FS.Null_FD, INHERIT);

if not Success then
if Success /= 0 then
Abort_App ("Could not spawn gprbuild");
end if;
end Run_GPRbuild;
Expand All @@ -327,31 +317,21 @@ procedure GNAT_Compare is
------------------

procedure Run_GPRclean (Project_File : String) is
Path : GNAT.OS_Lib.String_Access := Locate_Exec_On_Path ("gprclean");
Args : String_Vectors.Vector;
Success : Boolean;
Args : GNATCOLL.OS.Process.Argument_List;
Success : Integer;
begin
if Path = null then
Put_Line ("Could not locate gprclean on the PATH");
end if;

Args.Append ("gprclean");
Args.Append (+"-q");
Args.Append (+"-r");
Args.Append (+"-P" & Project_File);
for V of App.Args.Scenario_Vars.Get loop
Args.Append ("-X" & V);
Args.Append ("-X" & To_String (V));
end loop;

declare
Spawn_Args : String_List_Access :=
new String_List'(To_String_List (Args));
begin
Spawn (Path.all, Spawn_Args.all, Success);
Free (Spawn_Args);
Free (Path);
end;
Success := GNATCOLL.OS.Process.Run
(Args, "", FS.Standin, FS.Standerr, FS.Null_FD, INHERIT);

if not Success then
if Success /= 0 then
Abort_App ("Could not spawn gprclean");
end if;
end Run_GPRclean;
Expand Down
1 change: 0 additions & 1 deletion testsuite/tests/name_resolution/gnat_xref_1/test.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
test.adb:1:11: warning: file name does not match unit name, should be "p.adb" [enabled by default]
== test.adb ==
test.adb:1:11 => test.adb:1:11 (LAL: ok)
test.adb:4:5 => test.adb:1:11 (LAL: ok)
Expand Down

0 comments on commit c860961

Please sign in to comment.