Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gpr and Makefiles

179 views
Skip to first unread message

mockturtle

unread,
Jan 27, 2020, 11:22:41 AM1/27/20
to
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

Shark8

unread,
Jan 27, 2020, 12:49:38 PM1/27/20
to
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;

mockturtle

unread,
Jan 27, 2020, 2:32:25 PM1/27/20
to
Hmmm... I'll try.

Simon Wright

unread,
Jan 27, 2020, 2:46:03 PM1/27/20
to
The Gem seems only to be about "languages" that compile to object (.o)
files.

mockturtle

unread,
Jan 27, 2020, 3:28:59 PM1/27/20
to
On Monday, January 27, 2020 at 6:49:38 PM UTC+1, Shark8 wrote:
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.

mockturtle

unread,
Jan 27, 2020, 3:30:30 PM1/27/20
to
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

briot.e...@gmail.com

unread,
Jan 28, 2020, 6:57:53 AM1/28/20
to

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.
0 new messages