Commit d77cfab2 by Arnaud Charlet

[multiple changes]

2014-08-01  Gary Dismukes  <dismukes@adacore.com>

	* makeutl.ads, opt.ads: Minor grammar fixes.
	* makeutl.adb: Minor code reorganization.

2014-08-01  Arnaud Charlet  <charlet@adacore.com>

	* gcc-interface/Makefile.in, gcc-interface/Make-lang.in,
	gnatsym.adb: Remove gnatsym (VMS only tool).

2014-08-01  Ben Brosgol  <brosgol@adacore.com>

	* gnat_ugn.texi, projects.texi, xgnatugn.adb: Removed all VMS
	conditionalization from gnat_ugn.texi and projects.texi, and updated
	(considerably simplified) xgnatugn.adb, to be removed soon.

From-SVN: r213427
parent c84495c0
2014-08-01 Gary Dismukes <dismukes@adacore.com>
* makeutl.ads, opt.ads: Minor grammar fixes.
* makeutl.adb: Minor code reorganization.
2014-08-01 Arnaud Charlet <charlet@adacore.com>
* gcc-interface/Makefile.in, gcc-interface/Make-lang.in,
gnatsym.adb: Remove gnatsym (VMS only tool).
2014-08-01 Ben Brosgol <brosgol@adacore.com>
* gnat_ugn.texi, projects.texi, xgnatugn.adb: Removed all VMS
conditionalization from gnat_ugn.texi and projects.texi, and updated
(considerably simplified) xgnatugn.adb, to be removed soon.
2014-08-01 Vincent Celier <celier@adacore.com> 2014-08-01 Vincent Celier <celier@adacore.com>
* debug.adb: Remove doc for gnatmake/gprbuild switch -ds. * debug.adb: Remove doc for gnatmake/gprbuild switch -ds.
......
...@@ -89,7 +89,7 @@ ADA_FLAGS_TO_PASS = \ ...@@ -89,7 +89,7 @@ ADA_FLAGS_TO_PASS = \
# List of Ada tools to build and install # List of Ada tools to build and install
ADA_TOOLS=gnatbind gnatchop gnat gnatkr gnatlink gnatls gnatmake \ ADA_TOOLS=gnatbind gnatchop gnat gnatkr gnatlink gnatls gnatmake \
gnatname gnatprep gnatxref gnatfind gnatclean gnatsym gnatname gnatprep gnatxref gnatfind gnatclean
# Say how to compile Ada programs. # Say how to compile Ada programs.
.SUFFIXES: .ada .adb .ads .SUFFIXES: .ada .adb .ads
...@@ -763,8 +763,7 @@ doc/gnat-style.pdf: ada/gnat-style.texi $(gcc_docdir)/include/fdl.texi ...@@ -763,8 +763,7 @@ doc/gnat-style.pdf: ada/gnat-style.texi $(gcc_docdir)/include/fdl.texi
# or from the --target option if the former is not specified. # or from the --target option if the former is not specified.
# Do the same for the rest of the Ada tools (gnatchop, gnat, gnatkr, # Do the same for the rest of the Ada tools (gnatchop, gnat, gnatkr,
# gnatlink, gnatls, gnatmake, gnatname, gnatprep, gnatxref, gnatfind, # gnatlink, gnatls, gnatmake, gnatname, gnatprep, gnatxref, gnatfind,
# gnatclean, gnatsym). # gnatclean).
# gnatsym is only built on some platforms, including VMS.
# gnatdll is only used on Windows. # gnatdll is only used on Windows.
# vxaddr2line is only used for cross VxWorks ports (it calls the underlying # vxaddr2line is only used for cross VxWorks ports (it calls the underlying
# cross addr2line). # cross addr2line).
...@@ -840,7 +839,6 @@ ada.distclean: ...@@ -840,7 +839,6 @@ ada.distclean:
-$(RM) gnatfind$(exeext) -$(RM) gnatfind$(exeext)
-$(RM) gnatxref$(exeext) -$(RM) gnatxref$(exeext)
-$(RM) gnatclean$(exeext) -$(RM) gnatclean$(exeext)
-$(RM) gnatsym$(exeext)
-$(RM) ada/rts/* -$(RM) ada/rts/*
-$(RMDIR) ada/rts -$(RMDIR) ada/rts
-$(RM) ada/tools/* -$(RM) ada/tools/*
......
...@@ -2544,11 +2544,6 @@ common-tools: ../stamp-tools ...@@ -2544,11 +2544,6 @@ common-tools: ../stamp-tools
$(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \ $(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \
--GCC="$(GCC_LINK)" $(TOOLS_LIBS) --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
../../gnatsym$(exeext): ../stamp-tools
$(GNATMAKE) -c $(ADA_INCLUDES) gnatsym --GCC="$(CC) $(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatsym
$(GNATLINK) -v gnatsym -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
../../gnatdll$(exeext): ../stamp-tools ../../gnatdll$(exeext): ../stamp-tools
$(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)" $(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatdll $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatdll
......
This source diff could not be displayed because it is too large. You can view the blob instead.
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T S Y M --
-- --
-- B o d y --
-- --
-- Copyright (C) 2003-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- 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. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This utility application creates symbol files in a format that is
-- platform-dependent.
-- A symbol file is a text file that lists the symbols to be exported from
-- a shared library. The format of a symbol file depends on the platform;
-- it may be a simple enumeration of the symbol (one per line) or a more
-- elaborate format (on VMS, for example). A symbol file may be used as an
-- input to the platform linker when building a shared library.
-- This utility is not available on all platforms. It is currently supported
-- only on OpenVMS.
-- gnatsym takes as parameters:
-- - the name of the symbol file to create
-- - (optional) the policy to create the symbol file
-- - (optional) the name of the reference symbol file
-- - the names of one or more object files where the symbols are found
with Gnatvsn; use Gnatvsn;
with Osint; use Osint;
with Output; use Output;
with Symbols; use Symbols;
with Table;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Command_Line; use GNAT.Command_Line;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with GNAT.OS_Lib; use GNAT.OS_Lib;
procedure Gnatsym is
Empty_String : aliased String := "";
Empty : constant String_Access := Empty_String'Unchecked_Access;
-- To initialize variables Reference and Version_String
Copyright_Displayed : Boolean := False;
-- A flag to prevent multiple display of the Copyright notice
Success : Boolean := True;
Symbol_Policy : Policy := Autonomous;
Verbose : Boolean := False;
-- True when -v switch is used
Quiet : Boolean := False;
-- True when -q switch is used
Symbol_File_Name : String_Access := null;
-- The name of the symbol file
Reference_Symbol_File_Name : String_Access := Empty;
-- The name of the reference symbol file
Version_String : String_Access := Empty;
-- The version of the library (used on VMS)
type Object_File_Data is record
Path : String_Access;
Name : String_Access;
end record;
package Object_Files is new Table.Table
(Table_Component_Type => Object_File_Data,
Table_Index_Type => Natural,
Table_Low_Bound => 0,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Gnatsymb.Object_Files");
-- A table to store the object file names
Object_File : Natural := 0;
-- An index to traverse the Object_Files table
procedure Display_Copyright;
-- Display Copyright notice
procedure Parse_Cmd_Line;
-- Parse the command line switches and file names
procedure Usage;
-- Display the usage
-----------------------
-- Display_Copyright --
-----------------------
procedure Display_Copyright is
begin
if not Copyright_Displayed then
Write_Eol;
Write_Str ("GNATSYMB ");
Write_Str (Gnat_Version_String);
Write_Eol;
Write_Str ("Copyright 2003-2004 Free Software Foundation, Inc");
Write_Eol;
Copyright_Displayed := True;
end if;
end Display_Copyright;
--------------------
-- Parse_Cmd_Line --
--------------------
procedure Parse_Cmd_Line is
begin
loop
case GNAT.Command_Line.Getopt ("c C D q r: R s: v V:") is
when ASCII.NUL =>
exit;
when 'c' =>
Symbol_Policy := Compliant;
when 'C' =>
Symbol_Policy := Controlled;
when 'D' =>
Symbol_Policy := Direct;
when 'q' =>
Quiet := True;
when 'r' =>
Reference_Symbol_File_Name :=
new String'(GNAT.Command_Line.Parameter);
when 'R' =>
Symbol_Policy := Restricted;
when 's' =>
Symbol_File_Name := new String'(GNAT.Command_Line.Parameter);
when 'v' =>
Verbose := True;
when 'V' =>
Version_String := new String'(GNAT.Command_Line.Parameter);
when others =>
Fail ("invalid switch: " & Full_Switch);
end case;
end loop;
-- Get the object file names and put them in the table in alphabetical
-- order of base names.
loop
declare
S : constant String_Access :=
new String'(GNAT.Command_Line.Get_Argument);
begin
exit when S'Length = 0;
Object_Files.Increment_Last;
declare
Base : constant String := Base_Name (S.all);
Last : constant Positive := Object_Files.Last;
J : Positive;
begin
J := 1;
while J < Last loop
if Object_Files.Table (J).Name.all > Base then
Object_Files.Table (J + 1 .. Last) :=
Object_Files.Table (J .. Last - 1);
exit;
end if;
J := J + 1;
end loop;
Object_Files.Table (J) := (S, new String'(Base));
end;
end;
end loop;
exception
when Invalid_Switch =>
Usage;
Fail ("invalid switch : " & Full_Switch);
end Parse_Cmd_Line;
-----------
-- Usage --
-----------
procedure Usage is
begin
Write_Line ("gnatsym [options] object_file {object_file}");
Write_Eol;
Write_Line (" -c Compliant symbol policy");
Write_Line (" -C Controlled symbol policy");
Write_Line (" -q Quiet mode");
Write_Line (" -r<ref> Reference symbol file name");
Write_Line (" -R Restricted symbol policy");
Write_Line (" -s<sym> Symbol file name");
Write_Line (" -v Verbose mode");
Write_Line (" -V<ver> Version");
Write_Eol;
Write_Line ("Specifying a symbol file with -s<sym> is compulsory");
Write_Eol;
end Usage;
-- Start of processing of Gnatsym
begin
-- Initialize Object_Files table
Object_Files.Set_Last (0);
-- Parse the command line
Parse_Cmd_Line;
if Verbose then
Display_Copyright;
end if;
-- If there is no symbol file or no object files on the command line,
-- display the usage and exit with an error status.
if Symbol_File_Name = null or else Object_Files.Last = 0 then
Usage;
OS_Exit (1);
-- When symbol policy is direct, simply copy the reference symbol file to
-- the symbol file.
elsif Symbol_Policy = Direct then
declare
File_In : Ada.Text_IO.File_Type;
File_Out : Ada.Text_IO.File_Type;
Line : String (1 .. 1_000);
Last : Natural;
begin
begin
Open (File_In, In_File, Reference_Symbol_File_Name.all);
exception
when X : others =>
if not Quiet then
Put_Line
("could not open """ &
Reference_Symbol_File_Name.all
& """");
Put_Line (Exception_Message (X));
end if;
OS_Exit (1);
end;
begin
Create (File_Out, Out_File, Symbol_File_Name.all);
exception
when X : others =>
if not Quiet then
Put_Line
("could not create """ & Symbol_File_Name.all & """");
Put_Line (Exception_Message (X));
end if;
OS_Exit (1);
end;
while not End_Of_File (File_In) loop
Get_Line (File_In, Line, Last);
Put_Line (File_Out, Line (1 .. Last));
end loop;
Close (File_In);
Close (File_Out);
end;
else
if Verbose then
Write_Str ("Initializing symbol file """);
Write_Str (Symbol_File_Name.all);
Write_Line ("""");
end if;
-- Initialize symbol file and, if specified, read reference file
Symbols.Initialize
(Symbol_File => Symbol_File_Name.all,
Reference => Reference_Symbol_File_Name.all,
Symbol_Policy => Symbol_Policy,
Quiet => Quiet,
Version => Version_String.all,
Success => Success);
-- Process the object files in order. Stop as soon as there is
-- something wrong.
Object_File := 0;
while Success and then Object_File < Object_Files.Last loop
Object_File := Object_File + 1;
if Verbose then
Write_Str ("Processing object file """);
Write_Str (Object_Files.Table (Object_File).Path.all);
Write_Line ("""");
end if;
Processing.Process
(Object_Files.Table (Object_File).Path.all,
Success);
end loop;
-- Finalize the symbol file
if Success then
if Verbose then
Write_Str ("Finalizing """);
Write_Str (Symbol_File_Name.all);
Write_Line ("""");
end if;
Finalize (Quiet, Success);
end if;
-- Fail if there was anything wrong
if not Success then
Fail ("unable to build symbol file");
end if;
end if;
end Gnatsym;
...@@ -777,7 +777,7 @@ package body Makeutl is ...@@ -777,7 +777,7 @@ package body Makeutl is
Flush_Messages : Boolean := True) Flush_Messages : Boolean := True)
is is
begin begin
if Flush_Messages and then not No_Exit_Message then if Flush_Messages and not No_Exit_Message then
if Total_Errors_Detected /= 0 or else Warnings_Detected /= 0 then if Total_Errors_Detected /= 0 or else Warnings_Detected /= 0 then
Errutil.Finalize; Errutil.Finalize;
end if; end if;
......
...@@ -81,8 +81,8 @@ package Makeutl is ...@@ -81,8 +81,8 @@ package Makeutl is
No_Exit_Message_Option : constant String := "--no-exit-message"; No_Exit_Message_Option : constant String := "--no-exit-message";
-- Switch to suppress exit error message when there are compilation -- Switch to suppress exit error message when there are compilation
-- failures. This is useful when a tool, such as gnatprove, call silently -- failures. This is useful when a tool, such as gnatprove, silently calls
-- the builder and do not want to pollute its output with error messages -- the builder and does not want to pollute its output with error messages
-- coming from the builder. This is an internal switch. -- coming from the builder. This is an internal switch.
Load_Standard_Base : Boolean := True; Load_Standard_Base : Boolean := True;
......
...@@ -1941,7 +1941,7 @@ package Opt is ...@@ -1941,7 +1941,7 @@ package Opt is
No_Exit_Message : Boolean := False; No_Exit_Message : Boolean := False;
-- GNATMAKE, GPRBUILD -- GNATMAKE, GPRBUILD
-- Set with switch --no-exit-message. When True, if there are compilation -- Set with switch --no-exit-message. When True, if there are compilation
-- failure, the builder does not issue an exit error message. -- failures, the builder does not issue an exit error message.
Optimize_Alignment_Config : Character; Optimize_Alignment_Config : Character;
-- GNAT -- GNAT
......
...@@ -41,7 +41,7 @@ project files allow you to specify: ...@@ -41,7 +41,7 @@ project files allow you to specify:
@item The directory in which the compiler's output @item The directory in which the compiler's output
(@file{ALI} files, object files, tree files, etc.) is to be placed (@file{ALI} files, object files, tree files, etc.) is to be placed
@item The directory in which the executable programs are to be placed @item The directory in which the executable programs are to be placed
@item ^Switch^Switch^ settings for any of the project-enabled tools; @item Switch settings for any of the project-enabled tools;
you can apply these settings either globally or to individual compilation units. you can apply these settings either globally or to individual compilation units.
@item The source files containing the main subprogram(s) to be built @item The source files containing the main subprogram(s) to be built
@item The source programming language(s) @item The source programming language(s)
...@@ -68,7 +68,7 @@ Subsystems}). ...@@ -68,7 +68,7 @@ Subsystems}).
More generally, the Project Manager lets you structure large development More generally, the Project Manager lets you structure large development
efforts into hierarchical subsystems, where build decisions are delegated efforts into hierarchical subsystems, where build decisions are delegated
to the subsystem level, and thus different compilation environments to the subsystem level, and thus different compilation environments
(^switch^switch^ settings) used for different subsystems. (switch settings) used for different subsystems.
@item You can organize GNAT projects in a hierarchy: a child project @item You can organize GNAT projects in a hierarchy: a child project
can extend a parent project, inheriting the parent's source files and can extend a parent project, inheriting the parent's source files and
optionally overriding any of them with alternative versions optionally overriding any of them with alternative versions
...@@ -80,8 +80,8 @@ Subsystems}). ...@@ -80,8 +80,8 @@ Subsystems}).
Several tools support project files, generally in addition to specifying Several tools support project files, generally in addition to specifying
the information on the command line itself). They share common switches the information on the command line itself). They share common switches
to control the loading of the project (in particular to control the loading of the project (in particular
@option{^-P^/PROJECT_FILE=^@emph{projectfile}} and @option{-P@emph{projectfile}} and
@option{^-X^/EXTERNAL_REFERENCE=^@emph{vbl}=@emph{value}}). @option{-X@emph{vbl}=@emph{value}}).
The Project Manager supports a wide range of development strategies, The Project Manager supports a wide range of development strategies,
for systems of all sizes. Here are some typical practices that are for systems of all sizes. Here are some typical practices that are
...@@ -89,7 +89,7 @@ easily handled: ...@@ -89,7 +89,7 @@ easily handled:
@itemize @bullet @itemize @bullet
@item Using a common set of source files and generating object files in different @item Using a common set of source files and generating object files in different
directories via different ^switch^switch^ settings. It can be used for instance, for directories via different switch settings. It can be used for instance, for
generating separate sets of object files for debugging and for production. generating separate sets of object files for debugging and for production.
@item Using a mostly-shared set of source files with different versions of @item Using a mostly-shared set of source files with different versions of
some units or subunits. It can be used for instance, for grouping and hiding some units or subunits. It can be used for instance, for grouping and hiding
...@@ -185,19 +185,19 @@ following examples. ...@@ -185,19 +185,19 @@ following examples.
The Ada source files @file{pack.ads}, @file{pack.adb}, and @file{proc.adb} are in The Ada source files @file{pack.ads}, @file{pack.adb}, and @file{proc.adb} are in
the @file{common/} directory. The file @file{proc.adb} contains an Ada main the @file{common/} directory. The file @file{proc.adb} contains an Ada main
subprogram @code{Proc} that @code{with}s package @code{Pack}. We want to compile subprogram @code{Proc} that @code{with}s package @code{Pack}. We want to compile
these source files with the ^switch^switch^ these source files with the switch
@option{^-O2^-O2^}, and put the resulting files in @option{-O2}, and put the resulting files in
the directory @file{obj/}. the directory @file{obj/}.
@smallexample @smallexample
@group @group
^common/^[COMMON]^ common/
pack.ads pack.ads
pack.adb pack.adb
proc.adb proc.adb
@end group @end group
@group @group
^common/release/^[COMMON.RELEASE]^ common/release/
proc.ali, proc.o pack.ali, pack.o proc.ali, proc.o pack.ali, pack.o
@end group @end group
@end smallexample @end smallexample
...@@ -450,7 +450,7 @@ Its value is the path to the object directory, either absolute or ...@@ -450,7 +450,7 @@ Its value is the path to the object directory, either absolute or
relative to the directory containing the project file. This relative to the directory containing the project file. This
directory must already exist and be readable and writable, although directory must already exist and be readable and writable, although
some tools have a switch to create the directory if needed (See some tools have a switch to create the directory if needed (See
the switch @code{^-p^/CREATE_MISSING_DIRS^} for @command{gnatmake} the switch @code{-p} for @command{gnatmake}
and @command{gprbuild}). and @command{gprbuild}).
If the attribute @code{Object_Dir} is not specified, it defaults to If the attribute @code{Object_Dir} is not specified, it defaults to
...@@ -540,7 +540,7 @@ If this attribute is defined in the project, then spawning the builder ...@@ -540,7 +540,7 @@ If this attribute is defined in the project, then spawning the builder
with a command such as with a command such as
@smallexample @smallexample
gnatmake ^-Pbuild^/PROJECT_FILE=build^ gnatmake -Pbuild
@end smallexample @end smallexample
@noindent @noindent
...@@ -617,13 +617,13 @@ packages would be involved in the build process. ...@@ -617,13 +617,13 @@ packages would be involved in the build process.
@noindent @noindent
Let's first examine the compiler switches. As stated in the initial description Let's first examine the compiler switches. As stated in the initial description
of the example, we want to compile all files with @option{^-O2^-O2^}. This is a of the example, we want to compile all files with @option{-O2}. This is a
compiler switch, although it is usual, on the command line, to pass it to the compiler switch, although it is usual, on the command line, to pass it to the
builder which then passes it to the compiler. It is recommended to use directly builder which then passes it to the compiler. It is recommended to use directly
the right package, which will make the setup easier to understand for other the right package, which will make the setup easier to understand for other
people. people.
Several attributes can be used to specify the ^switches^switches^: Several attributes can be used to specify the switches:
@table @asis @table @asis
@item @b{Default_Switches}: @item @b{Default_Switches}:
...@@ -636,22 +636,22 @@ Several attributes can be used to specify the ^switches^switches^: ...@@ -636,22 +636,22 @@ Several attributes can be used to specify the ^switches^switches^:
likely be used for each language, and each compiler has its own set of likely be used for each language, and each compiler has its own set of
switches). The value of the attribute is a list of switches. switches). The value of the attribute is a list of switches.
In this example, we want to compile all Ada source files with the ^switch^switch^ In this example, we want to compile all Ada source files with the switch
@option{^-O2^-O2^}, and the resulting project file is as follows @option{-O2}, and the resulting project file is as follows
(only the @code{Compiler} package is shown): (only the @code{Compiler} package is shown):
@smallexample @smallexample
@b{package} Compiler @b{is} @b{package} Compiler @b{is}
@b{for} Default_Switches ("Ada") @b{use} ("^-O2^-O2^"); @b{for} Default_Switches ("Ada") @b{use} ("-O2");
@b{end} Compiler; @b{end} Compiler;
@end smallexample @end smallexample
@item @b{^Switches^Switches^}: @item @b{Switches}:
@cindex @code{^Switches^Switches^} @cindex @code{Switches}
in some cases, we might want to use specific ^switches^switches^ in some cases, we might want to use specific switches
for one or more files. For instance, compiling @file{proc.adb} might not be for one or more files. For instance, compiling @file{proc.adb} might not be
possible at high level of optimization because of a compiler issue. possible at high level of optimization because of a compiler issue.
In such a case, the @emph{^Switches^Switches^} In such a case, the @emph{Switches}
attribute (indexed on the file name) can be used and will override the attribute (indexed on the file name) can be used and will override the
switches defined by @emph{Default_Switches}. Our project file would switches defined by @emph{Default_Switches}. Our project file would
become: become:
...@@ -659,30 +659,30 @@ Several attributes can be used to specify the ^switches^switches^: ...@@ -659,30 +659,30 @@ Several attributes can be used to specify the ^switches^switches^:
@smallexample @smallexample
package Compiler is package Compiler is
for Default_Switches ("Ada") for Default_Switches ("Ada")
use ("^-O2^-O2^"); use ("-O2");
for ^Switches^Switches^ ("proc.adb") for Switches ("proc.adb")
use ("^-O0^-O0^"); use ("-O0");
end Compiler; end Compiler;
@end smallexample @end smallexample
@noindent @noindent
@code{^Switches^Switches^} may take a pattern as an index, such as in: @code{Switches} may take a pattern as an index, such as in:
@smallexample @smallexample
package Compiler is package Compiler is
for Default_Switches ("Ada") for Default_Switches ("Ada")
use ("^-O2^-O2^"); use ("-O2");
for ^Switches^Switches^ ("pkg*") for Switches ("pkg*")
use ("^-O0^-O0^"); use ("-O0");
end Compiler; end Compiler;
@end smallexample @end smallexample
@noindent @noindent
Sources @file{pkg.adb} and @file{pkg-child.adb} would be compiled with ^-O0^-O0^, Sources @file{pkg.adb} and @file{pkg-child.adb} would be compiled with -O0,
not ^-O2^-O2^. not -O2.
@noindent @noindent
@code{^Switches^Switches^} can also be given a language name as index instead of a file @code{Switches} can also be given a language name as index instead of a file
name in which case it has the same semantics as @emph{Default_Switches}. name in which case it has the same semantics as @emph{Default_Switches}.
However, indexes with wild cards are never valid for language name. However, indexes with wild cards are never valid for language name.
...@@ -696,7 +696,7 @@ Several attributes can be used to specify the ^switches^switches^: ...@@ -696,7 +696,7 @@ Several attributes can be used to specify the ^switches^switches^:
@end table @end table
The switches for the other tools are defined in a similar manner through the The switches for the other tools are defined in a similar manner through the
@b{Default_Switches} and @b{^Switches^Switches^} attributes, respectively in the @b{Default_Switches} and @b{Switches} attributes, respectively in the
@emph{Builder} package (for @command{gnatmake} and @command{gprbuild}), @emph{Builder} package (for @command{gnatmake} and @command{gprbuild}),
the @emph{Binder} package (binding Ada executables) and the @emph{Linker} the @emph{Binder} package (binding Ada executables) and the @emph{Linker}
package (for linking executables). package (for linking executables).
...@@ -711,7 +711,7 @@ Now that our project files are written, let's build our executable. ...@@ -711,7 +711,7 @@ Now that our project files are written, let's build our executable.
Here is the command we would use from the command line: Here is the command we would use from the command line:
@smallexample @smallexample
gnatmake ^-Pbuild^/PROJECT_FILE=build^ gnatmake -Pbuild
@end smallexample @end smallexample
@noindent @noindent
...@@ -727,7 +727,7 @@ same way: create the file @file{utils.c} in the @file{common} directory, ...@@ -727,7 +727,7 @@ same way: create the file @file{utils.c} in the @file{common} directory,
set the attribute @emph{Languages} to @code{"(Ada, C)"}, and run set the attribute @emph{Languages} to @code{"(Ada, C)"}, and run
@smallexample @smallexample
gprbuild ^-Pbuild^/PROJECT_FILE=build^ gprbuild -Pbuild
@end smallexample @end smallexample
@noindent @noindent
...@@ -784,12 +784,12 @@ on Windows), we could configure our project file to build "proc1" ...@@ -784,12 +784,12 @@ on Windows), we could configure our project file to build "proc1"
(resp proc1.exe) with the following addition: (resp proc1.exe) with the following addition:
@smallexample @c projectfile @smallexample @c projectfile
project Build is @b{project} Build @b{is}
... -- same as before ... --@i{ same as before}
package Builder is @b{package} Builder @b{is}
for Executable ("proc.adb") use "proc1"; @b{for} Executable ("proc.adb") @b{use} "proc1";
end Builder @b{end} Builder
end Build; @b{end} Build;
@end smallexample @end smallexample
@noindent @noindent
...@@ -815,18 +815,18 @@ To illustrate some other project capabilities, here is a slightly more complex ...@@ -815,18 +815,18 @@ To illustrate some other project capabilities, here is a slightly more complex
project using similar sources and a main program in C: project using similar sources and a main program in C:
@smallexample @c projectfile @smallexample @c projectfile
project C_Main is @b{project} C_Main @b{is}
for Languages use ("Ada", "C"); @b{for} Languages @b{use} ("Ada", "C");
for Source_Dirs use ("common"); @b{for} Source_Dirs @b{use} ("common");
for Object_Dir use "obj"; @b{for} Object_Dir @b{use} "obj";
for Main use ("main.c"); @b{for} Main @b{use} ("main.c");
package Compiler is @b{package} Compiler @b{is}
C_Switches := ("-pedantic"); C_Switches := ("-pedantic");
for Default_Switches ("C") use C_Switches; @b{for} Default_Switches ("C") @b{use} C_Switches;
for Default_Switches ("Ada") use ("^-gnaty^-gnaty^"); @b{for} Default_Switches ("Ada") @b{use} ("-gnaty");
for ^Switches^Switches^ ("main.c") use C_Switches & ("-g"); @b{for} Switches ("main.c") @b{use} C_Switches & ("-g");
end Compiler; @b{end} Compiler;
end C_Main; @b{end} C_Main;
@end smallexample @end smallexample
@noindent @noindent
...@@ -848,7 +848,7 @@ In this specific situation the use of a variable could have been ...@@ -848,7 +848,7 @@ In this specific situation the use of a variable could have been
replaced by a reference to the @code{Default_Switches} attribute: replaced by a reference to the @code{Default_Switches} attribute:
@smallexample @c projectfile @smallexample @c projectfile
for ^Switches^Switches^ ("c_main.c") use Compiler'Default_Switches ("C") & ("-g"); @b{for} Switches ("c_main.c") @b{use} Compiler'Default_Switches ("C") & ("-g");
@end smallexample @end smallexample
@noindent @noindent
...@@ -940,7 +940,7 @@ The following attributes can be defined in package @code{Naming}: ...@@ -940,7 +940,7 @@ The following attributes can be defined in package @code{Naming}:
@code{Specification_Exceptions}. @code{Specification_Exceptions}.
If @code{Spec_Suffix ("Ada")} is not specified, then the default is If @code{Spec_Suffix ("Ada")} is not specified, then the default is
@code{"^.ads^.ADS^"}. @code{".ads"}.
A non empty value must satisfy the following requirements: A non empty value must satisfy the following requirements:
...@@ -969,7 +969,7 @@ The following attributes can be defined in package @code{Naming}: ...@@ -969,7 +969,7 @@ The following attributes can be defined in package @code{Naming}:
In addition, they must be different from any of the values in In addition, they must be different from any of the values in
@code{Spec_Suffix}. @code{Spec_Suffix}.
If @code{Body_Suffix ("Ada")} is not specified, then the default is If @code{Body_Suffix ("Ada")} is not specified, then the default is
@code{"^.adb^.ADB^"}. @code{".adb"}.
If @code{Body_Suffix ("Ada")} and @code{Spec_Suffix ("Ada")} end with the If @code{Body_Suffix ("Ada")} and @code{Spec_Suffix ("Ada")} end with the
same string, then a file name that ends with the longest of these two same string, then a file name that ends with the longest of these two
...@@ -1029,39 +1029,20 @@ The following attributes can be defined in package @code{Naming}: ...@@ -1029,39 +1029,20 @@ The following attributes can be defined in package @code{Naming}:
@end table @end table
@ifclear vms @set unw
For example, the following package models the Apex file naming rules: For example, the following package models the Apex file naming rules:
@smallexample @c projectfile @smallexample @c projectfile
@group @group
package Naming is @b{package} Naming @b{is}
for Casing use "lowercase"; @b{for} Casing @b{use} "lowercase";
for Dot_Replacement use "."; @b{for} Dot_Replacement @b{use} ".";
for Spec_Suffix ("Ada") use ".1.ada"; @b{for} Spec_Suffix ("Ada") @b{use} ".1.ada";
for Body_Suffix ("Ada") use ".2.ada"; @b{for} Body_Suffix ("Ada") @b{use} ".2.ada";
end Naming; @b{end} Naming;
@end group @end group
@end smallexample @end smallexample
@end ifclear
@ifset vms
For example, the following package models the DEC Ada file naming rules:
@smallexample @c projectfile
@group
package Naming is
for Casing use "lowercase";
for Dot_Replacement use "__";
for Spec_Suffix ("Ada") use "_.ada";
for Body_Suffix ("Ada") use ".ada";
end Naming;
@end group
@end smallexample
@noindent
(Note that @code{Casing} is @code{"lowercase"} because GNAT gets the file
names in lower case)
@end ifset
@c --------------------------------------------- @c ---------------------------------------------
@node Installation @node Installation
...@@ -1186,11 +1167,11 @@ This is easily solved by adding the following @b{with} clauses at the beginning ...@@ -1186,11 +1167,11 @@ This is easily solved by adding the following @b{with} clauses at the beginning
of our project: of our project:
@smallexample @c projectfile @smallexample @c projectfile
with "gtkada.gpr"; @b{with} "gtkada.gpr";
with "a/b/logging.gpr"; @b{with} "a/b/logging.gpr";
project Build is @b{project} Build @b{is}
... -- as before ... --@i{ as before}
end Build; @b{end} Build;
@end smallexample @end smallexample
@noindent @noindent
...@@ -1219,7 +1200,7 @@ project files rather than packages. ...@@ -1219,7 +1200,7 @@ project files rather than packages.
Each literal string after @code{with} is the path Each literal string after @code{with} is the path
(absolute or relative) to a project file. The @code{.gpr} extension is (absolute or relative) to a project file. The @code{.gpr} extension is
optional, although we recommend adding it. If no extension is specified, optional, although we recommend adding it. If no extension is specified,
and no project file with the @file{^.gpr^.GPR^} extension is found, then and no project file with the @file{.gpr} extension is found, then
the file is searched for exactly as written in the @code{with} clause, the file is searched for exactly as written in the @code{with} clause,
that is with no extension. that is with no extension.
...@@ -1245,7 +1226,7 @@ the search stops: ...@@ -1245,7 +1226,7 @@ the search stops:
@cindex @code{GPR_PROJECT_PATH} @cindex @code{GPR_PROJECT_PATH}
@cindex @code{ADA_PROJECT_PATH} @cindex @code{ADA_PROJECT_PATH}
Then it is searched relative to all the directories specified in the Then it is searched relative to all the directories specified in the
^environment variables^logical names^ @b{GPR_PROJECT_PATH_FILE}, environment variables @b{GPR_PROJECT_PATH_FILE},
@b{GPR_PROJECT_PATH} and @b{ADA_PROJECT_PATH} (in that order) if they exist. @b{GPR_PROJECT_PATH} and @b{ADA_PROJECT_PATH} (in that order) if they exist.
The value of @b{GPR_PROJECT_PATH_FILE}, when defined, is the path name of The value of @b{GPR_PROJECT_PATH_FILE}, when defined, is the path name of
a text file that contains project directory path names, one per line. a text file that contains project directory path names, one per line.
...@@ -1371,11 +1352,11 @@ There are two main approaches to avoiding this duplication: ...@@ -1371,11 +1352,11 @@ There are two main approaches to avoiding this duplication:
@smallexample @c projectfile @smallexample @c projectfile
project Logging is project Logging is
package Compiler is package Compiler is
for ^Switches^Switches^ ("Ada") for Switches ("Ada")
use ("^-O2^-O2^"); use ("-O2");
end Compiler; end Compiler;
package Binder is package Binder is
for ^Switches^Switches^ ("Ada") for Switches ("Ada")
use ("-E"); use ("-E");
end Binder; end Binder;
end Logging; end Logging;
...@@ -1384,7 +1365,7 @@ There are two main approaches to avoiding this duplication: ...@@ -1384,7 +1365,7 @@ There are two main approaches to avoiding this duplication:
project Build is project Build is
package Compiler renames Logging.Compiler; package Compiler renames Logging.Compiler;
package Binder is package Binder is
for ^Switches^Switches^ ("Ada") use Logging.Binder'Switches ("Ada"); for Switches ("Ada") use Logging.Binder'Switches ("Ada");
end Binder; end Binder;
end Build; end Build;
@end smallexample @end smallexample
...@@ -1416,8 +1397,8 @@ There are two main approaches to avoiding this duplication: ...@@ -1416,8 +1397,8 @@ There are two main approaches to avoiding this duplication:
abstract project Shared is abstract project Shared is
for Source_Files use (); -- no sources for Source_Files use (); -- no sources
package Compiler is package Compiler is
for ^Switches^Switches^ ("Ada") for Switches ("Ada")
use ("^-O2^-O2^"); use ("-O2");
end Compiler; end Compiler;
end Shared; end Shared;
...@@ -1503,7 +1484,7 @@ information, when the second will focus on improving code optimization). ...@@ -1503,7 +1484,7 @@ information, when the second will focus on improving code optimization).
Let's enhance our example to support a debug and a release modes.The issue is to Let's enhance our example to support a debug and a release modes.The issue is to
let the user choose what kind of system he is building: let the user choose what kind of system he is building:
use @option{-g} as compiler switches in debug mode and @option{^-O2^-O2^} use @option{-g} as compiler switches in debug mode and @option{-O2}
in release mode. We will also setup the projects so that we do not share the in release mode. We will also setup the projects so that we do not share the
same object directory in both modes, otherwise switching from one to the other same object directory in both modes, otherwise switching from one to the other
might trigger more recompilations than needed or mix objects from the 2 modes. might trigger more recompilations than needed or mix objects from the 2 modes.
...@@ -1532,10 +1513,10 @@ order of priority): ...@@ -1532,10 +1513,10 @@ order of priority):
or gnatmake -Pbuild.gpr -Xmode=release or gnatmake -Pbuild.gpr -Xmode=release
@end smallexample @end smallexample
@item @b{^Environment variables^Logical names^}: @item @b{Environment variables}:
When the external value does not come from the command line, it can come from When the external value does not come from the command line, it can come from
the value of ^environment variables^logical names^ of the appropriate name. the value of environment variables of the appropriate name.
In our case, if ^an environment variable^a logical name^ called "mode" In our case, if an environment variable called "mode"
exist, its value will be taken into account. exist, its value will be taken into account.
@item @b{External function second parameter} @item @b{External function second parameter}
...@@ -1549,10 +1530,10 @@ the external. For instance, we could setup the object directory to point to ...@@ -1549,10 +1530,10 @@ the external. For instance, we could setup the object directory to point to
either @file{obj/debug} or @file{obj/release} by changing our project to either @file{obj/debug} or @file{obj/release} by changing our project to
@smallexample @c projectfile @smallexample @c projectfile
project Build is @b{project} Build @b{is}
for Object_Dir use "obj/" & external ("mode", "debug"); @b{for} Object_Dir @b{use} "obj/" & @b{external} ("mode", "debug");
... -- as before ... --@i{ as before}
end Build; @b{end} Build;
@end smallexample @end smallexample
@noindent @noindent
...@@ -1570,21 +1551,21 @@ Such a variable can then be used in a @b{case construction} and create condition ...@@ -1570,21 +1551,21 @@ Such a variable can then be used in a @b{case construction} and create condition
sections in the project. The following example shows how this can be done: sections in the project. The following example shows how this can be done:
@smallexample @c projectfile @smallexample @c projectfile
project Build is @b{project} Build @b{is}
type Mode_Type is ("debug", "release"); -- all possible values @b{type} Mode_Type @b{is} ("debug", "release"); --@i{ all possible values}
Mode : Mode_Type := external ("mode", "debug"); -- a typed variable Mode : Mode_Type := @b{external} ("mode", "debug"); --@i{ a typed variable}
package Compiler is @b{package} Compiler @b{is}
case Mode is @b{case} Mode @b{is}
when "debug" => @b{when} "debug" =>
for ^Switches^Switches^ ("Ada") @b{for} Switches ("Ada")
use ("-g"); @b{use} ("-g");
when "release" => @b{when} "release" =>
for ^Switches^Switches^ ("Ada") @b{for} Switches ("Ada")
use ("^-O2^-O2^"); @b{use} ("-O2");
end case; @b{end} @b{case};
end Compiler; @b{end} Compiler;
end Build; @b{end} Build;
@end smallexample @end smallexample
@noindent @noindent
...@@ -1684,11 +1665,11 @@ front of the @code{project} keyword. ...@@ -1684,11 +1665,11 @@ front of the @code{project} keyword.
Here is the new version of @file{logging.gpr} that makes it a library: Here is the new version of @file{logging.gpr} that makes it a library:
@smallexample @c projectfile @smallexample @c projectfile
library project Logging is -- "library" is optional library @b{project} Logging @b{is} --@i{ "library" is optional}
for Library_Name use "logging"; -- will create "liblogging.a" on Unix @b{for} Library_Name @b{use} "logging"; --@i{ will create "liblogging.a" on Unix}
for Object_Dir use "obj"; @b{for} Object_Dir @b{use} "obj";
for Library_Dir use "lib"; -- different from object_dir @b{for} Library_Dir @b{use} "lib"; --@i{ different from object_dir}
end Logging; @b{end} Logging;
@end smallexample @end smallexample
@noindent @noindent
...@@ -1740,13 +1721,13 @@ Other library-related attributes can be used to change the defaults: ...@@ -1740,13 +1721,13 @@ Other library-related attributes can be used to change the defaults:
@smallexample @c projectfile @smallexample @c projectfile
@group @group
project Logging is @b{project} Logging @b{is}
Version := "1"; Version := "1";
for Library_Dir use "lib"; @b{for} Library_Dir @b{use} "lib";
for Library_Name use "logging"; @b{for} Library_Name @b{use} "logging";
for Library_Kind use "dynamic"; @b{for} Library_Kind @b{use} "dynamic";
for Library_Version use "liblogging.so." & Version; @b{for} Library_Version @b{use} "liblogging.so." & Version;
end Logging; @b{end} Logging;
@end group @end group
@end smallexample @end smallexample
...@@ -1840,21 +1821,20 @@ All @file{ALI} files will also be copied from the object directory to the ...@@ -1840,21 +1821,20 @@ All @file{ALI} files will also be copied from the object directory to the
library directory. To build executables, @command{gnatmake} will use the library directory. To build executables, @command{gnatmake} will use the
library rather than the individual object files. library rather than the individual object files.
@ifclear vms
Library projects can also be useful to describe a library that need to be used Library projects can also be useful to describe a library that need to be used
but, for some reason, cannot be rebuilt. For instance, it is the case when some but, for some reason, cannot be rebuilt. For instance, it is the case when some
of the library sources are not available. Such library projects need simply to of the library sources are not available. Such library projects need simply to
use the @code{Externally_Built} attribute as in the example below: use the @code{Externally_Built} attribute as in the example below:
@smallexample @c projectfile @smallexample @c projectfile
library project Extern_Lib is library @b{project} Extern_Lib @b{is}
for Languages use ("Ada", "C"); @b{for} Languages @b{use} ("Ada", "C");
for Source_Dirs use ("lib_src"); @b{for} Source_Dirs @b{use} ("lib_src");
for Library_Dir use "lib2"; @b{for} Library_Dir @b{use} "lib2";
for Library_Kind use "dynamic"; @b{for} Library_Kind @b{use} "dynamic";
for Library_Name use "l2"; @b{for} Library_Name @b{use} "l2";
for Externally_Built use "true"; -- <<<< @b{for} Externally_Built @b{use} "true"; --@i{ <<<<}
end Extern_Lib; @b{end} Extern_Lib;
@end smallexample @end smallexample
@noindent @noindent
...@@ -1874,7 +1854,6 @@ In such a situation, it is better to use the externally built library project ...@@ -1874,7 +1854,6 @@ In such a situation, it is better to use the externally built library project
so that all other subsystems depending on it can declare this dependency thanks so that all other subsystems depending on it can declare this dependency thanks
to a project @code{with} clause, which in turn will trigger the builder to find to a project @code{with} clause, which in turn will trigger the builder to find
the proper order of libraries in the final link command. the proper order of libraries in the final link command.
@end ifclear
@c --------------------------------------------- @c ---------------------------------------------
@node Stand-alone Library Projects @node Stand-alone Library Projects
...@@ -1914,9 +1893,9 @@ language and takes a list of sources as parameter. ...@@ -1914,9 +1893,9 @@ language and takes a list of sources as parameter.
@smallexample @c projectfile @smallexample @c projectfile
@group @group
for Library_Dir use "lib"; @b{for} Library_Dir @b{use} "lib";
for Library_Name use "loggin"; @b{for} Library_Name @b{use} "loggin";
for Library_Interface use ("lib1", "lib2"); -- unit names @b{for} Library_Interface @b{use} ("lib1", "lib2"); --@i{ unit names}
@end group @end group
@end smallexample @end smallexample
...@@ -1944,11 +1923,11 @@ language and takes a list of sources as parameter. ...@@ -1944,11 +1923,11 @@ language and takes a list of sources as parameter.
@smallexample @c projectfile @smallexample @c projectfile
@group @group
for Library_Dir use "lib"; @b{for} Library_Dir @b{use} "lib";
for Library_Name use "loggin"; @b{for} Library_Name @b{use} "loggin";
for Library_Kind use "dynamic"; @b{for} Library_Kind @b{use} "dynamic";
for Library_Interface use ("lib1", "lib2"); -- unit names @b{for} Library_Interface @b{use} ("lib1", "lib2"); --@i{ unit names}
for Library_Standalone use "encapsulated"; @b{for} Library_Standalone @b{use} "encapsulated";
@end group @end group
@end smallexample @end smallexample
...@@ -1956,7 +1935,7 @@ language and takes a list of sources as parameter. ...@@ -1956,7 +1935,7 @@ language and takes a list of sources as parameter.
In order to include the elaboration code in the stand-alone library, the binder In order to include the elaboration code in the stand-alone library, the binder
is invoked on the closure of the library units creating a package whose name is invoked on the closure of the library units creating a package whose name
depends on the library name (^b~logging.ads/b^B$LOGGING.ADS/B^ in the example). depends on the library name (b~logging.ads/b in the example).
This binder-generated package includes @b{initialization} and @b{finalization} This binder-generated package includes @b{initialization} and @b{finalization}
procedures whose names depend on the library name (@code{logginginit} and procedures whose names depend on the library name (@code{logginginit} and
@code{loggingfinal} in the example). The object corresponding to this package is @code{loggingfinal} in the example). The object corresponding to this package is
...@@ -2125,8 +2104,8 @@ ones is also possible. Here is an example on how to extend the project ...@@ -2125,8 +2104,8 @@ ones is also possible. Here is an example on how to extend the project
@code{Build} from previous examples: @code{Build} from previous examples:
@smallexample @c projectfile @smallexample @c projectfile
project Work extends "../bld/build.gpr" is @b{project} Work @b{extends} "../bld/build.gpr" @b{is}
end Work; @b{end} Work;
@end smallexample @end smallexample
@noindent @noindent
...@@ -2240,18 +2219,18 @@ create several extending projects: ...@@ -2240,18 +2219,18 @@ create several extending projects:
@noindent @noindent
@smallexample @c projectfile @smallexample @c projectfile
project A_Ext extends "a.gpr" is @b{project} A_Ext @b{extends} "a.gpr" @b{is}
for Source_Files use ("a1.adb", "a1.ads"); @b{for} Source_Files @b{use} ("a1.adb", "a1.ads");
end A_Ext; @b{end} A_Ext;
with "a_ext.gpr"; @b{with} "a_ext.gpr";
project B_Ext extends "b.gpr" is @b{project} B_Ext @b{extends} "b.gpr" @b{is}
end B_Ext; @b{end} B_Ext;
with "b_ext.gpr"; @b{with} "b_ext.gpr";
project C_Ext extends "c.gpr" is @b{project} C_Ext @b{extends} "c.gpr" @b{is}
for Source_Files use ("c1.adb"); @b{for} Source_Files @b{use} ("c1.adb");
end C_Ext; @b{end} C_Ext;
@end smallexample @end smallexample
@noindent @noindent
...@@ -2292,14 +2271,14 @@ Thus, in our example we could create the following projects instead: ...@@ -2292,14 +2271,14 @@ Thus, in our example we could create the following projects instead:
@noindent @noindent
@smallexample @c projectfile @smallexample @c projectfile
project A_Ext extends "a.gpr" is @b{project} A_Ext @b{extends} "a.gpr" @b{is}
for Source_Files use ("a1.adb", "a1.ads"); @b{for} Source_Files @b{use} ("a1.adb", "a1.ads");
end A_Ext; @b{end} A_Ext;
with "a_ext.gpr"; @b{with} "a_ext.gpr";
project C_Ext extends all "c.gpr" is @b{project} C_Ext @b{extends} @b{all} "c.gpr" @b{is}
for Source_Files use ("c1.adb"); @b{for} Source_Files @b{use} ("c1.adb");
end C_Ext; @b{end} C_Ext;
@end smallexample @end smallexample
@noindent @noindent
...@@ -2369,9 +2348,9 @@ and C. Then, when you build with ...@@ -2369,9 +2348,9 @@ and C. Then, when you build with
this will build all mains from A, B and C. this will build all mains from A, B and C.
@smallexample @c projectfile @smallexample @c projectfile
aggregate project Agg is aggregate @b{project} Agg @b{is}
for Project_Files use ("a.gpr", "b.gpr", "c.gpr"); @b{for} Project_Files @b{use} ("a.gpr", "b.gpr", "c.gpr");
end Agg; @b{end} Agg;
@end smallexample @end smallexample
If B or C do not define any main program (through their Main If B or C do not define any main program (through their Main
...@@ -2442,25 +2421,25 @@ make sure all your user have a consistent environment when ...@@ -2442,25 +2421,25 @@ make sure all your user have a consistent environment when
building. The syntax looks like building. The syntax looks like
@smallexample @c projectfile @smallexample @c projectfile
aggregate project Agg is aggregate @b{project} Agg @b{is}
for Project_Files use ("A.gpr", "B.gpr"); @b{for} Project_Files @b{use} ("A.gpr", "B.gpr");
for Project_Path use ("../dir1", "../dir1/dir2"); @b{for} Project_Path @b{use} ("../dir1", "../dir1/dir2");
for External ("BUILD") use "PRODUCTION"; @b{for} External ("BUILD") @b{use} "PRODUCTION";
package Builder is @b{package} Builder @b{is}
for ^Switches^Switches^ ("Ada") use ("-q"); @b{for} Switches ("Ada") @b{use} ("-q");
end Builder; @b{end} Builder;
end Agg; @b{end} Agg;
@end smallexample @end smallexample
One of the often requested features in projects is to be able to One of the often requested features in projects is to be able to
reference external variables in @code{with} statements, as in reference external variables in @code{with} statements, as in
@smallexample @c projectfile @smallexample @c projectfile
with external("SETUP") & "path/prj.gpr"; -- ILLEGAL @b{with} @b{external}("SETUP") & "path/prj.gpr"; --@i{ ILLEGAL}
project MyProject is @b{project} MyProject @b{is}
... ...
end MyProject; @b{end} MyProject;
@end smallexample @end smallexample
For various reasons, this isn't authorized. But using aggregate For various reasons, this isn't authorized. But using aggregate
...@@ -2468,15 +2447,15 @@ projects provide an elegant solution. For instance, you could ...@@ -2468,15 +2447,15 @@ projects provide an elegant solution. For instance, you could
use a project file like: use a project file like:
@smallexample @c projectfile @smallexample @c projectfile
aggregate project Agg is aggregate @b{project} Agg @b{is}
for Project_Path use (external("SETUP") & "path"); @b{for} Project_Path @b{use} (@b{external}("SETUP") & "path");
for Project_Files use ("myproject.gpr"); @b{for} Project_Files @b{use} ("myproject.gpr");
end Agg; @b{end} Agg;
with "prj.gpr"; -- searched on Agg'Project_Path @b{with} "prj.gpr"; --@i{ searched on Agg'Project_Path}
project MyProject is @b{project} MyProject @b{is}
... ...
end MyProject; @b{end} MyProject;
@end smallexample @end smallexample
@c -------------------------------------------- @c --------------------------------------------
...@@ -2586,11 +2565,11 @@ number of system calls that are needed. ...@@ -2586,11 +2565,11 @@ number of system calls that are needed.
Here are a few valid examples: Here are a few valid examples:
@smallexample @c projectfile @smallexample @c projectfile
for Project_Files use ("a.gpr", "subdir/b.gpr"); @b{for} Project_Files @b{use} ("a.gpr", "subdir/b.gpr");
-- two specific projects relative to the directory of agg.gpr --@i{ two specific projects relative to the directory of agg.gpr}
for Project_Files use ("**/*.gpr"); @b{for} Project_Files @b{use} ("**/*.gpr");
-- all projects recursively --@i{ all projects recursively}
@end smallexample @end smallexample
@item @b{Project_Path}: @item @b{Project_Path}:
...@@ -2660,7 +2639,7 @@ Directories are relative to the location of the aggregate project file. ...@@ -2660,7 +2639,7 @@ Directories are relative to the location of the aggregate project file.
Here are a few valid examples: Here are a few valid examples:
@smallexample @c projectfile @smallexample @c projectfile
for Project_Path use ("/usr/local/gpr", "gpr/"); @b{for} Project_Path @b{use} ("/usr/local/gpr", "gpr/");
@end smallexample @end smallexample
@item @b{External}: @item @b{External}:
...@@ -2718,8 +2697,8 @@ an aggregate project. In this package, only the following attributes ...@@ -2718,8 +2697,8 @@ an aggregate project. In this package, only the following attributes
are valid: are valid:
@table @asis @table @asis
@item @b{^Switches^Switches^}: @item @b{Switches}:
@cindex @code{^Switches^Switches^} @cindex @code{Switches}
This attribute gives the list of switches to use for @command{gprbuild}. This attribute gives the list of switches to use for @command{gprbuild}.
Because no mains can be specified for aggregate projects, the only possible Because no mains can be specified for aggregate projects, the only possible
index for attribute @code{Switches} is @code{others}. All other indexes will index for attribute @code{Switches} is @code{others}. All other indexes will
...@@ -2728,7 +2707,7 @@ be ignored. ...@@ -2728,7 +2707,7 @@ be ignored.
Example: Example:
@smallexample @c projectfile @smallexample @c projectfile
for ^Switches^Switches^ (others) use ("-v", "-k", "-j8"); @b{for} Switches (@b{others}) @b{use} ("-v", "-k", "-j8");
@end smallexample @end smallexample
These switches are only read from the main aggregate project (the These switches are only read from the main aggregate project (the
...@@ -2744,8 +2723,8 @@ This attribute gives the list of compiler switches for the various ...@@ -2744,8 +2723,8 @@ This attribute gives the list of compiler switches for the various
languages. For instance, languages. For instance,
@smallexample @c projectfile @smallexample @c projectfile
for Global_Compilation_Switches ("Ada") use ("^O1^-O1^", "-g"); @b{for} Global_Compilation_Switches ("Ada") @b{use} ("O1", "-g");
for Global_Compilation_Switches ("C") use ("^-O2^-O2^"); @b{for} Global_Compilation_Switches ("C") @b{use} ("-O2");
@end smallexample @end smallexample
This attribute is only taken into account in the aggregate project This attribute is only taken into account in the aggregate project
...@@ -2764,57 +2743,57 @@ instance, aggregate project Agg groups the projects A and B, that ...@@ -2764,57 +2743,57 @@ instance, aggregate project Agg groups the projects A and B, that
both depend on C. Here is an extra for all of these projects: both depend on C. Here is an extra for all of these projects:
@smallexample @c projectfile @smallexample @c projectfile
aggregate project Agg is aggregate @b{project} Agg @b{is}
for Project_Files use ("a.gpr", "b.gpr"); @b{for} Project_Files @b{use} ("a.gpr", "b.gpr");
package Builder is @b{package} Builder @b{is}
for Global_Compilation_Switches ("Ada") use ("^-O2^-O2^"); @b{for} Global_Compilation_Switches ("Ada") @b{use} ("-O2");
end Builder; @b{end} Builder;
end Agg; @b{end} Agg;
with "c.gpr"; @b{with} "c.gpr";
project A is @b{project} A @b{is}
package Builder is @b{package} Builder @b{is}
for Global_Compilation_Switches ("Ada") use ("^-O1^-O1^"); @b{for} Global_Compilation_Switches ("Ada") @b{use} ("-O1");
-- ignored --@i{ ignored}
end Builder; @b{end} Builder;
package Compiler is @b{package} Compiler @b{is}
for Default_Switches ("Ada") @b{for} Default_Switches ("Ada")
use ("^-O1^-O1^", "-g"); @b{use} ("-O1", "-g");
for ^Switches^Switches^ ("a_file1.adb") @b{for} Switches ("a_file1.adb")
use ("^-O0^-O0^"); @b{use} ("-O0");
end Compiler; @b{end} Compiler;
end A; @b{end} A;
with "c.gpr"; @b{with} "c.gpr";
project B is @b{project} B @b{is}
package Compiler is @b{package} Compiler @b{is}
for Default_Switches ("Ada") use ("^-O0^-O0^"); @b{for} Default_Switches ("Ada") @b{use} ("-O0");
end Compiler; @b{end} Compiler;
end B; @b{end} B;
project C is @b{project} C @b{is}
package Compiler is @b{package} Compiler @b{is}
for Default_Switches ("Ada") @b{for} Default_Switches ("Ada")
use ("^-O3^-O3^", @b{use} ("-O3",
"^-gnatn^-gnatn^"); "-gnatn");
for ^Switches^Switches^ ("c_file1.adb") @b{for} Switches ("c_file1.adb")
use ("^-O0^-O0^", "-g"); @b{use} ("-O0", "-g");
end Compiler; @b{end} Compiler;
end C; @b{end} C;
@end smallexample @end smallexample
then the following switches are used: then the following switches are used:
@itemize @bullet @itemize @bullet
@item all files from project A except a_file1.adb are compiled @item all files from project A except a_file1.adb are compiled
with "^-O2^-O2^ -g", since the aggregate project has priority. with "-O2 -g", since the aggregate project has priority.
@item the file a_file1.adb is compiled with @item the file a_file1.adb is compiled with
"^-O0^-O0^", since the Compiler.Switches has priority "-O0", since the Compiler.Switches has priority
@item all files from project B are compiled with @item all files from project B are compiled with
"^-O2^-O2^", since the aggregate project has priority "-O2", since the aggregate project has priority
@item all files from C are compiled with "^-O2^-O2^ -gnatn", except for @item all files from C are compiled with "-O2 -gnatn", except for
c_file1.adb which is compiled with "^-O0^-O0^ -g" c_file1.adb which is compiled with "-O0 -g"
@end itemize @end itemize
Even though C is seen through two paths (through A and through Even though C is seen through two paths (through A and through
...@@ -2875,11 +2854,11 @@ For example, we can define an aggregate project Agg that groups A, B ...@@ -2875,11 +2854,11 @@ For example, we can define an aggregate project Agg that groups A, B
and C: and C:
@smallexample @c projectfile @smallexample @c projectfile
aggregate library project Agg is aggregate library @b{project} Agg @b{is}
for Project_Files use ("a.gpr", "b.gpr", "c.gpr"); @b{for} Project_Files @b{use} ("a.gpr", "b.gpr", "c.gpr");
for Library_Name use ("agg"); @b{for} Library_Name @b{use} ("agg");
for Library_Dir use ("lagg"); @b{for} Library_Dir @b{use} ("lagg");
end Agg; @b{end} Agg;
@end smallexample @end smallexample
Then, when you build with: Then, when you build with:
...@@ -2899,16 +2878,16 @@ required to create relocatable object files, a Builder package in the ...@@ -2899,16 +2878,16 @@ required to create relocatable object files, a Builder package in the
aggregate library project may be used: aggregate library project may be used:
@smallexample @c projectfile @smallexample @c projectfile
aggregate library project Agg is aggregate library @b{project} Agg @b{is}
for Project_Files use ("a.gpr", "b.gpr", "c.gpr"); @b{for} Project_Files @b{use} ("a.gpr", "b.gpr", "c.gpr");
for Library_Name use ("agg"); @b{for} Library_Name @b{use} ("agg");
for Library_Dir use ("lagg"); @b{for} Library_Dir @b{use} ("lagg");
for Library_Kind use "relocatable"; @b{for} Library_Kind @b{use} "relocatable";
package Builder is @b{package} Builder @b{is}
for Global_Compilation_Switches ("Ada") use ("-fPIC"); @b{for} Global_Compilation_Switches ("Ada") @b{use} ("-fPIC");
end Builder; @b{end} Builder;
end Agg; @b{end} Agg;
@end smallexample @end smallexample
With the above aggregate library Builder package, the @code{-fPIC} With the above aggregate library Builder package, the @code{-fPIC}
...@@ -2991,8 +2970,8 @@ Project files have an Ada-like syntax. The minimal project file is: ...@@ -2991,8 +2970,8 @@ Project files have an Ada-like syntax. The minimal project file is:
@smallexample @c projectfile @smallexample @c projectfile
@group @group
project Empty is @b{project} Empty @b{is}
end Empty; @b{end} Empty;
@end group @end group
@end smallexample @end smallexample
...@@ -3059,9 +3038,9 @@ in the cycle is a @b{limited with}. ...@@ -3059,9 +3038,9 @@ in the cycle is a @b{limited with}.
@c ??? Need more details here @c ??? Need more details here
@smallexample @c projectfile @smallexample @c projectfile
with "other_project.gpr"; @b{with} "other_project.gpr";
project My_Project extends "extended.gpr" is @b{project} My_Project @b{extends} "extended.gpr" @b{is}
end My_Project; @b{end} My_Project;
@end smallexample @end smallexample
@noindent @noindent
...@@ -3196,28 +3175,28 @@ The following packages are currently supported in project files ...@@ -3196,28 +3175,28 @@ The following packages are currently supported in project files
@item Cross_Reference @item Cross_Reference
This package specifies the options used when calling the library tool This package specifies the options used when calling the library tool
@command{gnatxref} via the @command{gnat} driver. Its attributes @command{gnatxref} via the @command{gnat} driver. Its attributes
@b{Default_Switches} and @b{^Switches^Switches^} have the same semantics as for the @b{Default_Switches} and @b{Switches} have the same semantics as for the
package @code{Builder}. package @code{Builder}.
@ifclear FSFEDITION @ifclear FSFEDITION
@item Eliminate @item Eliminate
This package specifies the options used when calling the tool This package specifies the options used when calling the tool
@command{gnatelim} via the @command{gnat} driver. Its attributes @command{gnatelim} via the @command{gnat} driver. Its attributes
@b{Default_Switches} and @b{^Switches^Switches^} have the same semantics as for the @b{Default_Switches} and @b{Switches} have the same semantics as for the
package @code{Builder}. package @code{Builder}.
@end ifclear @end ifclear
@item Finder @item Finder
This package specifies the options used when calling the search tool This package specifies the options used when calling the search tool
@command{gnatfind} via the @command{gnat} driver. Its attributes @command{gnatfind} via the @command{gnat} driver. Its attributes
@b{Default_Switches} and @b{^Switches^Switches^} have the same semantics as for the @b{Default_Switches} and @b{Switches} have the same semantics as for the
package @code{Builder}. package @code{Builder}.
@item ^Gnatls^Gnatls^ @item Gnatls
This package specifies the options to use when invoking @command{gnatls} This package specifies the options to use when invoking @command{gnatls}
via the @command{gnat} driver. via the @command{gnat} driver.
@ifclear FSFEDITION @ifclear FSFEDITION
@item ^Gnatstub^Gnatstub^ @item Gnatstub
This package specifies the options used when calling the tool This package specifies the options used when calling the tool
@command{gnatstub} via the @command{gnat} driver. Its attributes @command{gnatstub} via the @command{gnat} driver. Its attributes
@b{Default_Switches} and @b{^Switches^Switches^} have the same semantics as for the @b{Default_Switches} and @b{Switches} have the same semantics as for the
package @code{Builder}. package @code{Builder}.
@end ifclear @end ifclear
@item IDE @item IDE
...@@ -3233,7 +3212,7 @@ The following packages are currently supported in project files ...@@ -3233,7 +3212,7 @@ The following packages are currently supported in project files
@item Metrics @item Metrics
This package specifies the options used when calling the tool This package specifies the options used when calling the tool
@command{gnatmetric} via the @command{gnat} driver. Its attributes @command{gnatmetric} via the @command{gnat} driver. Its attributes
@b{Default_Switches} and @b{^Switches^Switches^} have the same semantics as for the @b{Default_Switches} and @b{Switches} have the same semantics as for the
package @code{Builder}. package @code{Builder}.
@end ifclear @end ifclear
@item Naming @item Naming
...@@ -3246,7 +3225,7 @@ The following packages are currently supported in project files ...@@ -3246,7 +3225,7 @@ The following packages are currently supported in project files
@item Pretty_Printer @item Pretty_Printer
This package specifies the options used when calling the formatting tool This package specifies the options used when calling the formatting tool
@command{gnatpp} via the @command{gnat} driver. Its attributes @command{gnatpp} via the @command{gnat} driver. Its attributes
@b{Default_Switches} and @b{^Switches^Switches^} have the same semantics as for the @b{Default_Switches} and @b{Switches} have the same semantics as for the
package @code{Builder}. package @code{Builder}.
@end ifclear @end ifclear
@item Remote @item Remote
...@@ -3255,7 +3234,7 @@ The following packages are currently supported in project files ...@@ -3255,7 +3234,7 @@ The following packages are currently supported in project files
@item Stack @item Stack
This package specifies the options used when calling the tool This package specifies the options used when calling the tool
@command{gnatstack} via the @command{gnat} driver. Its attributes @command{gnatstack} via the @command{gnat} driver. Its attributes
@b{Default_Switches} and @b{^Switches^Switches^} have the same semantics as for the @b{Default_Switches} and @b{Switches} have the same semantics as for the
package @code{Builder}. package @code{Builder}.
@item Synchronize @item Synchronize
This package specifies the options used when calling the tool This package specifies the options used when calling the tool
...@@ -3267,10 +3246,10 @@ In its simplest form, a package may be empty: ...@@ -3267,10 +3246,10 @@ In its simplest form, a package may be empty:
@smallexample @c projectfile @smallexample @c projectfile
@group @group
project Simple is @b{project} Simple @b{is}
package Builder is @b{package} Builder @b{is}
end Builder; @b{end} Builder;
end Simple; @b{end} Simple;
@end group @end group
@end smallexample @end smallexample
...@@ -3376,9 +3355,9 @@ strings is involved, the result of the concatenation is a list of strings. The ...@@ -3376,9 +3355,9 @@ strings is involved, the result of the concatenation is a list of strings. The
following Ada declarations show the existing operators: following Ada declarations show the existing operators:
@smallexample @c ada @smallexample @c ada
function "&" (X : String; Y : String) return String; @b{function} "&" (X : String; Y : String) @b{return} String;
function "&" (X : String_List; Y : String) return String_List; @b{function} "&" (X : String_List; Y : String) @b{return} String_List;
function "&" (X : String_List; Y : String_List) return String_List; @b{function} "&" (X : String_List; Y : String_List) @b{return} String_List;
@end smallexample @end smallexample
@noindent @noindent
...@@ -3386,10 +3365,10 @@ Here are some specific examples: ...@@ -3386,10 +3365,10 @@ Here are some specific examples:
@smallexample @c projectfile @smallexample @c projectfile
@group @group
List := () & File_Name; -- One string in this list List := () & File_Name; --@i{ One string in this list}
List2 := List & (File_Name & ".orig"); -- Two strings List2 := List & (File_Name & ".orig"); --@i{ Two strings}
Big_List := List & Lists2; -- Three strings Big_List := List & Lists2; --@i{ Three strings}
Illegal := "gnat.adc" & List2; -- Illegal, must start with list Illegal := "gnat.adc" & List2; --@i{ Illegal, must start with list}
@end group @end group
@end smallexample @end smallexample
...@@ -3419,9 +3398,9 @@ if present, is the default to use if there is no specification for this ...@@ -3419,9 +3398,9 @@ if present, is the default to use if there is no specification for this
external value either on the command line or in the environment. external value either on the command line or in the environment.
Typically, the external value will either exist in the Typically, the external value will either exist in the
^environment variables^logical name^ environment variables
or be specified on the command line through the or be specified on the command line through the
@option{^-X^/EXTERNAL_REFERENCE=^@emph{vbl}=@emph{value}} switch. If both @option{-X@emph{vbl}=@emph{value}} switch. If both
are specified, then the command line value is used, so that a user can more are specified, then the command line value is used, so that a user can more
easily override the value. easily override the value.
...@@ -3464,14 +3443,14 @@ last separator and the end are components of the string list. ...@@ -3464,14 +3443,14 @@ last separator and the end are components of the string list.
@end smallexample @end smallexample
@noindent @noindent
If the external value is "^-O2^-O2^,-g", If the external value is "-O2,-g",
the result is ("^-O2^-O2^", "-g"). the result is ("-O2", "-g").
If the external value is ",^-O2^-O2^,-g,", If the external value is ",-O2,-g,",
the result is also ("^-O2^-O2^", "-g"). the result is also ("-O2", "-g").
if the external value is "^-gnatv^-gnatv^", if the external value is "-gnatv",
the result is ("^-gnatv^-gnatv^"). the result is ("-gnatv").
If the external value is ",,", the result is (""). If the external value is ",,", the result is ("").
...@@ -3500,7 +3479,7 @@ They may include any graphic characters allowed in Ada, including spaces. ...@@ -3500,7 +3479,7 @@ They may include any graphic characters allowed in Ada, including spaces.
Here is an example of a string type declaration: Here is an example of a string type declaration:
@smallexample @c projectfile @smallexample @c projectfile
type OS is ("NT", "nt", "Unix", "GNU/Linux", "other OS"); @b{type} OS @b{is} ("NT", "nt", "Unix", "GNU/Linux", "other OS");
@end smallexample @end smallexample
@noindent @noindent
...@@ -3555,8 +3534,8 @@ Here are some examples of variable declarations: ...@@ -3555,8 +3534,8 @@ Here are some examples of variable declarations:
@smallexample @c projectfile @smallexample @c projectfile
@group @group
This_OS : OS := external ("OS"); -- a typed variable declaration This_OS : OS := @b{external} ("OS"); --@i{ a typed variable declaration}
That_OS := "GNU/Linux"; -- an untyped variable declaration That_OS := "GNU/Linux"; --@i{ an untyped variable declaration}
Name := "readme.txt"; Name := "readme.txt";
Save_Name := Name & ".saved"; Save_Name := Name & ".saved";
...@@ -3641,23 +3620,23 @@ Here is a typical example: ...@@ -3641,23 +3620,23 @@ Here is a typical example:
@smallexample @c projectfile @smallexample @c projectfile
@group @group
project MyProj is @b{project} MyProj @b{is}
type OS_Type is ("GNU/Linux", "Unix", "NT", "VMS"); @b{type} OS_Type @b{is} ("GNU/Linux", "Unix", "NT", "VMS");
OS : OS_Type := external ("OS", "GNU/Linux"); OS : OS_Type := @b{external} ("OS", "GNU/Linux");
package Compiler is @b{package} Compiler @b{is}
case OS is @b{case} OS @b{is}
when "GNU/Linux" | "Unix" => @b{when} "GNU/Linux" | "Unix" =>
for ^Switches^Switches^ ("Ada") @b{for} Switches ("Ada")
use ("-gnath"); @b{use} ("-gnath");
when "NT" => @b{when} "NT" =>
for ^Switches^Switches^ ("Ada") @b{for} Switches ("Ada")
use ("^-gnatP^-gnatP^"); @b{use} ("-gnatP");
when others => @b{when} @b{others} =>
null; @b{null};
end case; @b{end} @b{case};
end Compiler; @b{end} Compiler;
end MyProj; @b{end} MyProj;
@end group @end group
@end smallexample @end smallexample
...@@ -3680,9 +3659,9 @@ end MyProj; ...@@ -3680,9 +3659,9 @@ end MyProj;
* Package Eliminate Attributes:: * Package Eliminate Attributes::
@end ifclear @end ifclear
* Package Finder Attributes:: * Package Finder Attributes::
* Package ^gnatls^gnatls^ Attributes:: * Package gnatls Attributes::
@ifclear FSFEDITION @ifclear FSFEDITION
* Package ^gnatstub^gnatstub^ Attributes:: * Package gnatstub Attributes::
@end ifclear @end ifclear
* Package IDE Attributes:: * Package IDE Attributes::
* Package Install Attributes:: * Package Install Attributes::
...@@ -3735,20 +3714,20 @@ attribute, and replaces the previous setting. ...@@ -3735,20 +3714,20 @@ attribute, and replaces the previous setting.
Here are some examples of attribute declarations: Here are some examples of attribute declarations:
@smallexample @c projectfile @smallexample @c projectfile
-- simple attributes --@i{ simple attributes}
for Object_Dir use "objects"; @b{for} Object_Dir @b{use} "objects";
for Source_Dirs use ("units", "test/drivers"); @b{for} Source_Dirs @b{use} ("units", "test/drivers");
-- indexed attributes --@i{ indexed attributes}
for Body ("main") use "Main.ada"; @b{for} Body ("main") @b{use} "Main.ada";
for ^Switches^Switches^ ("main.ada") @b{for} Switches ("main.ada")
use ("-v", "^-gnatv^-gnatv^"); @b{use} ("-v", "-gnatv");
for ^Switches^Switches^ ("main.ada") use Builder'Switches ("main.ada") & "-g"; @b{for} Switches ("main.ada") @b{use} Builder'Switches ("main.ada") & "-g";
-- indexed attributes copy (from package Builder in project Default) --@i{ indexed attributes copy (from package Builder in project Default)}
-- The package name must always be specified, even if it is the current --@i{ The package name must always be specified, even if it is the current}
-- package. --@i{ package.}
for Default_Switches use Default.Builder'Default_Switches; @b{for} Default_Switches @b{use} Default.Builder'Default_Switches;
@end smallexample @end smallexample
@noindent @noindent
...@@ -3769,7 +3748,7 @@ attribute_prefix ::= @i{project} ...@@ -3769,7 +3748,7 @@ attribute_prefix ::= @i{project}
Examples are: Examples are:
@smallexample @c projectfile @smallexample @c projectfile
project'Object_Dir @b{project}'Object_Dir
Naming'Dot_Replacement Naming'Dot_Replacement
Imported_Project'Source_Dirs Imported_Project'Source_Dirs
Imported_Project.Naming'Casing Imported_Project.Naming'Casing
...@@ -4248,9 +4227,9 @@ sources of runtime libraries are located. ...@@ -4248,9 +4227,9 @@ sources of runtime libraries are located.
@item @b{Default_Switches}: list, indexed, case-insensitive index @item @b{Default_Switches}: list, indexed, case-insensitive index
Index is a language name. Value is the list of switches to be used when binding Index is a language name. Value is the list of switches to be used when binding
code of the language, if there is no applicable attribute ^Switches^Switches^. code of the language, if there is no applicable attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, @item @b{Switches}: list, optional index, indexed,
case-insensitive index, others allowed case-insensitive index, others allowed
Index is either a language name or a source file name. Value is the list of Index is either a language name or a source file name. Value is the list of
...@@ -4305,7 +4284,7 @@ Index is a language name. Value is the list of builder switches to be used when ...@@ -4305,7 +4284,7 @@ Index is a language name. Value is the list of builder switches to be used when
building an executable of the language, if there is no applicable attribute building an executable of the language, if there is no applicable attribute
Switches. Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is either a language name or a source file name. Value is the list of Index is either a language name or a source file name. Value is the list of
...@@ -4352,9 +4331,9 @@ project tree. ...@@ -4352,9 +4331,9 @@ project tree.
Index is a language name. Value is a list of switches to be used when invoking Index is a language name. Value is a list of switches to be used when invoking
@code{gnatcheck} for a source of the language, if there is no applicable @code{gnatcheck} for a source of the language, if there is no applicable
attribute ^Switches^Switches^. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
...@@ -4368,7 +4347,7 @@ invoking @code{gnatcheck} for the source. ...@@ -4368,7 +4347,7 @@ invoking @code{gnatcheck} for the source.
@itemize @bullet @itemize @bullet
@item @b{^Switches^Switches^}: list @item @b{Switches}: list
Value is a list of switches to be used by the cleaning application. Value is a list of switches to be used by the cleaning application.
...@@ -4411,7 +4390,7 @@ Index is a language name. Value is a list of switches to be used when invoking ...@@ -4411,7 +4390,7 @@ Index is a language name. Value is a list of switches to be used when invoking
the compiler for the language for a source of the project, if there is no the compiler for the language for a source of the project, if there is no
applicable attribute Switches. applicable attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name or a language name. Value is the list of switches Index is a source file name or a language name. Value is the list of switches
...@@ -4645,7 +4624,7 @@ Index is a language name. Value is a list of switches to be used when invoking ...@@ -4645,7 +4624,7 @@ Index is a language name. Value is a list of switches to be used when invoking
@code{gnatxref} for a source of the language, if there is no applicable @code{gnatxref} for a source of the language, if there is no applicable
attribute Switches. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
...@@ -4665,7 +4644,7 @@ Index is a language name. Value is a list of switches to be used when invoking ...@@ -4665,7 +4644,7 @@ Index is a language name. Value is a list of switches to be used when invoking
@code{gnatelim} for a source of the language, if there is no applicable @code{gnatelim} for a source of the language, if there is no applicable
attribute Switches. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
...@@ -4685,7 +4664,7 @@ Index is a language name. Value is a list of switches to be used when invoking ...@@ -4685,7 +4664,7 @@ Index is a language name. Value is a list of switches to be used when invoking
@code{gnatfind} for a source of the language, if there is no applicable @code{gnatfind} for a source of the language, if there is no applicable
attribute Switches. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
...@@ -4693,20 +4672,20 @@ invoking @code{gnatfind} for the source. ...@@ -4693,20 +4672,20 @@ invoking @code{gnatfind} for the source.
@end itemize @end itemize
@node Package ^gnatls^gnatls^ Attributes @node Package gnatls Attributes
@subsubsection Package ^gnatls^gnatls^ Attributes @subsubsection Package gnatls Attributes
@itemize @bullet @itemize @bullet
@item @b{^Switches^Switches^}: list @item @b{Switches}: list
Value is a list of switches to be used when invoking @code{gnatls}. Value is a list of switches to be used when invoking @code{gnatls}.
@end itemize @end itemize
@ifclear FSFEDITION @ifclear FSFEDITION
@node Package ^gnatstub^gnatstub^ Attributes @node Package gnatstub Attributes
@subsubsection Package ^gnatstub^gnatstub^ Attributes @subsubsection Package gnatstub Attributes
@itemize @bullet @itemize @bullet
...@@ -4714,9 +4693,9 @@ Value is a list of switches to be used when invoking @code{gnatls}. ...@@ -4714,9 +4693,9 @@ Value is a list of switches to be used when invoking @code{gnatls}.
Index is a language name. Value is a list of switches to be used when invoking Index is a language name. Value is a list of switches to be used when invoking
@code{gnatstub} for a source of the language, if there is no applicable @code{gnatstub} for a source of the language, if there is no applicable
attribute ^Switches^Switches^. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
...@@ -4764,11 +4743,11 @@ the handling of switches. ...@@ -4764,11 +4743,11 @@ the handling of switches.
Value is a string that specifies the name of the debugger to be used, such as Value is a string that specifies the name of the debugger to be used, such as
gdb, powerpc-wrs-vxworks-gdb or gdb-4. gdb, powerpc-wrs-vxworks-gdb or gdb-4.
@item @b{^gnatlist^gnatlist^}: single @item @b{gnatlist}: single
Value is a string that specifies the name of the @command{^gnatls^gnatls^} utility Value is a string that specifies the name of the @command{gnatls} utility
to be used to retrieve information about the predefined path; for example, to be used to retrieve information about the predefined path; for example,
@code{"^gnatls^gnatls^"}, @code{"powerpc-wrs-vxworks-gnatls"}. @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
@item @b{VCS_Kind}: single @item @b{VCS_Kind}: single
...@@ -4854,7 +4833,7 @@ Index is a source file name or a language name. Value is the list of switches ...@@ -4854,7 +4833,7 @@ Index is a source file name or a language name. Value is the list of switches
to be used at the beginning of the command line when invoking the linker to to be used at the beginning of the command line when invoking the linker to
build an executable for the source or for its language. build an executable for the source or for its language.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name or a language name. Value is the list of switches Index is a source file name or a language name. Value is the list of switches
...@@ -4928,7 +4907,7 @@ Index is a language name. Value is a list of switches to be used when invoking ...@@ -4928,7 +4907,7 @@ Index is a language name. Value is a list of switches to be used when invoking
@code{gnatmetric} for a source of the language, if there is no applicable @code{gnatmetric} for a source of the language, if there is no applicable
attribute Switches. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
...@@ -5018,7 +4997,7 @@ Index is a language name. Value is a list of switches to be used when invoking ...@@ -5018,7 +4997,7 @@ Index is a language name. Value is a list of switches to be used when invoking
@code{gnatpp} for a source of the language, if there is no applicable @code{gnatpp} for a source of the language, if there is no applicable
attribute Switches. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
...@@ -5063,7 +5042,7 @@ Value is the root directory used by the slave machines. ...@@ -5063,7 +5042,7 @@ Value is the root directory used by the slave machines.
@itemize @bullet @itemize @bullet
@item @b{^Switches^Switches^}: list @item @b{Switches}: list
Value is the list of switches to be used when invoking @code{gnatstack}. Value is the list of switches to be used when invoking @code{gnatstack}.
...@@ -5080,11 +5059,10 @@ Index is a language name. Value is a list of switches to be used when invoking ...@@ -5080,11 +5059,10 @@ Index is a language name. Value is a list of switches to be used when invoking
@code{gnatsync} for a source of the language, if there is no applicable @code{gnatsync} for a source of the language, if there is no applicable
attribute Switches. attribute Switches.
@item @b{^Switches^Switches^}: list, optional index, indexed, case-insensitive index, @item @b{Switches}: list, optional index, indexed, case-insensitive index,
others allowed others allowed
Index is a source file name. Value is the list of switches to be used when Index is a source file name. Value is the list of switches to be used when
invoking @code{gnatsync} for the source. invoking @code{gnatsync} for the source.
@end itemize @end itemize
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2003-2013, Free Software Foundation, Inc. -- -- Copyright (C) 2003-2014, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -20,1067 +20,36 @@ ...@@ -20,1067 +20,36 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This utility is used to process the source of gnat_ugn.texi to make a -- This is a temporary version whose only purpose is to work with
-- version suitable for running through standard Texinfo processor. It is -- Makefile.gnat6
-- invoked as follows: -- Its main previous purpose (to handle VMS-specific wording in
-- gnat_ugn.texi and projects.texi) is not applicable, since there is
-- no longer a VMS-specific version of the User's Guide.
-- xgnatugn <target> <in-file> <word-list> [ <out-file> [ <warnings> ] ] -- The program is invoked as follows:
-- 1. <target> is the target type of the manual, which is one of: -- xgnatugn <target> <in-file> <word-list> <out-file>
-- unw Unix and Windows platforms -- In this temporary version, the program simply copies <in-file>
-- vms OpenVMS -- to <out-file> and ignores the <target> and <word-list> arguments
-- 2. <in-file> is the file name of the Texinfo file to be
-- preprocessed.
-- 3. <word-list> is the name of the word list file. This file is used for
-- rewriting the VMS edition. Each line contains a word mapping: The source
-- word in the first column, the target word in the second column. The
-- columns are separated by a '^' character. When preprocessing for VMS, the
-- first word is replaced with the second. (Words consist of letters,
-- digits, and the four characters "?-_~". A sequence of multiple words can
-- be replaced if they are listed in the first column, separated by a single
-- space character. If multiple words are to be replaced, there must be a
-- replacement for each prefix.)
-- 4. <out-file> (optional) is the name of the output file. It defaults to
-- gnat_ugn_unw.texi or gnat_ugn_vms.texi, depending on the target.
-- 5. <warnings> (optional, and allowed only if <out-file> is explicit)
-- can be any string. If present, it indicates that warning messages are
-- to be output to Standard_Error. If absent, no warning messages are
-- generated.
-- The following steps are performed:
-- In VMS mode
-- Any occurrences of ^alpha^beta^ are replaced by beta. The sequence
-- must fit on a single line, and there can only be one occurrence on a
-- line.
-- Any occurrences of a word in the Ug_Words list are replaced by the
-- appropriate vms equivalents. Note that replacements do not occur
-- within ^alpha^beta^ sequences.
-- Any occurrence of [filename].extension, where extension one of the
-- following:
-- "o", "ads", "adb", "ali", "ada", "atb", "ats", "adc", "c"
-- replaced by the appropriate VMS names (all upper case with .o
-- replaced .OBJ). Note that replacements do not occur within
-- ^alpha^beta^ sequences.
-- In UNW mode
-- Any occurrences of ^alpha^beta^ are replaced by alpha. The sequence
-- must fit on a single line.
-- In both modes
-- The sequence ^^^ is replaced by a single ^. This escape sequence
-- must be used if the literal character ^ is to appear in the
-- output. A line containing this escape sequence may not also contain
-- a ^alpha^beta^ sequence.
with Ada.Command_Line; use Ada.Command_Line; with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Spitbol; use GNAT.Spitbol;
with GNAT.Spitbol.Table_VString; use GNAT.Spitbol.Table_VString;
procedure Xgnatugn is procedure Xgnatugn is
procedure Usage; Max_Line_Length : constant := 5000;
-- Print usage information. Invoked if an invalid command line is Line : String (1 .. Max_Line_Length);
-- encountered. Last : Natural;
File1, File2 : File_Type;
subtype Sfile is Ada.Streams.Stream_IO.File_Type;
Output_File : Sfile;
-- The preprocessed output is written to this file
type Input_File is record
Name : VString;
Data : Ada.Text_IO.File_Type;
Line : Natural := 0;
end record;
-- Records information on an input file. Name and Line are used
-- in error messages, Line is updated automatically by Get_Line.
function Get_Line (Input : access Input_File) return String;
-- Returns a line from Input and performs the necessary
-- line-oriented checks (length, character set, trailing spaces).
procedure Put_Line (F : Sfile; S : String);
-- Local version of Put_Line ensures Unix style line endings
First_Time : Boolean := True;
Number_Of_Warnings : Natural := 0;
Number_Of_Errors : Natural := 0;
Warnings_Enabled : Boolean;
procedure Error
(Input : Input_File;
At_Character : Natural;
Message : String);
procedure Error
(Input : Input_File;
Message : String);
-- Prints a message reporting an error on line Input.Line. If
-- At_Character is not 0, indicate the exact character at which
-- the error occurs.
procedure Warning
(Input : Input_File;
At_Character : Natural;
Message : String);
Dictionary_File : aliased Input_File;
procedure Read_Dictionary_File;
-- Dictionary_File is opened using the name given on the command
-- line. It contains the replacements for the Ug_Words list.
-- Read_Dictionary_File reads Dictionary_File and fills the
-- Ug_Words table.
Source_File : aliased Input_File;
procedure Process_Source_File;
-- Source_File is opened using the name given on the command line.
-- It contains the Texinfo source code. Process_Source_File
-- performs the necessary replacements.
type Flag_Type is (UNW, VMS, FSFEDITION, PROEDITION, GPLEDITION);
-- The flags permitted in @ifset or @ifclear commands:
--
-- Targets for preprocessing
-- UNW (Unix and Windows) or VMS
--
-- Editions of the manual
-- FSFEDITION, PROEDITION, or GPLEDITION
--
-- Conditional commands for target are processed by xgnatugn
--
-- Conditional commands for edition are passed through unchanged
subtype Target_Type is Flag_Type range UNW .. VMS;
Target : Target_Type;
-- The Target variable is initialized using the command line
Valid_Characters : constant Character_Set := To_Set (Span => (' ', '~'));
-- This array controls which characters are permitted in the input
-- file (after line breaks have been removed). Valid characters
-- are all printable ASCII characters and the space character.
Word_Characters : constant Character_Set :=
(To_Set (Ranges =>
(('0', '9'), ('a', 'z'), ('A', 'Z')))
or To_Set ("?-_~"));
-- The characters which are permitted in words. Other (valid)
-- characters are assumed to be delimiters between words. Note that
-- this set has to include all characters of the source words of the
-- Ug_Words dictionary.
Reject_Trailing_Spaces : constant Boolean := True;
-- Controls whether Xgnatug rejects superfluous space characters
-- at the end of lines.
Maximum_Line_Length : constant Positive := 79;
Fatal_Line_Length_Limit : constant Positive := 5000;
Fatal_Line_Length : exception;
-- If Maximum_Line_Length is exceeded in an input file, an error
-- message is printed. If Fatal_Line_Length is exceeded,
-- execution terminates with a Fatal_Line_Length exception.
VMS_Escape_Character : constant Character := '^';
-- The character used to mark VMS alternatives (^alpha^beta^)
Extensions : GNAT.Spitbol.Table_VString.Table (20);
procedure Initialize_Extensions;
-- This table records extensions and their replacement for
-- rewriting filenames in the VMS version of the manual.
function Is_Extension (Extension : String) return Boolean;
function Get_Replacement_Extension (Extension : String) return String;
-- These functions query the replacement table. Is_Extension
-- checks if the given string is a known extension.
-- Get_Replacement returns the replacement extension.
Ug_Words : GNAT.Spitbol.Table_VString.Table (200);
function Is_Known_Word (Word : String) return Boolean;
function Get_Replacement_Word (Word : String) return String;
-- The Ug_Words table lists replacement words for the VMS version
-- of the manual. Is_Known_Word and Get_Replacement_Word query
-- this table. The table is filled using Read_Dictionary_File.
function Rewrite_Source_Line (Line : String) return String;
-- This subprogram takes a line and rewrites it according to Target.
-- It relies on information in Source_File to generate error messages.
-----------
-- Usage --
-----------
procedure Usage is
begin
Put_Line (Standard_Error,
"usage: xgnatugn TARGET SOURCE DICTIONARY [OUTFILE [WARNINGS]]");
New_Line;
Put_Line (Standard_Error, "TARGET is one of:");
for T in Target_Type'Range loop
Put_Line (Standard_Error, " " & Target_Type'Image (T));
end loop;
New_Line;
Put_Line (Standard_Error, "SOURCE is the source file to process.");
New_Line;
Put_Line (Standard_Error, "DICTIONARY is the name of a file "
& "that contains word replacements");
Put_Line (Standard_Error, "for the VMS version.");
New_Line;
Put_Line (Standard_Error,
"OUT-FILE, if present, is the output file to be created;");
Put_Line (Standard_Error,
"If OUT-FILE is absent, the output file is either " &
"gnat_ugn_unw.texi, ");
Put_Line (Standard_Error,
"or gnat_ugn_vms.texi, depending on TARGET.");
New_Line;
Put_Line (Standard_Error,
"WARNINGS, if present, is any string;");
Put_Line (Standard_Error,
"it will result in warning messages (e.g., line too long))");
Put_Line (Standard_Error,
"being output to Standard_Error.");
end Usage;
--------------
-- Get_Line --
--------------
function Get_Line (Input : access Input_File) return String is
Line_Buffer : String (1 .. Fatal_Line_Length_Limit);
Last : Natural;
begin
Input.Line := Input.Line + 1;
Get_Line (Input.Data, Line_Buffer, Last);
if Last = Line_Buffer'Last then
Error (Input.all, "line exceeds fatal line length limit");
raise Fatal_Line_Length;
end if;
declare
Line : String renames Line_Buffer (Line_Buffer'First .. Last);
begin
for J in Line'Range loop
if not Is_In (Line (J), Valid_Characters) then
Error (Input.all, J, "invalid character");
exit;
end if;
end loop;
if Line'Length > Maximum_Line_Length then
Warning (Input.all, Maximum_Line_Length + 1, "line too long");
end if;
if Reject_Trailing_Spaces
and then Line'Length > 0
and then Line (Line'Last) = ' '
then
Error (Input.all, Line'Last, "trailing space character");
end if;
return Trim (Line, Right);
end;
end Get_Line;
--------------
-- Put_Line --
--------------
procedure Put_Line (F : Sfile; S : String) is
begin
String'Write (Stream (F), S);
Character'Write (Stream (F), ASCII.LF);
end Put_Line;
-----------
-- Error --
-----------
procedure Error
(Input : Input_File;
Message : String)
is
begin
Error (Input, 0, Message);
end Error;
procedure Error
(Input : Input_File;
At_Character : Natural;
Message : String)
is
Line_Image : constant String := Integer'Image (Input.Line);
At_Character_Image : constant String := Integer'Image (At_Character);
-- These variables are required because we have to drop the leading
-- space character.
begin
Number_Of_Errors := Number_Of_Errors + 1;
if At_Character > 0 then
Put_Line (Standard_Error,
S (Input.Name) & ':'
& Line_Image (Line_Image'First + 1 .. Line_Image'Last) & ':'
& At_Character_Image (At_Character_Image'First + 1
.. At_Character_Image'Last)
& ": "
& Message);
else
Put_Line (Standard_Error,
S (Input.Name) & ':'
& Line_Image (Line_Image'First + 1 .. Line_Image'Last)
& ": "
& Message);
end if;
end Error;
-------------
-- Warning --
-------------
procedure Warning
(Input : Input_File;
At_Character : Natural;
Message : String)
is
Line_Image : constant String := Integer'Image (Input.Line);
At_Character_Image : constant String := Integer'Image (At_Character);
-- These variables are required because we have to drop the leading
-- space character.
begin
if not Warnings_Enabled then
return;
end if;
Number_Of_Warnings := Number_Of_Warnings + 1;
if At_Character > 0 then
Put_Line (Standard_Error,
S (Input.Name) & ':'
& Line_Image (Line_Image'First + 1 .. Line_Image'Last) & ':'
& At_Character_Image (At_Character_Image'First + 1
.. At_Character_Image'Last)
& ": warning: "
& Message);
else
Put_Line (Standard_Error,
S (Input.Name) & ':'
& Line_Image (Line_Image'First + 1 .. Line_Image'Last)
& ": warning: "
& Message);
end if;
end Warning;
--------------------------
-- Read_Dictionary_File --
--------------------------
procedure Read_Dictionary_File is
begin
while not End_Of_File (Dictionary_File.Data) loop
declare
Line : constant String :=
Get_Line (Dictionary_File'Access);
Split : constant Natural :=
Index (Line, (1 => VMS_Escape_Character));
begin
if Line'Length = 0 then
Error (Dictionary_File, "empty line in dictionary file");
elsif Line (Line'First) = ' ' then
Error (Dictionary_File, 1, "line starts with space character");
elsif Split = 0 then
Error (Dictionary_File, "line does not contain "
& VMS_Escape_Character & " character");
else
declare
Source : constant String :=
Trim (Line (1 .. Split - 1), Both);
Target : constant String :=
Trim (Line (Split + 1 .. Line'Last), Both);
Two_Spaces : constant Natural := Index (Source, " ");
Non_Word_Character : constant Natural :=
Index (Source,
Word_Characters or
To_Set (" ."),
Outside);
begin
if Two_Spaces /= 0 then
Error (Dictionary_File, Two_Spaces,
"multiple space characters in source word");
end if;
if Non_Word_Character /= 0 then
Error (Dictionary_File, Non_Word_Character,
"illegal character in source word");
end if;
if Source'Length = 0 then
Error (Dictionary_File, "source is empty");
elsif Target'Length = 0 then
Error (Dictionary_File, "target is empty");
else
Set (Ug_Words, Source, V (Target));
-- Ensure that if Source is a sequence of words
-- "WORD1 WORD2 ...", we already have a mapping for
-- "WORD1".
for J in Source'Range loop
if Source (J) = ' ' then
declare
Prefix : String renames
Source (Source'First .. J - 1);
begin
if not Is_Known_Word (Prefix) then
Error (Dictionary_File,
"prefix '" & Prefix
& "' not known at this point");
end if;
end;
end if;
end loop;
end if;
end;
end if;
end;
end loop;
end Read_Dictionary_File;
-------------------------
-- Rewrite_Source_Line --
-------------------------
function Rewrite_Source_Line (Line : String) return String is
-- We use a simple lexer to split the line into tokens:
-- Word consisting entirely of Word_Characters
-- VMS_Alternative ^alpha^beta^ replacement (but not ^^^)
-- Space a space character
-- Other everything else (sequence of non-word characters)
-- VMS_Error incomplete VMS alternative
-- End_Of_Line no more characters on this line
-- A sequence of three VMS_Escape_Characters is automatically
-- collapsed to an Other token.
type Token_Span is record
First, Last : Positive;
end record;
-- The character range covered by a token in Line
type Token_Kind is (End_Of_Line, Word, Other,
VMS_Alternative, VMS_Error);
type Token_Record (Kind : Token_Kind := End_Of_Line) is record
First : Positive;
case Kind is
when Word | Other =>
Span : Token_Span;
when VMS_Alternative =>
Non_VMS, VMS : Token_Span;
when VMS_Error | End_Of_Line =>
null;
end case;
end record;
Input_Position : Positive := Line'First;
Token : Token_Record;
-- The position of the next character to be processed by Next_Token
procedure Next_Token;
-- Returns the next token in Line, starting at Input_Position
Rewritten_Line : VString;
-- Collects the line as it is rewritten
procedure Rewrite_Word;
-- The current token is assumed to be a Word. When processing the VMS
-- version of the manual, additional tokens are gathered to check if
-- we have a file name or a sequence of known words.
procedure Maybe_Rewrite_Extension;
-- The current token is assumed to be Other. When processing the VMS
-- version of the manual and the token represents a single dot ".",
-- the following word is rewritten according to the rules for
-- extensions.
VMS_Token_Seen : Boolean := False;
-- This is set to true if a VMS_Alternative has been encountered, or a
-- ^^^ token.
----------------
-- Next_Token --
----------------
procedure Next_Token is
Remaining_Line : String renames Line (Input_Position .. Line'Last);
Last_Character : Natural;
begin
if Remaining_Line'Length = 0 then
Token := (End_Of_Line, Remaining_Line'First);
return;
end if;
-- ^alpha^beta^, the VMS_Alternative case
if Remaining_Line (Remaining_Line'First) = VMS_Escape_Character then
declare
VMS_Second_Character, VMS_Third_Character : Natural;
begin
if VMS_Token_Seen then
Error (Source_File, Remaining_Line'First,
"multiple " & VMS_Escape_Character
& " characters on a single line");
else
VMS_Token_Seen := True;
end if;
-- Find the second and third escape character. If one of
-- them is not present, generate an error token.
VMS_Second_Character :=
Index (Remaining_Line (Remaining_Line'First + 1
.. Remaining_Line'Last),
(1 => VMS_Escape_Character));
if VMS_Second_Character = 0 then
Input_Position := Remaining_Line'Last + 1;
Token := (VMS_Error, Remaining_Line'First);
return;
end if;
VMS_Third_Character :=
Index (Remaining_Line (VMS_Second_Character + 1
.. Remaining_Line'Last),
(1 => VMS_Escape_Character));
if VMS_Third_Character = 0 then
Input_Position := Remaining_Line'Last + 1;
Token := (VMS_Error, Remaining_Line'First);
return;
end if;
-- Consume all the characters we are about to include in
-- the token.
Input_Position := VMS_Third_Character + 1;
-- Check if we are in a ^^^ situation, and return an Other
-- token in this case.
if Remaining_Line'First + 1 = VMS_Second_Character
and then Remaining_Line'First + 2 = VMS_Third_Character
then
Token := (Other, Remaining_Line'First,
(Remaining_Line'First, Remaining_Line'First));
return;
end if;
Token := (VMS_Alternative, Remaining_Line'First,
(Remaining_Line'First + 1, VMS_Second_Character - 1),
(VMS_Second_Character + 1, VMS_Third_Character - 1));
return;
end;
end if;
-- The Word case. Search for characters not in Word_Characters.
-- We have found a word if the first non-word character is not
-- the first character in Remaining_Line, i.e. if Remaining_Line
-- starts with a word character.
Last_Character := Index (Remaining_Line, Word_Characters, Outside);
if Last_Character /= Remaining_Line'First then
-- If we haven't found a character which is not in
-- Word_Characters, all remaining characters are part of the
-- current Word token.
if Last_Character = 0 then
Last_Character := Remaining_Line'Last + 1;
end if;
Input_Position := Last_Character;
Token := (Word, Remaining_Line'First,
(Remaining_Line'First, Last_Character - 1));
return;
end if;
-- Remaining characters are in the Other category. To speed
-- up processing, we collect them together if there are several
-- of them.
Input_Position := Last_Character + 1;
Token := (Other,
Remaining_Line'First,
(Remaining_Line'First, Last_Character));
end Next_Token;
------------------
-- Rewrite_Word --
------------------
procedure Rewrite_Word is
First_Word : String
renames Line (Token.Span.First .. Token.Span.Last);
begin
-- We do not perform any error checking below, so we can just skip
-- all processing for the non-VMS version.
if Target /= VMS then
Append (Rewritten_Line, First_Word);
Next_Token;
return;
end if;
if Is_Known_Word (First_Word) then
-- If we have a word from the dictionary, we look for the
-- longest possible sequence we can rewrite.
declare
Seq : Token_Span := Token.Span;
Lost_Space : Boolean := False;
begin
Next_Token;
loop
if Token.Kind = Other
and then Line (Token.Span.First .. Token.Span.Last) = " "
then
Next_Token;
if Token.Kind /= Word
or else not Is_Known_Word (Line (Seq.First
.. Token.Span.Last))
then
-- When we reach this point, the following conditions
-- are true:
-- Seq is a known word
-- The previous token was a space character
-- Seq extended to the current token is not a
-- known word.
Lost_Space := True;
exit;
else
-- Extend Seq to cover the current (known) word
Seq.Last := Token.Span.Last;
Next_Token;
end if;
else
-- When we reach this point, the following conditions
-- are true:
-- Seq is a known word
-- The previous token was a word
-- The current token is not a space character.
exit;
end if;
end loop;
-- Rewrite Seq, and add the lost space if necessary
Append (Rewritten_Line,
Get_Replacement_Word (Line (Seq.First .. Seq.Last)));
if Lost_Space then
Append (Rewritten_Line, ' ');
end if;
-- The unknown token will be processed during the
-- next iteration of the main loop.
return;
end;
end if;
Next_Token;
if Token.Kind = Other
and then Line (Token.Span.First .. Token.Span.Last) = "."
then
-- Deal with extensions
Next_Token;
if Token.Kind = Word
and then
Is_Extension (Line (Token.Span.First .. Token.Span.Last))
then
-- We have discovered a file extension. Convert the file
-- name to upper case.
Append (Rewritten_Line,
Translate (First_Word, Upper_Case_Map) & '.');
Append (Rewritten_Line,
Get_Replacement_Extension
(Line (Token.Span.First .. Token.Span.Last)));
Next_Token;
else
-- We already have: Word ".", followed by an unknown token
Append (Rewritten_Line, First_Word & '.');
-- The unknown token will be processed during the next
-- iteration of the main loop.
end if;
else
-- We have an unknown Word, followed by an unknown token.
-- The unknown token will be processed by the outer loop.
Append (Rewritten_Line, First_Word);
end if;
end Rewrite_Word;
-----------------------------
-- Maybe_Rewrite_Extension --
-----------------------------
procedure Maybe_Rewrite_Extension is
begin
-- Again, we need no special processing in the non-VMS case
if Target = VMS
and then Line (Token.Span.First .. Token.Span.Last) = "."
then
-- This extension is not preceded by a word, otherwise
-- Rewrite_Word would have handled it.
Next_Token;
if Token.Kind = Word
and then Is_Extension (Line (Token.Span.First
.. Token.Span.Last))
then
Append (Rewritten_Line, '.' & Get_Replacement_Extension
(Line (Token.Span.First .. Token.Span.Last)));
Next_Token;
else
Append (Rewritten_Line, '.');
end if;
else
Append (Rewritten_Line, Line (Token.Span.First
.. Token.Span.Last));
Next_Token;
end if;
end Maybe_Rewrite_Extension;
-- Start of processing for Process_Source_Line
begin
-- The following parser recognizes the following special token
-- sequences:
-- Word "." Word rewrite as file name if second word is extension
-- Word " " Word rewrite as a single word using Ug_Words table
Next_Token;
loop
case Token.Kind is
when End_Of_Line =>
exit;
when Word =>
Rewrite_Word;
when Other =>
Maybe_Rewrite_Extension;
when VMS_Alternative =>
if Target = VMS then
Append (Rewritten_Line, Line (Token.VMS.First
.. Token.VMS.Last));
else
Append (Rewritten_Line, Line (Token.Non_VMS.First
.. Token.Non_VMS.Last));
end if;
Next_Token;
when VMS_Error =>
Error (Source_File, Token.First, "invalid VMS alternative");
Next_Token;
end case;
end loop;
return S (Rewritten_Line);
end Rewrite_Source_Line;
-------------------------
-- Process_Source_File --
-------------------------
procedure Process_Source_File is
begin
while not End_Of_File (Source_File.Data) loop
declare
Line : constant String := Get_Line (Source_File'Access);
Rewritten : constant String := Rewrite_Source_Line (Line);
-- We unconditionally rewrite the line so that we can check the
-- syntax of all lines, and not only those which are actually
-- included in the output.
begin
if First_Time
and then Line'Length > 3 and then Line (1 .. 3) = "@if"
then
Put_Line (Output_File, "@set " & Argument (1));
First_Time := False;
end if;
Put_Line (Output_File, Rewritten);
end;
end loop;
end Process_Source_File;
---------------------------
-- Initialize_Extensions --
---------------------------
procedure Initialize_Extensions is
procedure Add (Extension : String);
-- Adds an extension which is replaced with itself (in upper case)
procedure Add (Extension, Replacement : String);
-- Adds an extension with a custom replacement
---------
-- Add --
---------
procedure Add (Extension : String) is
begin
Add (Extension, Translate (Extension, Upper_Case_Map));
end Add;
procedure Add (Extension, Replacement : String) is
begin
Set (Extensions, Extension, V (Replacement));
end Add;
-- Start of processing for Initialize_Extensions
begin
-- To avoid performance degradation, increase the constant in the
-- definition of Extensions above if you add more extensions here.
Add ("o", "OBJ");
Add ("ads");
Add ("adb");
Add ("ali");
Add ("ada");
Add ("atb");
Add ("ats");
Add ("adc");
Add ("c");
end Initialize_Extensions;
------------------
-- Is_Extension --
------------------
function Is_Extension (Extension : String) return Boolean is
begin
return Present (Extensions, Extension);
end Is_Extension;
-------------------------------
-- Get_Replacement_Extension --
-------------------------------
function Get_Replacement_Extension (Extension : String) return String is
begin
return S (Get (Extensions, Extension));
end Get_Replacement_Extension;
-------------------
-- Is_Known_Word --
-------------------
function Is_Known_Word (Word : String) return Boolean is
begin
return Present (Ug_Words, Word);
end Is_Known_Word;
--------------------------
-- Get_Replacement_Word --
--------------------------
function Get_Replacement_Word (Word : String) return String is
begin
return S (Get (Ug_Words, Word));
end Get_Replacement_Word;
-- Start of processing for Xgnatugn
Valid_Command_Line : Boolean;
Output_File_Name : VString;
begin begin
Initialize_Extensions;
Valid_Command_Line := Argument_Count in 3 .. 5;
-- First argument: Target
if Valid_Command_Line then
begin
Target := Flag_Type'Value (Argument (1));
if not Target'Valid then
Valid_Command_Line := False;
end if;
exception
when Constraint_Error =>
Valid_Command_Line := False;
end;
end if;
-- Second argument: Source_File
if Valid_Command_Line then
begin
Source_File.Name := V (Argument (2));
Open (Source_File.Data, In_File, Argument (2));
exception
when Ada.Text_IO.Name_Error =>
Valid_Command_Line := False;
end;
end if;
-- Third argument: Dictionary_File
if Valid_Command_Line then
begin
Dictionary_File.Name := V (Argument (3));
Open (Dictionary_File.Data, In_File, Argument (3));
exception
when Ada.Text_IO.Name_Error =>
Valid_Command_Line := False;
end;
end if;
-- Fourth argument: Output_File
if Valid_Command_Line then
if Argument_Count in 4 .. 5 then
Output_File_Name := V (Argument (4));
else
case Target is
when UNW =>
Output_File_Name := V ("gnat_ugn_unw.texi");
when VMS =>
Output_File_Name := V ("gnat_ugn_vms.texi");
end case;
end if;
Warnings_Enabled := Argument_Count = 5;
begin
Create (Output_File, Out_File, S (Output_File_Name));
exception
when Ada.Text_IO.Name_Error | Ada.Text_IO.Use_Error =>
Valid_Command_Line := False;
end;
end if;
if not Valid_Command_Line then
Usage;
Set_Exit_Status (Failure);
else
Read_Dictionary_File;
Close (Dictionary_File.Data);
-- Main processing starts here
Process_Source_File;
Close (Output_File);
Close (Source_File.Data);
New_Line (Standard_Error);
if Number_Of_Warnings = 0 then
Put_Line (Standard_Error, " NO Warnings");
else
Put (Standard_Error, Integer'Image (Number_Of_Warnings));
Put (Standard_Error, " Warning");
if Number_Of_Warnings > 1 then
Put (Standard_Error, "s");
end if;
New_Line (Standard_Error);
end if;
if Number_Of_Errors = 0 then
Put_Line (Standard_Error, " NO Errors");
else
Put (Standard_Error, Integer'Image (Number_Of_Errors));
Put (Standard_Error, " Error");
if Number_Of_Errors > 1 then
Put (Standard_Error, "s");
end if;
New_Line (Standard_Error); Open (File1, Mode => In_File, Name => Argument (2));
end if; Create (File2, Mode => Out_File, Name => Argument (4));
if Number_Of_Errors /= 0 then while not End_Of_File (File1) loop
Set_Exit_Status (Failure); Get_Line (File1, Line, Last);
else Put_Line (File2, Line (1 .. Last));
Set_Exit_Status (Success); end loop;
end if;
end if;
end Xgnatugn; end Xgnatugn;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment