Add support for specifying the name of the driver for gnatbdd

This commit is contained in:
Emmanuel Briot 2014-06-05 16:56:41 +02:00
parent de179bcbdd
commit 8e1fee43a9
5 changed files with 23 additions and 7 deletions

View File

@ -481,6 +481,7 @@ package body Gnatbdd.Codegen is
Extension : Filesystem_String := ".ads";
Object_Dir : GNATCOLL.VFS.Virtual_File;
Tree : GNATCOLL.Projects.Project_Tree;
Driver : String;
Extra_Steps_Dirs : GNATCOLL.VFS.File_Array_Access)
is
Files : File_Array_Access;
@ -520,7 +521,8 @@ package body Gnatbdd.Codegen is
end if;
Create (F, Out_File,
Create_From_Dir (Object_Dir, "driver.adb").Display_Full_Name);
Create_From_Dir
(Object_Dir, +Driver & ".adb").Display_Full_Name);
Put_Line (F, "-- Automatically generated");
Put_Line (F, "with BDD; use BDD;");
Put_Line (F, "with BDD.Main; use BDD.Main;");
@ -528,7 +530,7 @@ package body Gnatbdd.Codegen is
Put_Line (F, "with BDD.Runner; use BDD.Runner;");
Put_Line (F, "with GNAT.Regpat; use GNAT.Regpat;");
Put_Line (F, To_String (Data.Withs));
Put_Line (F, "procedure Driver is");
Put_Line (F, "procedure " & Driver & " is");
New_Line (F);
Put_Line (F, To_String (Data.Regexps));
Put_Line (F, " procedure Run_Steps");
@ -559,18 +561,19 @@ package body Gnatbdd.Codegen is
Put_Line
(F, " Runner.Add_Step_Runner (Run_Steps'Unrestricted_Access);");
Put_Line (F, " BDD.Main.Main (Runner);");
Put_Line (F, "end Driver;");
Put_Line (F, "end " & Driver & ";");
Close (F);
Create (F, Out_File,
Create_From_Dir (Object_Dir, "driver.gpr").Display_Full_Name);
Create_From_Dir
(Object_Dir, +Driver & ".gpr").Display_Full_Name);
Put_Line (F, "with ""gnatcoll"";");
Put_Line (F, "with ""gnatbdd"";");
Put_Line (F, "with """
& Tree.Root_Project.Project_Path.Display_Full_Name
& """;");
Put_Line (F, "project Driver is");
Put_Line (F, " for Main use (""driver.adb"");");
Put_Line (F, "project " & Driver & " is");
Put_Line (F, " for Main use (""" & Driver & ".adb"");");
Put (F, " for Source_Dirs use ("".""");
if Extra_Steps_Dirs /= null then
@ -589,7 +592,7 @@ package body Gnatbdd.Codegen is
Put_Line (F, " package Compiler is");
Put_Line (F, " for Switches (""Ada"") use (""-g"");");
Put_Line (F, " end Compiler;");
Put_Line (F, "end Driver;");
Put_Line (F, "end " & Driver & ";");
Close (F);
end Discover_Steps;

View File

@ -38,6 +38,7 @@ package Gnatbdd.Codegen is
Extension : Filesystem_String := ".ads";
Object_Dir : GNATCOLL.VFS.Virtual_File;
Tree : GNATCOLL.Projects.Project_Tree;
Driver : String;
Extra_Steps_Dirs : GNATCOLL.VFS.File_Array_Access);
-- Parse all specs in the project's source directories or in
-- Extra_Steps_Dirs, to find the definition of steps.

View File

@ -79,6 +79,7 @@ begin
Extension => +Ads_Extension,
Object_Dir => Tree.Root_Project.Object_Dir,
Tree => Tree,
Driver => Setup.Driver.all,
Extra_Steps_Dirs => Setup.Steps_Dirs);
end;

View File

@ -68,6 +68,12 @@ package body Gnatbdd.Support is
Long_Switch => "--steps=",
Argument => "DIR",
Help => "Specify a directory to search for step definitions");
Define_Switch
(Config,
Long_Switch => "--driver=",
Argument => "NAME",
Help => "Name of the generated driver");
end Setup_Command_Line_Switches;
------------------------
@ -105,6 +111,10 @@ package body Gnatbdd.Support is
Error ("Project file not found");
end if;
end if;
elsif Switch = "--driver" then
Free (Result.Driver);
Result.Driver := new String'(Parameter);
end if;
end On_Switch;

View File

@ -35,6 +35,7 @@ package Gnatbdd.Support is
type Configuration is record
Project_Name : GNATCOLL.VFS.Virtual_File;
Steps_Dirs : GNATCOLL.VFS.File_Array_Access;
Driver : GNAT.Strings.String_Access := new String'("driver");
end record;
-- Various configurations from the command line