matreshka_league_21.0.0_0c8f4d47/tools/configure/configure-driver.adb

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
------------------------------------------------------------------------------
--                                                                          --
--                            Matreshka Project                             --
--                                                                          --
--         Localization, Internationalization, Globalization for Ada        --
--                                                                          --
--                              Tools Component                             --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2010-2017, Vadim Godunko <vgodunko@gmail.com>                --
-- All rights reserved.                                                     --
--                                                                          --
-- Redistribution and use in source and binary forms, with or without       --
-- modification, are permitted provided that the following conditions       --
-- are met:                                                                 --
--                                                                          --
--  * Redistributions of source code must retain the above copyright        --
--    notice, this list of conditions and the following disclaimer.         --
--                                                                          --
--  * Redistributions in binary form must reproduce the above copyright     --
--    notice, this list of conditions and the following disclaimer in the   --
--    documentation and/or other materials provided with the distribution.  --
--                                                                          --
--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
--    contributors may be used to endorse or promote products derived from  --
--    this software without specific prior written permission.              --
--                                                                          --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 5734 $ $Date: 2017-01-28 15:59:47 +0300 (Сб, 28 янв 2017) $
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Directories;
with Ada.Strings.Unbounded.Text_IO;
with Ada.Text_IO;

with Configure.Architecture;
with Configure.Instantiate;
with Configure.Internals;
with Configure.RTL_Version;
with Configure.Tests.Asis;
with Configure.Tests.AWS;
with Configure.Tests.Modules.AMF;
with Configure.Tests.Gprbuild;
with Configure.Tests.Install;
with Configure.Tests.Installation_Directories;
with Configure.Tests.MySQL;
with Configure.Tests.OCI;
with Configure.Tests.Operating_System;
with Configure.Tests.PostgreSQL;
with Configure.Tests.SQLite3;
with Configure.Tests.Firebird;
with Configure.Tests.Valgrind;
with Configure.Version;

procedure Configure.Driver is
   use Ada.Command_Line;

   function Is_Help_Requested return Boolean;
   --  Returns True when help information is requested by the user.

   procedure Help_Output (Position : Unbounded_String_Vectors.Cursor);
   --  Outputs line of help information.

   -----------------
   -- Help_Output --
   -----------------

   procedure Help_Output (Position : Unbounded_String_Vectors.Cursor) is
      Line : constant Unbounded_String
        := Unbounded_String_Vectors.Element (Position);

   begin
      Ada.Strings.Unbounded.Text_IO.Put_Line (Line);
   end Help_Output;

   -----------------------
   -- Is_Help_Requested --
   -----------------------

   function Is_Help_Requested return Boolean is
   begin
      for J in 1 .. Argument_Count loop
         if Argument (J) = "--help" then
            return True;
         end if;
      end loop;

      return False;
   end Is_Help_Requested;

   Arguments       : Unbounded_String_Vector;
   Operating_System_Test : aliased
     Configure.Tests.Operating_System.Operating_System_Test;
   Dirs_Test       :
     Configure.Tests.Installation_Directories.Installation_Directories_Test;
   Gprbuild_Test   : Configure.Tests.Gprbuild.Gprbuild_Test;
   Install_Test    : Configure.Tests.Install.Install_Test;
   Asis_Test       : Configure.Tests.Asis.Asis_Test;
   AWS_Test        : Configure.Tests.AWS.AWS_Test;
   AMF_Test        :
     Configure.Tests.Modules.AMF.AMF_Test (Operating_System_Test'Access);
   MySQL_Test      : Configure.Tests.MySQL.MySQL_Test;
   OCI_Test        :
     Configure.Tests.OCI.OCI_Test (Operating_System_Test'Access);
   PostgreSQL_Test : Configure.Tests.PostgreSQL.PostgreSQL_Test;
   SQLite3_Test    :
     Configure.Tests.SQLite3.SQLite3_Test (Operating_System_Test'Access);
   Firebird_Test   : Configure.Tests.Firebird.Firebird_Test;
   Valgrind_Test   : Configure.Tests.Valgrind.Valgrind_Test;

begin
   if Is_Help_Requested then
      Ada.Text_IO.Put_Line
       ("`"
          & Ada.Directories.Simple_Name (Command_Name)
          & "' configures Matreshka to adapt to many kinds of systems.");
      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Usage: " & Command_Name & " [OPTION]...");
      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line
       ("Defaults for the options are specified in brackets.");
      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Configuration:");
      Ada.Text_IO.Put_Line
       ("  --help                  display this help and exit");

      Ada.Text_IO.New_Line;
      Dirs_Test.Help.Iterate (Help_Output'Access);

      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Modules:");

      AMF_Test.Help.Iterate (Help_Output'Access);

      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Optional Packages:");

      OCI_Test.Help.Iterate (Help_Output'Access);
      PostgreSQL_Test.Help.Iterate (Help_Output'Access);
      SQLite3_Test.Help.Iterate (Help_Output'Access);
      Firebird_Test.Help.Iterate (Help_Output'Access);

      return;
   end if;

   --  Create log file.

   Configure.Internals.Create_Log_File;

   --  Convert command line arguments into the vector.

   for J in 1 .. Ada.Command_Line.Argument_Count loop
      Arguments.Append (+Ada.Command_Line.Argument (J));
   end loop;

   Configure.Version;
   Configure.Architecture;
   Operating_System_Test.Execute (Arguments);
   Configure.RTL_Version;
   Dirs_Test.Execute (Arguments);
   Install_Test.Execute (Arguments);
   Gprbuild_Test.Execute (Arguments);
   Asis_Test.Execute (Arguments);
   AWS_Test.Execute (Arguments);
   AMF_Test.Execute (Arguments);
   MySQL_Test.Execute (Arguments);
   OCI_Test.Execute (Arguments);
   PostgreSQL_Test.Execute (Arguments);
   SQLite3_Test.Execute (Arguments);
   Firebird_Test.Execute (Arguments);
   Valgrind_Test.Execute (Arguments);

   declare
      use Ada.Directories;
      use Ada.Strings.Unbounded.Text_IO;
      use Ada.Text_IO;
      use Maps;

      P : Cursor := Substitutions.First;

   begin
      while Has_Element (P) loop
         Put (Simple_Name (Command_Name));
         Put (": ");
         Put (Key (P));
         Put (" => ");
         Put (Element (P));
         New_Line;

         Next (P);
      end loop;
   end;

   --  Check whether all arguments in the command line are recognized and
   --  removed.

   if not Arguments.Is_Empty then
      declare
         procedure Output (Position : Unbounded_String_Vectors.Cursor);

         ------------
         -- Output --
         ------------

         procedure Output (Position : Unbounded_String_Vectors.Cursor) is
            Arg : constant Unbounded_String
              := Unbounded_String_Vectors.Element (Position);

         begin
            Warning
             ("command line argument '" & (+Arg) & "' is not recognized");
         end Output;

      begin
         Arguments.Iterate (Output'Access);
      end;
   end if;

   Configure.Instantiate ("Makefile.config");
   Configure.Instantiate ("gnat/install/matreshka_config.gpr");
   Configure.Instantiate ("gnat/matreshka_config.gpr");
   Configure.Instantiate ("source/league/matreshka-config.ads");

   --  Close log file.

   Configure.Internals.Close_Log_File;

exception
   when Internal_Error =>
      Set_Exit_Status (Failure);
end Configure.Driver;