From 8e1fee43a99c21d34e6e0a1bd7d2aefe8fbd8689 Mon Sep 17 00:00:00 2001 From: Emmanuel Briot Date: Thu, 5 Jun 2014 16:56:41 +0200 Subject: [PATCH] Add support for specifying the name of the driver for gnatbdd --- src/gnatbdd/gnatbdd-codegen.adb | 17 ++++++++++------- src/gnatbdd/gnatbdd-codegen.ads | 1 + src/gnatbdd/gnatbdd-main.adb | 1 + src/gnatbdd/gnatbdd-support.adb | 10 ++++++++++ src/gnatbdd/gnatbdd-support.ads | 1 + 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/gnatbdd/gnatbdd-codegen.adb b/src/gnatbdd/gnatbdd-codegen.adb index ee119c1..09f6167 100644 --- a/src/gnatbdd/gnatbdd-codegen.adb +++ b/src/gnatbdd/gnatbdd-codegen.adb @@ -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; diff --git a/src/gnatbdd/gnatbdd-codegen.ads b/src/gnatbdd/gnatbdd-codegen.ads index 5402892..2556d8c 100644 --- a/src/gnatbdd/gnatbdd-codegen.ads +++ b/src/gnatbdd/gnatbdd-codegen.ads @@ -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. diff --git a/src/gnatbdd/gnatbdd-main.adb b/src/gnatbdd/gnatbdd-main.adb index 8b78ead..5f6e4ef 100644 --- a/src/gnatbdd/gnatbdd-main.adb +++ b/src/gnatbdd/gnatbdd-main.adb @@ -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; diff --git a/src/gnatbdd/gnatbdd-support.adb b/src/gnatbdd/gnatbdd-support.adb index d6341c4..4127eb6 100644 --- a/src/gnatbdd/gnatbdd-support.adb +++ b/src/gnatbdd/gnatbdd-support.adb @@ -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; diff --git a/src/gnatbdd/gnatbdd-support.ads b/src/gnatbdd/gnatbdd-support.ads index bd6ef65..bf32e9d 100644 --- a/src/gnatbdd/gnatbdd-support.ads +++ b/src/gnatbdd/gnatbdd-support.ads @@ -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