comp.lang.ada
 help / color / mirror / Atom feed
* Have one GPR file build another with external variables
@ 2020-05-30 16:59 Jere
  2020-05-30 17:17 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 6+ messages in thread
From: Jere @ 2020-05-30 16:59 UTC (permalink / raw)


Say I have a custom runtime whose project file (GPR) takes in an 
external variable to compile in either debug or release 
(-xBUILD=release vs -xBUILD=debug for example).  If I have another 
project that uses this runtime with the same external variable, is 
there a way for me to tell the project file for this 2nd project to 
also rebuild the runtime GPR and use the same external variable value?  
I'm looking for a solution within the GPR file if possible.  I know 
I can always just do a make file, but wanted to see if I have a more 
cross platform alternative.

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

* Re: Have one GPR file build another with external variables
  2020-05-30 16:59 Have one GPR file build another with external variables Jere
@ 2020-05-30 17:17 ` Dmitry A. Kazakov
  2020-05-30 18:48   ` Jere
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2020-05-30 17:17 UTC (permalink / raw)


On 30/05/2020 18:59, Jere wrote:
> Say I have a custom runtime whose project file (GPR) takes in an
> external variable to compile in either debug or release
> (-xBUILD=release vs -xBUILD=debug for example).  If I have another
> project that uses this runtime with the same external variable, is
> there a way for me to tell the project file for this 2nd project to
> also rebuild the runtime GPR and use the same external variable value?
> I'm looking for a solution within the GPR file if possible.  I know
> I can always just do a make file, but wanted to see if I have a more
> cross platform alternative.

I don't quite understand your question, because as a rule, you design 
the project files so that when you change a scenario variable that would 
also change the object and library directories. Thus there would be no 
need to rebuild anything unless you change to code. Something like:

    Object_Dir_Path := "obj/" & OS "/" & arch & "/" & BUILD;
    for Object_Dir use Object_Dir_Path;

in the root GPR file. The project with-ing it can take Object_Dir_Path 
for their Object_Dir:

    Object_Dir_Path := Parent.Object_Dir_Path;

This will make each project having its own set of object files along all 
dependencies. If you want rather share object files across all projects 
you can make the path absolute.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: Have one GPR file build another with external variables
  2020-05-30 17:17 ` Dmitry A. Kazakov
@ 2020-05-30 18:48   ` Jere
  2020-05-30 19:29     ` Dmitry A. Kazakov
  2020-05-30 21:33     ` Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: Jere @ 2020-05-30 18:48 UTC (permalink / raw)


On Saturday, May 30, 2020 at 1:17:11 PM UTC-4, Dmitry A. Kazakov wrote:
> On 30/05/2020 18:59, Jere wrote:
> > Say I have a custom runtime whose project file (GPR) takes in an
> > external variable to compile in either debug or release
> > (-xBUILD=release vs -xBUILD=debug for example).  If I have another
> > project that uses this runtime with the same external variable, is
> > there a way for me to tell the project file for this 2nd project to
> > also rebuild the runtime GPR and use the same external variable value?
> > I'm looking for a solution within the GPR file if possible.  I know
> > I can always just do a make file, but wanted to see if I have a more
> > cross platform alternative.
> 
> I don't quite understand your question, because as a rule, you design 
> the project files so that when you change a scenario variable that would 
> also change the object and library directories. Thus there would be no 
> need to rebuild anything unless you change to code. Something like:
> 
>     Object_Dir_Path := "obj/" & OS "/" & arch & "/" & BUILD;
>     for Object_Dir use Object_Dir_Path;
> 
> in the root GPR file. The project with-ing it can take Object_Dir_Path 
> for their Object_Dir:
> 
>     Object_Dir_Path := Parent.Object_Dir_Path;
> 
> This will make each project having its own set of object files along all 
> dependencies. If you want rather share object files across all projects 
> you can make the path absolute.
> 
I'm working with GNAT.  I've never seen a custom runtime be able to use
an obj subfolder.  I've only been able to get a runtime in GNAT to work
using adainclude for the source files and adalib for the object files.
I've not encountered an example where it allowed debug and release 
subfolders to the adalib folder.  Right now to build my project in debug
I do:
gprbuild my_runtime.gpr -xBUILD=debug
cd /somepath/my_library/
gprbuild my_library.gpr -xBUILD=debug

where my_library's runtime is set to my_runtime.  Conversely if I want
to build in release mode, I have to do:

gprbuild my_runtime.gpr -xBUILD=release
cd /somepath/my_library/
gprbuild my_library.gpr -xBUILD=release

I would like to see if there is someway for me to setup my_library.gpr
so that when do either 
gprbuild my_library.gpr -xBUILD=debug
OR
gprbuild my_library.gpr -xBUILD=release

it first recompiles my_runtime.gpr with the same external variable that
I used for my_library.gpr

I currently use a make file for it, but I would like to not require that
if possible since make isn't standard with all OS'es that support GNAT.

It may not be possible, just asking.

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

* Re: Have one GPR file build another with external variables
  2020-05-30 18:48   ` Jere
@ 2020-05-30 19:29     ` Dmitry A. Kazakov
  2020-05-30 21:33     ` Simon Wright
  1 sibling, 0 replies; 6+ messages in thread
From: Dmitry A. Kazakov @ 2020-05-30 19:29 UTC (permalink / raw)


On 30/05/2020 20:48, Jere wrote:

> gprbuild my_runtime.gpr -xBUILD=debug
> cd /somepath/my_library/
> gprbuild my_library.gpr -xBUILD=debug

[ Run-time might be a special case. ]

With libraries I "with" all of them in my project and everything 
necessary is rebuilt. I have two GPR files per library: one for design, 
another for production.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: Have one GPR file build another with external variables
  2020-05-30 18:48   ` Jere
  2020-05-30 19:29     ` Dmitry A. Kazakov
@ 2020-05-30 21:33     ` Simon Wright
  2020-05-31 18:42       ` Jere
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Wright @ 2020-05-30 21:33 UTC (permalink / raw)


If you're only concerned wih runtimes, you could maybe look at
_installing_ the runtime in different locations depending on the
release/debug mode?

For Cortex GNAT RTS I use this style in build_runtime.gpr, to install
either with the compiler (not that I ever do!) or in
~/cortex-gnat-rts/local/stm32f4 (for example). All the source files in
the runtime source end up in the one adainclude/ directory.

   package Install is
      case Common.Local is
         when "no" =>
            for Prefix use "arm-eabi/lib/gnat/";
         when "yes" =>
            for Prefix use project'Project_Dir & "../local/";
      end case;
      for Prefix use Install'Prefix & "stm32f4";
      for Sources_Subdir use "adainclude";
      for Ali_Subdir use "adalib";
      for Lib_Subdir use "adalib";
      for Required_Artifacts (".") use ("runtime.xml");
      for Required_Artifacts ("adalib") use ("adalib/stm32f407-flash.ld");
      for Install_Project use "false";
   end Install;

Common.Local is set by the scenario variable INSTALL_LOCALLY, but you
could equally use your BUILD variable, so that the RTS would end up in
/some/path/debug or /some/path/release, and your project would pick up
its runtime from whichever. Wouldn't even have to use the same build
variable in project and RTS, so long as the projject knows where to
look.

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

* Re: Have one GPR file build another with external variables
  2020-05-30 21:33     ` Simon Wright
@ 2020-05-31 18:42       ` Jere
  0 siblings, 0 replies; 6+ messages in thread
From: Jere @ 2020-05-31 18:42 UTC (permalink / raw)


On Saturday, May 30, 2020 at 5:33:30 PM UTC-4, Simon Wright wrote:
> If you're only concerned wih runtimes, you could maybe look at
> _installing_ the runtime in different locations depending on the
> release/debug mode?
> 
> For Cortex GNAT RTS I use this style in build_runtime.gpr, to install
> either with the compiler (not that I ever do!) or in
> ~/cortex-gnat-rts/local/stm32f4 (for example). All the source files in
> the runtime source end up in the one adainclude/ directory.
> 
>    package Install is
>       case Common.Local is
>          when "no" =>
>             for Prefix use "arm-eabi/lib/gnat/";
>          when "yes" =>
>             for Prefix use project'Project_Dir & "../local/";
>       end case;
>       for Prefix use Install'Prefix & "stm32f4";
>       for Sources_Subdir use "adainclude";
>       for Ali_Subdir use "adalib";
>       for Lib_Subdir use "adalib";
>       for Required_Artifacts (".") use ("runtime.xml");
>       for Required_Artifacts ("adalib") use ("adalib/stm32f407-flash.ld");
>       for Install_Project use "false";
>    end Install;
> 
> Common.Local is set by the scenario variable INSTALL_LOCALLY, but you
> could equally use your BUILD variable, so that the RTS would end up in
> /some/path/debug or /some/path/release, and your project would pick up
> its runtime from whichever. Wouldn't even have to use the same build
> variable in project and RTS, so long as the projject knows where to
> look.

I appreciate this and I actually started out with something similar to
this.  Every time I needed to make an adjustment to the runtime, I had to
rebuild the runtime twice, re-install it twice, and then rebuild the
library too.  I'm trying to get to a single gprbuild command on the
library GPR file that both forces the runtime to be rebuilt and also
is able to pass an external variable to that build process.  I want
something like:

gprbuild my_library.gpr -xBUILD=debug 

to essentially replace my 

gprbuild my_runtime.gpr -xBUILD=debug
gprbuild my_library.gpr -xBUILD=debug

(NOTE:  Inside of my_library.gpr, I specify the runtime
as the one for my_runtime.gpr so it knows where it is).

So that every time I make an adjustment to the library or the
runtime (I'm working on both at the same time), I don't have
so many steps to do for compilation.  I currently use a make
file to do this, but I was hoping I could add something to
my_library.gpr to tell it to rebuild my_runtime.gpr and 
specify the external variables needed for that build process. 

It may not be possible, I'm just checking to see if gprbuild
has some sort of aspect or similar to tell it to rebuild the
runtime and also specify the variables needed for that build.

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

end of thread, other threads:[~2020-05-31 18:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30 16:59 Have one GPR file build another with external variables Jere
2020-05-30 17:17 ` Dmitry A. Kazakov
2020-05-30 18:48   ` Jere
2020-05-30 19:29     ` Dmitry A. Kazakov
2020-05-30 21:33     ` Simon Wright
2020-05-31 18:42       ` Jere

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