Between normal Ada projects, everything works as you describe (and as expected).
However, in the special case where project B, instead of transforming Ada files into .o files, transforms other kind of files into Ada files that are with-ed by units of project A, things get off the road: project A doesn't see out-of-date Ada files produced by project B.
Here is a full example. Files are reproduced below (they are meant to land into the same directory).
Then you do the following commands:
gprbuild -P fuzzy_gen.gpr
gprbuild -P code_generation.gpr
gnatstudio -P main.gpr
First build launched from GNAT Studio does the following on my machine:
Compile
[Ada] main.adb
[Fuzzy] x789.cfg
Ada file "fuzzy_x789.adb" is up to date
[Fuzzy] x456.cfg
Ada file "fuzzy_x456.adb" is up to date
[Fuzzy] x123.cfg
Ada file "fuzzy_x123.adb" is up to date
[Ada] fuzzy_x123.adb
[Ada] fuzzy_x456.adb
[Ada] fuzzy_x789.adb
Bind
[gprbind] main.bexch
[Ada] main.ali
Link
[link] main.adb
Second build has an expected output as well:
Compile
[Fuzzy] x789.cfg
Ada file "fuzzy_x789.adb" is up to date
[Fuzzy] x456.cfg
Ada file "fuzzy_x456.adb" is up to date
[Fuzzy] x123.cfg
Ada file "fuzzy_x123.adb" is up to date
gprbuild: "main.exe" up to date
Now, say you modify x123.cfg and save it.
Compile
[Fuzzy] x789.cfg
Ada file "fuzzy_x789.adb" is up to date
[Fuzzy] x456.cfg
Ada file "fuzzy_x456.adb" is up to date
[Fuzzy] x123.cfg
Converting "x123.cfg" into "fuzzy_x123.adb"...
gprbuild: "main.exe" up to date
That's *not* what I would like: gprbuild did not detect the out-of-date file "fuzzy_x123.adb" in time.
A second call to gprbuild compiles the changed "fuzzy_x123.adb" and all is well, but it is one step too late.
The files
=========
1) The code generator
=====================
fuzzy_gen.gpr:
-------------
project Fuzzy_Gen is
for Object_Dir use "obj";
for Exec_Dir use "gen";
for Create_Missing_Dirs use "True";
for Main use ("fuzzy_gen.adb");
end Fuzzy_Gen;
fuzzy_gen.adb:
-------------
with Ada.Calendar,
Ada.Command_Line,
Ada.Directories,
Ada.Text_IO;
procedure Fuzzy_Gen is
use Ada.Command_Line, Ada.Directories, Ada.Text_IO;
procedure Convert (arg : String) is
cfg : constant String := Simple_Name (arg);
cfg_file_name : constant String := "../" & cfg;
ada_unit_name : constant String :=
"fuzzy_" & cfg (cfg'First .. cfg'Last - 4);
ada_file_name : constant String := ada_unit_name & ".adb";
cfg_in, ada_out : File_Type;
use type Ada.Calendar.Time;
begin
if Exists (ada_file_name) and then
Modification_Time (ada_file_name) >=
Modification_Time (cfg_file_name)
then
Put_Line ("Ada file """ & ada_file_name & """ is up to date");
return;
end if;
Put_Line
("Converting """ & cfg & """ into """ & ada_file_name & """...");
Open (cfg_in, In_File, cfg_file_name);
Create (ada_out, Out_File, ada_file_name);
Put_Line
(ada_out, "function " & ada_unit_name & " return String is");
Put_Line (ada_out, "begin");
Put_Line (ada_out, " return """ & Get_Line (cfg_in) & """;");
Put_Line (ada_out, "end;");
Close (cfg_in);
Close (ada_out);
end Convert;
begin
if Argument_Count = 0 then
Put_Line (Current_Error, "config file name missing");
else
Convert (Argument (1));
end if;
end Fuzzy_Gen;
2) The project that generates Ada files ("project B")
=====================================================
code_generation.gpr:
-------------------
project Code_Generation is
for Languages use ("Fuzzy");
for Source_Dirs use (".");
for Object_Dir use "gen";
for Objects_Linked ("Fuzzy") use "False";
package Naming is
for Body_Suffix ("Fuzzy") use ".cfg";
end Naming;
package Compiler is
for Driver ("Fuzzy") use "fuzzy_gen";
end Compiler;
end Code_Generation;
x123.cfg:
--------
123
x456.cfg:
--------
456
x789.cfg:
--------
789
3) The main project (project A)
===============================
main.gpr:
--------
with "code_generation.gpr";
project Main is
for Source_Dirs use (".", "gen");
for Object_Dir use "obj";
for Create_Missing_Dirs use "True";
for Main use ("main.adb");
end Main;
main.adb:
--------
with Ada.Text_IO;
with Fuzzy_X123,
Fuzzy_X456,
Fuzzy_X789;
procedure Main is
begin
Ada.Text_IO.Put
("Messages from elsewhere:" &
" """ & Fuzzy_X123 & '"' &
" """ & Fuzzy_X456 & '"' &
" """ & Fuzzy_X789 & '"');
end;