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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
------------------------------------------------------------------------------
-- --
-- GNATELIM COMPONENTS --
-- --
-- G N A T E L I M . P R O J E C T S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2013-2018, AdaCore --
-- --
-- GNATELIM is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3 or (at your option) any later --
-- version. GNATELIM is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABI- --
-- LITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Li- --
-- cense for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING3. If not, --
-- go to http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- The original version of Gnatelim was developed by Alain Le Guennec --
-- It is now maintained by AdaCore (http://www.adacore.com) --
-- --
------------------------------------------------------------------------------
with System.Multiprocessors;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with ASIS_UL.Common; use ASIS_UL.Common;
with ASIS_UL.Compiler_Options; use ASIS_UL.Compiler_Options;
with ASIS_UL.Debug; use ASIS_UL.Debug;
with ASIS_UL.Environment; use ASIS_UL.Environment;
with ASIS_UL.Options; use ASIS_UL.Options;
with ASIS_UL.Output; use ASIS_UL.Output;
with ASIS_UL.Source_Table; use ASIS_UL.Source_Table;
with Gnatelim.Output;
with Gnatelim.Options;
package body Gnatelim.Projects is
----------------------
-- Print_Tool_Usage --
----------------------
overriding procedure Print_Tool_Usage (My_Project : Gnatelim_Project_Type)
is
pragma Unreferenced (My_Project);
begin
Gnatelim.Output.Print_Gnatelim_Usage;
end Print_Tool_Usage;
--------------------
-- Scan_Arguments --
--------------------
overriding procedure Scan_Arguments
(My_Project : in out Gnatelim_Project_Type;
First_Pass : Boolean := False;
Parser : Opt_Parser := Command_Line_Parser;
In_Switches : Boolean := False)
is
In_Project_File : constant Boolean := Parser /= Command_Line_Parser;
begin
loop
case GNAT.Command_Line.Getopt
(
"P: U X! eL " & -- project-specific options
"-RTS= " &
"-target= " &
"t v q " &
"j! " &
"log? " & -- Specifying the log file
"wq ws wn wf " & -- Warning message control
"o= " & -- Specify the output file
"files= " & -- Specifies a set of files
-- to process
"main= " & -- specifies the main subprogram
"-version -help " & -- print version and usage
"-no-elim-dispatch " & -- Turns OFF elimination of
-- dispatching operations,
-- Non-documented options:
"d? " & -- debug mode/options
"a " & -- Process RTL components, no effect
-- at the moment
"-ignore= " & -- specifies a set of units not to
-- generate pragmas for
"-elim-dispatching " & -- Turns ON elimination of
-- dispatching operations, does nothing for now, elimination
-- of dispatching operations is ON by default
"-old-pragma-format " & -- Generate UNIT_NAME pragma
-- Parameter (Parser => Parser)
-- obsolete features, for backward compatibility
"b: I: C: -GCC=: -GNATMAKE= m",
Parser => Parser)
is
when ASCII.NUL =>
exit when not
More_Arguments
(Store_Arguments => In_Project_File or else First_Pass,
In_Switches => In_Switches);
when 'a' =>
if not First_Pass then
Process_RTL_Units := True;
end if;
when 'b' =>
null; -- obsolete features, for backward compatibility
when 'C' =>
-- In old gnatelim this switch has been used to specify a
-- configuration file, so:
if not First_Pass then
Store_GNAT_Option_With_Path
("gnatec", Parameter (Parser => Parser));
end if;
when 'd' =>
if not First_Pass then
if Full_Switch (Parser => Parser) = "d" then
Set_Debug_Options (Parameter (Parser => Parser));
end if;
end if;
when 'e' =>
if Full_Switch (Parser => Parser) = "eL" then
if First_Pass then
ASIS_UL.Projects.Follow_Symbolic_Links := True;
elsif In_Project_File then
Error ("-eL option cannot be set in a project file");
raise Parameter_Error;
end if;
end if;
when 'f' =>
if Full_Switch (Parser => Parser) = "files" then
if First_Pass then
Read_Args_From_File (Parameter);
elsif In_Project_File then
if In_Switches then
Error ("-files option is not allowed " &
"for Switches attribute");
raise Parameter_Error;
else
Read_Args_From_File (Parameter (Parser => Parser));
end if;
end if;
end if;
when 'j' =>
if not First_Pass then
begin
J_Specified := True;
ASIS_UL.Options.Process_Num :=
Natural'Value (Parameter (Parser => Parser));
if ASIS_UL.Options.Process_Num = 0 then
ASIS_UL.Options.Process_Num :=
Positive (System.Multiprocessors.Number_Of_CPUs);
end if;
exception
when Constraint_Error =>
Error ("Wrong Parameter of '-j' option: " &
Parameter (Parser => Parser));
raise Parameter_Error;
end;
end if;
when 'I' =>
if not First_Pass then
Store_I_Option (Parameter (Parser => Parser));
end if;
when 'l' =>
if not First_Pass then
if Full_Switch (Parser => Parser) = "log" then
Log_Mode := True;
Set_Log_File_Name (Parameter (Parser => Parser));
end if;
end if;
when 'm' =>
if not First_Pass then
if Full_Switch (Parser => Parser) = "main" then
Free (ASIS_UL.Options.Main_Subprogram_Name);
ASIS_UL.Options.Main_Subprogram_Name :=
new String'(Parameter (Parser => Parser));
-- elsif Full_Switch (Parser => Parser) = "m" then
-- null; -- Obsolete switch, for backwards compatibility
end if;
end if;
when 'o' =>
if not First_Pass then
if Full_Switch (Parser => Parser) = "o" then
Set_Pipe_Mode (False);
Set_Report_File_Name (Parameter (Parser => Parser));
end if;
end if;
when 'P' =>
if Full_Switch (Parser => Parser) = "P" then
if First_Pass then
My_Project.Store_Project_Source (Parameter);
elsif In_Project_File then
Error ("project file should not be specified inside " &
"another project file");
raise Parameter_Error;
end if;
end if;
when 'q' =>
if not First_Pass then
Quiet_Mode := True;
end if;
when 't' =>
if not First_Pass then
if Full_Switch (Parser => Parser) = "t" then
Compute_Timing := True;
end if;
end if;
when 'v' =>
if not First_Pass then
Verbose_Mode := True;
end if;
when 'w' =>
if not First_Pass then
if Full_Switch (Parser => Parser) = "wq" then
Warning_Mode := Quiet;
elsif Full_Switch (Parser => Parser) = "ws" then
Warning_Mode := Short;
elsif Full_Switch (Parser => Parser) = "wn" then
Warning_Mode := Normal;
elsif Full_Switch (Parser => Parser) = "wf" then
Warning_Mode := Full;
end if;
end if;
when 'U' =>
if Full_Switch (Parser => Parser) = "U" then
if First_Pass then
if ASIS_UL.Projects.U_Option_Set then
Error ("-U can be specified only once");
raise Parameter_Error;
end if;
ASIS_UL.Projects.U_Option_Set := True;
elsif In_Project_File then
Error ("-U option is not allowed in a project file");
raise Parameter_Error;
end if;
end if;
when 'X' =>
if Full_Switch (Parser => Parser) = "X" then
if First_Pass then
ASIS_UL.Projects.Store_External_Variable
(Var => Parameter);
elsif In_Project_File then
Error ("external references cannot be set in " &
"a project file");
raise Parameter_Error;
end if;
end if;
when '-' =>
if Full_Switch (Parser => Parser) = "-help" then
if In_Project_File then
Error ("project file should not contain '--help' option");
raise Parameter_Error;
end if;
Print_Usage := True;
return;
elsif Full_Switch (Parser => Parser) = "-version" then
if In_Project_File then
Error
("project file should not contain '--version' option");
raise Parameter_Error;
end if;
Print_Version := True;
return;
end if;
if not First_Pass then
if Full_Switch (Parser => Parser) = "-GCC" then
null; -- obsolete features, for backward compatibility
elsif Full_Switch (Parser => Parser) = "-GNATMAKE" then
null; -- obsolete features, for backward compatibility
elsif Full_Switch (Parser => Parser) =
"-elim-dispatching"
then
Gnatelim.Options.Eliminate_Dispatching_Operations := True;
elsif Full_Switch (Parser => Parser) =
"-no-elim-dispatch"
then
Gnatelim.Options.Eliminate_Dispatching_Operations :=
False;
elsif Full_Switch (Parser => Parser) = "-ignore" then
if Is_Regular_File (Parameter (Parser => Parser)) then
ASIS_UL.Options.Exempted_Units :=
new String'(Normalize_Pathname
(Parameter (Parser => Parser)));
else
Error (Parameter (Parser => Parser) & " not found");
raise Parameter_Error;
end if;
elsif Full_Switch (Parser => Parser) =
"-old-pragma-format"
then
-- Junk for now, should be changed to opposite when
-- K108-003 is complete
Gnatelim.Options.Long_Pragma_Format := False;
elsif Full_Switch (Parser => Parser) = "-RTS" then
-- We do not store --RTS option for gcc now - we have
-- to resolve its parameter to the full path, and we
-- can do this only when target is fully detected.
null;
end if;
else
if Full_Switch (Parser => Parser) = "-RTS" then
Store_RTS_Path (Parameter (Parser => Parser));
elsif Full_Switch (Parser => Parser) = "-target" then
Target := new String'(Parameter (Parser => Parser));
end if;
end if;
when others =>
raise Parameter_Error;
end case;
end loop;
if not First_Pass then
Process_cargs_Section (Parser => Parser);
end if;
exception
when GNAT.Command_Line.Invalid_Switch =>
Error ("invalid switch : " & Full_Switch (Parser => Parser));
raise Parameter_Error;
when GNAT.Command_Line.Invalid_Parameter =>
Error ("missing Parameter (Parser => Parser) for: " &
Full_Switch (Parser => Parser));
raise Parameter_Error;
end Scan_Arguments;
-----------------------
-- Tool_Package_Name --
-----------------------
function Tool_Package_Name
(My_Project : Gnatelim_Project_Type)
return String
is
pragma Unreferenced (My_Project);
begin
return "Eliminate";
end Tool_Package_Name;
end Gnatelim.Projects;
|