comp.lang.ada
 help / color / mirror / Atom feed
* Copying ressource files with gprbuild
@ 2012-06-06 18:43 Felix Krause
  2012-06-06 19:08 ` Simon Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Felix Krause @ 2012-06-06 18:43 UTC (permalink / raw)


I develop an application which depends on some ressource files. Let's 
say these ressource files are located in my source folder "src", next 
to the Ada sources, and let "ressource.txt" be one of these ressource 
files. I compile my application with GPRBuild and a standard folder 
setup. Currently, my code loads the ressource with the path 
"../src/ressource.txt", which works when I compile the code, navigate 
to the "bin" directory, and execute the binary there. It also works 
from inside GPS.

Now I want to do some debugging. Therefore, I switch to build mode 
"debug" in GPS, which causes the executable to be executed in 
"bin/debug". From there, it obviously cannot locate ressource.txt. So I 
need some possibility to copy the ressource file to the folder the 
executable gets written to.

After reading through the GPRBuild manual, it seems that there is no 
standard way of doing this with a project file. I thought about 
defining a custom language "txt" in the project file, and setting up 
appropriate drivers in the Compiler, Binder and Linker packages so that 
it will just be piped through the build process and lands in the 
executable output directory. But I couldn't figure out how I can get 
gprbuild to do this, and it also smells like a rather ugly hack.

Now I know I can probably write some Makefile that will take care of 
copying the ressource files. But I'd like to know how others handle 
this problem, and if there is a way to handle ressource files with the 
project file.

-- 
Felix




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

* Re: Copying ressource files with gprbuild
  2012-06-06 18:43 Copying ressource files with gprbuild Felix Krause
@ 2012-06-06 19:08 ` Simon Wright
  2012-06-06 20:06 ` gautier_niouzes
  2012-06-07 20:48 ` Stephen Leake
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Wright @ 2012-06-06 19:08 UTC (permalink / raw)


Felix Krause <flyx@isobeef.org> writes:

> I develop an application which depends on some ressource files. Let's
> say these ressource files are located in my source folder "src", next
> to the Ada sources, and let "ressource.txt" be one of these ressource
> files. I compile my application with GPRBuild and a standard folder
> setup. Currently, my code loads the ressource with the path
> "../src/ressource.txt", which works when I compile the code, navigate
> to the "bin" directory, and execute the binary there. It also works
> from inside GPS.
>
> Now I want to do some debugging. Therefore, I switch to build mode
> "debug" in GPS, which causes the executable to be executed in
> "bin/debug". From there, it obviously cannot locate ressource.txt. So
> I need some possibility to copy the ressource file to the folder the
> executable gets written to.

Presumably actually "bin/src"?

> After reading through the GPRBuild manual, it seems that there is no
> standard way of doing this with a project file. I thought about
> defining a custom language "txt" in the project file, and setting up
> appropriate drivers in the Compiler, Binder and Linker packages so
> that it will just be piped through the build process and lands in the
> executable output directory. But I couldn't figure out how I can get
> gprbuild to do this, and it also smells like a rather ugly hack.
>
> Now I know I can probably write some Makefile that will take care of
> copying the ressource files. But I'd like to know how others handle
> this problem, and if there is a way to handle ressource files with the
> project file.

If you are on a Unix-like system you might try a symbolic link;

  $ ln -s src bin/src

But it might be better to use for example an environment variable to
define the (absolute) location where the resource files are found.



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

* Re: Copying ressource files with gprbuild
  2012-06-06 18:43 Copying ressource files with gprbuild Felix Krause
  2012-06-06 19:08 ` Simon Wright
@ 2012-06-06 20:06 ` gautier_niouzes
  2012-06-07 20:48 ` Stephen Leake
  2 siblings, 0 replies; 4+ messages in thread
From: gautier_niouzes @ 2012-06-06 20:06 UTC (permalink / raw)


Hello,
I do not handle the problem but avoid it ;-).
If you have sibling directories for the different modes, you can have the same levels up in the directories and use the same resources the same way.
E.g you'd have for the different modes
  bin/debug
  bin/fast
  bin/small
  bin/profiling
but use "../../src" in a mode-agnostic way  
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address



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

* Re: Copying ressource files with gprbuild
  2012-06-06 18:43 Copying ressource files with gprbuild Felix Krause
  2012-06-06 19:08 ` Simon Wright
  2012-06-06 20:06 ` gautier_niouzes
@ 2012-06-07 20:48 ` Stephen Leake
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Leake @ 2012-06-07 20:48 UTC (permalink / raw)


Felix Krause <flyx@isobeef.org> writes:

> I develop an application which depends on some ressource files. Let's
> say these ressource files are located in my source folder "src", next
> to the Ada sources, and let "ressource.txt" be one of these ressource
> files. I compile my application with GPRBuild and a standard folder
> setup. Currently, my code loads the ressource with the path
> "../src/ressource.txt", which works when I compile the code, navigate
> to the "bin" directory, and execute the binary there. It also works
> from inside GPS.
>
> Now I want to do some debugging. Therefore, I switch to build mode
> "debug" in GPS, which causes the executable to be executed in
> "bin/debug". From there, it obviously cannot locate ressource.txt. So
> I need some possibility to copy the ressource file to the folder the
> executable gets written to.

For development, I use separate build directories for 'release' and
'debug':

project

project/build/debug

project/build/release

project/source

That way, relative paths from either build directory to source are
correct.

However, once you get to distribution, that relative path will be wrong.

One solution is to follow an operating system standard like Debian,
which specifies where resource files go. Or define your own standard.

In any case, allowing the user to override the location via an
environment variable makes sense, and you can then use that during
development.


None of this has to do with gprbuid; I would definitely use a Makefile
to copy the files to the right place.

-- 
-- Stephe



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

end of thread, other threads:[~2012-06-07 20:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-06 18:43 Copying ressource files with gprbuild Felix Krause
2012-06-06 19:08 ` Simon Wright
2012-06-06 20:06 ` gautier_niouzes
2012-06-07 20:48 ` Stephen Leake

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