Setting the --create-missing-dirs option in a gprbuild file
Asked Answered
K

2

6

It's useful to have a separate directory to store object files in. However, gprbuild will complain if the directory doesn't already exist. I use hg for version control, which doesn't allow you to track empty directories (AFAIK this is true of git as well), but even if it did, it's unfortunate to have to clutter up the repository with an empty directory. gprbuild has an option, --create-missing-dirs (short form -p) which does precisely what it says on the tin. This is exceedingly useful. What I would like to know, however, is if there is some way to set this in a .gpr file. It is obnoxious to have to remind my users to compile with the -p option, instead of being able to just run gprbuild project. Unfortunately, the docs for gprguild have this to say:

By default, GPRbuild checks that the object, library and exec directories specified in project files exist. Switch -p instructs GPRbuild to attempt to create missing directories. Note that these switches may be specified in package Builder of the main project, but they are useless there as either the directories already exist or the processing of the project files has failed before the evaluation of the Builder switches, because there is at least one missing directory.

Surely there has to be a way to do what I am describing?

Keyboard answered 2/10, 2017 at 6:25 Comment(0)
R
9

Recent versions of gprbuild (since 19 August 2016, see Git) support the Create_Missing_Dirs attribute.

project Foo is
   for Create_Missing_Dirs use "True";
   ...

GNAT GPL 2017 has this.

Rosetterosewall answered 2/10, 2017 at 10:0 Comment(0)
S
-1

If you're committing an empty directory, chances are you don't want git/hg to track files in that directory either. One solution is to put one hidden* tracked file in the directory, and add a rule to ignore all other files.

For hg, .hgignore has to be at top-level (as far as I know), so you'd need to add a .keep file (or some other describing name) in the directory you want to keep, and add a rule to .hgignore to ignore everything else.

For git, you could put a .gitignore file inside the directory itself with a rule to ignore all files. In this case, .gitignore itself will be the hidden tracked file. (bonus: the rule is easier to write)

  • on systems where files starting with a . are hidden
Senhauser answered 2/10, 2017 at 7:17 Comment(1)
this is an option, yes, one that I am well-aware of. But it doesn't answer my actual question at all.Keyboard

© 2022 - 2024 — McMap. All rights reserved.