comp.lang.ada
 help / color / mirror / Atom feed
* gpr and Makefiles
@ 2020-01-27 16:22 mockturtle
  2020-01-27 17:49 ` Shark8
  0 siblings, 1 reply; 7+ messages in thread
From: mockturtle @ 2020-01-27 16:22 UTC (permalink / raw)


Dear.all, 
I have a question about the interaction between gprbuild and Makefile. I googled a bit and found mostly how to use gprbuild inside a Makefile, but, in a sense, I am interested in the other way around.

More precisely, among all my source files there is one package (say, foo.ads) that it is actually generated by an external file (say, bar.txt) using an utility (call it "convert").  The matter is a bit more complex, but this is the core of the issue.  

I can express the dependency between foo.ads and bar.txt in a Makefile like

foo.ads: bar.txt
       convert --from=bar.txt --to=foo.ads

What I would like is having gprbuild checking if bar.txt is newer than foo.ads; if it is, run convert and after that proceed with the actual building.

Is this possible?

I also checked Gem #152 (https://www.adacore.com/gems/gem-152-defining-a-new-language-in-a-project-file) about defining a new language inside a gpr file, but I am not sure it can be a solution.

Thank you in advance for your help

Riccardo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gpr and Makefiles
  2020-01-27 16:22 gpr and Makefiles mockturtle
@ 2020-01-27 17:49 ` Shark8
  2020-01-27 19:32   ` mockturtle
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Shark8 @ 2020-01-27 17:49 UTC (permalink / raw)


On Monday, January 27, 2020 at 9:22:41 AM UTC-7, mockturtle wrote:
> 
> foo.ads: bar.txt
>        convert --from=bar.txt --to=foo.ads
> 
> What I would like is having gprbuild checking if bar.txt is newer than foo.ads; if it is, run convert and after that proceed with the actual building.
> 
> Is this possible?
> 
> I also checked Gem #152 (https://www.adacore.com/gems/gem-152-defining-a-new-language-in-a-project-file) about defining a new language inside a gpr file, but I am not sure it can be a solution.
Why not?
Wouldn't you just use

Package Compiler is
  for Driver ("Converter") use "convert";
  for Object_Generated ("Converter") use "False";
  --...
End Compiler;


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gpr and Makefiles
  2020-01-27 17:49 ` Shark8
@ 2020-01-27 19:32   ` mockturtle
  2020-01-27 19:46   ` Simon Wright
  2020-01-27 20:28   ` mockturtle
  2 siblings, 0 replies; 7+ messages in thread
From: mockturtle @ 2020-01-27 19:32 UTC (permalink / raw)


On Monday, January 27, 2020 at 6:49:38 PM UTC+1, Shark8 wrote:
> On Monday, January 27, 2020 at 9:22:41 AM UTC-7, mockturtle wrote:
> > 
> > foo.ads: bar.txt
> >        convert --from=bar.txt --to=foo.ads
> > 
> > What I would like is having gprbuild checking if bar.txt is newer than foo.ads; if it is, run convert and after that proceed with the actual building.
> > 
> > Is this possible?
> > 
> > I also checked Gem #152 (https://www.adacore.com/gems/gem-152-defining-a-new-language-in-a-project-file) about defining a new language inside a gpr file, but I am not sure it can be a solution.
> Why not?
> Wouldn't you just use
> 
> Package Compiler is
>   for Driver ("Converter") use "convert";
>   for Object_Generated ("Converter") use "False";
>   --...
> End Compiler;

Hmmm... I'll try.  


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gpr and Makefiles
  2020-01-27 17:49 ` Shark8
  2020-01-27 19:32   ` mockturtle
@ 2020-01-27 19:46   ` Simon Wright
  2020-01-27 20:30     ` mockturtle
  2020-01-27 20:28   ` mockturtle
  2 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 2020-01-27 19:46 UTC (permalink / raw)


Shark8 <onewingedshark@gmail.com> writes:

> On Monday, January 27, 2020 at 9:22:41 AM UTC-7, mockturtle wrote:
>> 
>> foo.ads: bar.txt
>>        convert --from=bar.txt --to=foo.ads
>> 
>> What I would like is having gprbuild checking if bar.txt is newer
>> than foo.ads; if it is, run convert and after that proceed with the
>> actual building.
>> 
>> Is this possible?
>> 
>> I also checked Gem #152
>> (https://www.adacore.com/gems/gem-152-defining-a-new-language-in-a-project-file)
>> about defining a new language inside a gpr file, but I am not sure
>> it can be a solution.
> Why not?
> Wouldn't you just use
>
> Package Compiler is
>   for Driver ("Converter") use "convert";
>   for Object_Generated ("Converter") use "False";
>   --...
> End Compiler;

The Gem seems only to be about "languages" that compile to object (.o)
files.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gpr and Makefiles
  2020-01-27 17:49 ` Shark8
  2020-01-27 19:32   ` mockturtle
  2020-01-27 19:46   ` Simon Wright
@ 2020-01-27 20:28   ` mockturtle
  2020-01-28 11:57     ` briot.emmanuel
  2 siblings, 1 reply; 7+ messages in thread
From: mockturtle @ 2020-01-27 20:28 UTC (permalink / raw)


On Monday, January 27, 2020 at 6:49:38 PM UTC+1, Shark8 wrote:
> On Monday, January 27, 2020 at 9:22:41 AM UTC-7, mockturtle wrote:
> > 
> > foo.ads: bar.txt
> >        convert --from=bar.txt --to=foo.ads
> > 
> > What I would like is having gprbuild checking if bar.txt is newer than foo.ads; if it is, run convert and after that proceed with the actual building.
> > 
> > Is this possible?
> > 
> > I also checked Gem #152 (https://www.adacore.com/gems/gem-152-defining-a-new-language-in-a-project-file) about defining a new language inside a gpr file, but I am not sure it can be a solution.
> Why not?
> Wouldn't you just use
> 
> Package Compiler is
>   for Driver ("Converter") use "convert";
>   for Object_Generated ("Converter") use "False";
>   --...
> End Compiler;


It worked, thank you.

Actually, it was less trivial than I expected. The main problem was that gprbuild expects a command line like

   <compiler name> <pre-options> <source> <post-options>

while my command line was

   convert <output filename> <input filename>

However, since convert is actually a Ruby script I changed it to handle the case <output>=-c as an "automagical" case where the output filename is obtained from the input.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gpr and Makefiles
  2020-01-27 19:46   ` Simon Wright
@ 2020-01-27 20:30     ` mockturtle
  0 siblings, 0 replies; 7+ messages in thread
From: mockturtle @ 2020-01-27 20:30 UTC (permalink / raw)


On Monday, January 27, 2020 at 8:46:03 PM UTC+1, Simon Wright wrote:
> Shark8 <onewingedshark@gmail.com> writes:
> 
> > On Monday, January 27, 2020 at 9:22:41 AM UTC-7, mockturtle wrote:
> >> 
> >> foo.ads: bar.txt
> >>        convert --from=bar.txt --to=foo.ads
> >> 
> >> What I would like is having gprbuild checking if bar.txt is newer
> >> than foo.ads; if it is, run convert and after that proceed with the
> >> actual building.
> >> 
> >> Is this possible?
> >> 
> >> I also checked Gem #152
> >> (https://www.adacore.com/gems/gem-152-defining-a-new-language-in-a-project-file)
> >> about defining a new language inside a gpr file, but I am not sure
> >> it can be a solution.
> > Why not?
> > Wouldn't you just use
> >
> > Package Compiler is
> >   for Driver ("Converter") use "convert";
> >   for Object_Generated ("Converter") use "False";
> >   --...
> > End Compiler;
> 
> The Gem seems only to be about "languages" that compile to object (.o)
> files.

Actually, near the end it talks about the attribute Object_Generated that if set to False it tells to the gprbuild that no object is generated


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gpr and Makefiles
  2020-01-27 20:28   ` mockturtle
@ 2020-01-28 11:57     ` briot.emmanuel
  0 siblings, 0 replies; 7+ messages in thread
From: briot.emmanuel @ 2020-01-28 11:57 UTC (permalink / raw)



gprbuild is pretty weak for generated code.
When I was working at AdaCore, we had made a nice design to properly handle this, but I don't know what happened to that design.

Here, you are trying to generate Ada code. So when you start gprbuild, it might quickly compile a unit that depends on one of the generated Ada packages, without having generated them already. In practice, you end up having to run gprbuild multiple times (once to generate the files, then to compile everything).
A proper build tool should be able to handle that automatically in one pass, just by having a full graph of dependencies.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-28 11:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-27 16:22 gpr and Makefiles mockturtle
2020-01-27 17:49 ` Shark8
2020-01-27 19:32   ` mockturtle
2020-01-27 19:46   ` Simon Wright
2020-01-27 20:30     ` mockturtle
2020-01-27 20:28   ` mockturtle
2020-01-28 11:57     ` briot.emmanuel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox