comp.lang.ada
 help / color / mirror / Atom feed
* project file syntax
@ 2014-08-01 20:48 agent
  2014-08-01 21:25 ` Simon Wright
  2014-08-02 13:16 ` Robert A Duff
  0 siblings, 2 replies; 4+ messages in thread
From: agent @ 2014-08-01 20:48 UTC (permalink / raw)


As an exercise for myself, I'm converting an rpn calculator I wrote in
modula-2 to Ada.  I have already debugged several modules, such as
tknrtnsa, timliba and environa.  Now I want to debug 2 modules,
hpcalca and rpna.  I call this project file rpna.gpr

project rpna is
  for Source_Files use ("rpna.adb","hpcalca.ads","hpcala.adb");   for
Source_Dirs use (".", "./**");
  for Main use ("rpna");   

  package Builder is
    for Default_Switches ("Ada")
        use ("-g");
  end Builder;

  package Compiler is
    for Default_Switches ("Ada")
       use ("-fstack-check",
            "-gnatVa",
            "-g",
            "-gnato",
            "-gnatf",
            "-gnatwu",
            "-gnat2012");
  end Compiler;

end rpna;


I get errors that the modules I previously wrote cannot be found. That
is, tknrtnsa, timliba and environa cannot be found.  If I have these
re-compiled by putting them in the Source_Files list, that works.  But
it strikes me as I am not understanding something about project files.

How do I write a project file to not have to recompile packages that I
know already work, and for which I have the .ali and .o files?

Thanks,
Rob

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

* Re: project file syntax
  2014-08-01 20:48 project file syntax agent
@ 2014-08-01 21:25 ` Simon Wright
  2014-08-02 11:56   ` agent
  2014-08-02 13:16 ` Robert A Duff
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Wright @ 2014-08-01 21:25 UTC (permalink / raw)


agent@drrob1.com writes:

> As an exercise for myself, I'm converting an rpn calculator I wrote in
> modula-2 to Ada.  I have already debugged several modules, such as
> tknrtnsa, timliba and environa.  Now I want to debug 2 modules,
> hpcalca and rpna.  I call this project file rpna.gpr
[...]
> I get errors that the modules I previously wrote cannot be found. That
> is, tknrtnsa, timliba and environa cannot be found.  If I have these
> re-compiled by putting them in the Source_Files list, that works.  But
> it strikes me as I am not understanding something about project files.
>
> How do I write a project file to not have to recompile packages that I
> know already work, and for which I have the .ali and .o files?

Recompilation is pretty cheap, especially with a small number of files
like these. I'd probably put all the source in the same project!

That said, you can put tknrtnsa etc. in their own project and "with" it
in your main project. I wrote a more complete answer to a similar
question at http://stackoverflow.com/a/12587981 .


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

* Re: project file syntax
  2014-08-01 21:25 ` Simon Wright
@ 2014-08-02 11:56   ` agent
  0 siblings, 0 replies; 4+ messages in thread
From: agent @ 2014-08-02 11:56 UTC (permalink / raw)


Thanks.

I was hoping for an automatic way for separate compilation like I do
for my modula-2 code.

so it goes.

--rob

On Fri, 01 Aug 2014 22:25:52 +0100, Simon Wright <simon@pushface.org>
wrote:

>agent@drrob1.com writes:
>
>> As an exercise for myself, I'm converting an rpn calculator I wrote in
>> modula-2 to Ada.  I have already debugged several modules, such as
>> tknrtnsa, timliba and environa.  Now I want to debug 2 modules,
>> hpcalca and rpna.  I call this project file rpna.gpr
>[...]
>> I get errors that the modules I previously wrote cannot be found. That
>> is, tknrtnsa, timliba and environa cannot be found.  If I have these
>> re-compiled by putting them in the Source_Files list, that works.  But
>> it strikes me as I am not understanding something about project files.
>>
>> How do I write a project file to not have to recompile packages that I
>> know already work, and for which I have the .ali and .o files?
>
>Recompilation is pretty cheap, especially with a small number of files
>like these. I'd probably put all the source in the same project!
>
>That said, you can put tknrtnsa etc. in their own project and "with" it
>in your main project. I wrote a more complete answer to a similar
>question at http://stackoverflow.com/a/12587981 .


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

* Re: project file syntax
  2014-08-01 20:48 project file syntax agent
  2014-08-01 21:25 ` Simon Wright
@ 2014-08-02 13:16 ` Robert A Duff
  1 sibling, 0 replies; 4+ messages in thread
From: Robert A Duff @ 2014-08-02 13:16 UTC (permalink / raw)


agent@drrob1.com writes:

> As an exercise for myself, I'm converting an rpn calculator I wrote in
> modula-2 to Ada.  I have already debugged several modules, such as
> tknrtnsa, timliba and environa.  Now I want to debug 2 modules,
> hpcalca and rpna.  I call this project file rpna.gpr
>
> project rpna is
>   for Source_Files use ("rpna.adb","hpcalca.ads","hpcala.adb");   for

I suggest using the default naming convention, and leaving out the "for
Source_Files...".  Then your project will contain all source files
whose names match *.ads and *.adb.

You don't want to edit your project file every time you add a new source
file (or rename or delete one).

> Source_Dirs use (".", "./**");
>   for Main use ("rpna");   
>
>   package Builder is
>     for Default_Switches ("Ada")
>         use ("-g");
>   end Builder;
>
>   package Compiler is
>     for Default_Switches ("Ada")
>        use ("-fstack-check",
>             "-gnatVa",
>             "-g",
>             "-gnato",
>             "-gnatf",
>             "-gnatwu",

Consider using -gnatwa or -gnatwae.

>             "-gnat2012");
>   end Compiler;
>
> end rpna;
>
>
> I get errors that the modules I previously wrote cannot be found. That
> is, tknrtnsa, timliba and environa cannot be found.

Right.  Your project contains exactly 3 source files, and if they say
"with tknrtnsa", it won't find tknrtnsa.ads.

>...If I have these
> re-compiled by putting them in the Source_Files list, that works.  But
> it strikes me as I am not understanding something about project files.
>
> How do I write a project file to not have to recompile packages that I
> know already work, and for which I have the .ali and .o files?

That happens automatically.  gprbuild will [re]compile just the files
that need to be [re]compiled.  If you already have .ali and .o files
from a previous run of gprbuild, and they are up to date, those will not
be recompiled.  You shouldn't be trying to tell it which files need to
be recompiled -- it figures that out based on timestamps and .ali files.

You don't need to run gcc directly; just use gprbuild.

- Bob


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

end of thread, other threads:[~2014-08-02 13:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01 20:48 project file syntax agent
2014-08-01 21:25 ` Simon Wright
2014-08-02 11:56   ` agent
2014-08-02 13:16 ` Robert A Duff

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