More power to GPRbuild

As somebody who just studies a whole Ada ecosystem I am learning a lot about GPRbuild and its language. I find this is a pretty interesting build system with features many other build systems do not have.

Looking at alire repository, however, I find that many projects also use GNU make as a kind of frontend to build and install things, sometimes even as a simple wrapper to GPRbuild. I’ve run into problems trying to make alire index more portable and those problems have been easily solved somewhere else.

I consider make ugly and GPRbuild nice and I was wondering why some projects still prefer make.

So the project idea is this:

  1. Identify most common reasons to use make instead of GPRbuild
  2. Consider additional features that should be added to the GPR language
  3. Implement them (preferably also in the older GPRbuild 1)
  4. Stop using make as a frontend

So far I have identified the following reasons:

  1. Convenience loops - it is easy for example to build 3 versions of a library looping around multiple gprbuild invocations with different -P parameters. Gem #158: GPRinstall - Part 1 | AdaCore gem suggests to simply run gprbuild/gprinstall in sequence to have a library built for three object format variants. I believe we could support something like this in GPR without introducing general purpose loops (which I think has been avoided on purpose)
  2. Building multiple projects - a variant of above if make is used to invoke multiple GPR projects within the same repository. If aggregate projects are too limited to achieve this, we should figure out what are the obstacles here.
  3. C language libraries - additional code like GNU autoconf and similar can be used to detect additional external libraries and feed them to the GPR processing. My proposal to solve the most typical use case is to integrate GPR tigher with pkgconf - to allow for example setting linker flags from within the GPR without resorting to the need to provide them externally.
  4. Code generation - there could be an additional phase before the compilation phase to invoke some additional code generators. I think LangKit based projects and maybe asn1scc should be used to make sure the feature is generic enough to support various code generators. I read somewhere (in the Lisp community) that if code generation is needed, this means that the abstractions that the programming language provides are not rich enough [citation needed], but solving this is definitely out of scope here.
  5. ….

A special mention goes to LangKit’s manage.py which is used for various aspects of building/confguration. I understand that this might be because some other non-Ada projects might want to use the library.

A major benefit of this is simplification of a whole ecosystem and lowering barriers of entry. Cargo users need only to use cargo. I believe alire is a wrong place to solve this problem. I’d rather be programming GPR than TOML if you ask me.We also do not want to convert the alire index to a full feature ports tree such as ravenports.

Solving all this requires some architectural discussion about where the GPR language should evolve. I am not sure where to start such a discussion, so I am trying here.

Difficulty to solve all of this is hard, but once the design directions are clear this might actually proceed. Good thing here is that we can devise smaller sub-projects to deal with various aspects of this issue.

For myself, I think that adding some kind of pkgconf integration should be easy enough for a newcomer like me to get started.

My apologies if this has been discussed extensively already, but I could not find much references to this, even with some LLM-based tools to search the Internet.

1 Like

I read somewhere that AdaCore will release a GPRBuild2. It will be interesting to see what new features it will provide

1 Like

Gprbuild is an extremely useful and powerful tool that exceeds make and cmake in every possible aspect. The reason why people use make is same why they use C. You will never get them back. Citing Dijkstra:

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

My issues with grpbuild are far more modest:

  • String and string list expressions: slicing substituting etc, preferably in Ada syntax.
  • Use (as a subproject) vs build (as a library) projects. Presently they must be different. It would be nice to have a single project file for both scenarios.
  • Predefined built-in variables/attributes/values identifying the operating system, machine, language standard version.

I also wished AdaCore actively promoted gprbuild. It is an excellent product useful far beyond Ada community. Once I was confronted by huge pile of cmake files and source directories for a legacy C++ project. The stuff just refused to build and nobody knew how to fix it. Coprology is not my thing, so I wrote a gpr-file. It took a half of a day and worked straight out the box.

That is why TOML must be placed into XML and that into JSON all parsed from Python. You cannot properly appreciate it without having all four at once… :grinning:

I’ve resorted to just converting makefiles to standalone Ada files when the build process gets too unwieldy for a makefile and doesn’t work well with gprbuild. Here’s one as an example, you might be able to pull some useful feature ideas from here: prunt/prebuild.adb at 3754d8fa4d32f8c3fa9fea054087fa968cebacf8 · Prunt3D/prunt · GitHub

Don’t mind the awful commit history on that branch, it’s all going to be squashed once it’s done, it only exists so I can grep older changes temporarily.