ada-mode: Use multiple GNAT project files
6.5 Use multiple GNAT project files
===================================
In this example, we show how to use multiple GNAT project files,
specifying the GNAT project search path in an Ada mode project file.
Create the directory ‘Example_4’ as specified in Use GNAT
project file.
Create the directory ‘Example_5’, containing:
‘hello_5.adb’:
with Hello_Pkg;
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello_5
is begin
Hello_Pkg.Say_Hello;
Put_Line ("From hello_5");
end Hello_5;
There are no errors in this file.
‘hello_5.adp’:
ada_project_path=../Example_4/Gnat_Project
gpr_file=hello_5.gpr
‘hello_5.gpr’:
with "hello_4";
Project Hello_5 is
for Source_Dirs use (".");
package Compiler is
for Default_Switches ("Ada") use ("-g", "-gnatyt");
end Compiler;
end Hello_5;
In buffer ‘hello_5.adb’, invoke ‘Ada | Project | Load...’, and select
‘Example_5/hello_5.adp’.
Then, again in ‘hello_5.adb’, invoke ‘Ada | Set main and Build’. You
should get a ‘*compilation*’ buffer containing something like (the
directory paths will be different):
cd c:/Examples/Example_5/
gnatmake -o hello_5 hello_5 -Phello_5.gpr -g -cargs -gnatq -gnatQ -bargs -largs
gcc -c -g -gnatyt -g -gnatq -gnatQ -I- -gnatA c:\Examples\Example_5\hello_5.adb
gcc -c -g -gnatyt -g -gnatq -gnatQ -I- -gnatA c:\Examples\Example_4\hello_pkg.adb
hello_pkg.adb:2:08: keyword "body" expected here [see file name]
gnatmake: "c:\examples\example_4\hello_pkg.adb" compilation error
Now type ‘C-x `’. ‘Example_4/hello_pkg.adb’ is shown, demonstrating
that ‘hello_5.gpr’ and ‘hello_4.gpr’ are being used to set the
compilation search path.