Gprbuild & command-line args

Not sure how feasible or practical that would be but I am wondering if there would be any value for gprbuild to save the state of the command-line arguments used in its last run as that could come in handy in some scenarios:

My exact use-case isn’t massively relevant but to give a bit of context, I was trying to build a bareboard runtime with some custom logic I added in some file so I ran the following command:

gprbuild -j0 -P ravenscar_build.gpr -XDUILD=Debug

which printed out some info lines with the file that I’d changed so I could tell that my change had been picked-up. However, when I later tried debugging my code the runtime symbols were nowhere to be found! The problem as you might have spotted, was that the -X key name had been misspelled (DUILD instead of BUILD) so naturally no debug symbols were inserted in the elf file. So, I fixed that and ran again but still nothing! The command returned immediately without any diagnostic messages which I thought was a bit odd but nevertheless got the impression it had run but because no files had been changed it just didn’t print anything.

The solution was to change my file (any file would do the trick really) save it then revert the change and save it again so that the last access timestamp would be bumped. And gprbuild then built the runtime in debug mode.

So, I’m wondering (just thinking out loud really) would it make sense to save the arguments of the last run (maybe in some hidden file in the root project dir) and use that (along with the files modification state) when deciding whether to run the given command or not?

Or even maybe just print some diagnostic message when it hasn’t actually run?

Any thoughts?

Thanks!

  1. Wait for gprbuild2, it can detect changes of switches.
  2. Use -f to force recompilation.

A function should be function of its arguments only. That is the golden rule of SW design.

P.S. gprclean is a handy utility for removing project’s artefacts.

P.P.S. GNAT Studio remembers command line arguments set for build and run.

package Builder is
     for Default_Switches ("Ada") use ("-s",   -- recompile if switches change

I’m not sure if it will catch your case, since it is the value of a switch that changed, and not the switch itself. But I would try it.