Trying to figure out how to model dependencies between repos

So I’ve been reading up on how this whole CI thing works, and this is what I currently have. All of this is C++ code.

I have four library repos, let’s call them A, B, C and D. Then I have an application repo X.

I have scripts in each of A, B, C and D that build the libraries for various platforms, and then copy the resultant libraries and public header files to another repo P. P is setup to use Git LFS.

There are also some dependencies between A, B, C and D. For example, A and B depend on C. So if I change some code in C, I would build it and copy it’s output to P. Then I would build A and B which would include C’s header files from P. Any other dependencies between A, B, C and D are expressed this way, ie they reference the appropriate sub folder in P rather than A, B, C and D directly. (This is for a reason - it means it’s easier to build and debug instances of X on other machines without having to rebuild A, B, C, and D as X just links to the prebuilt libraries from P.)

Finally, scripts in X build more code and links with the output of A, B, C and D that was copied to P.

Anyway as I’ve added more platforms to this project, I need to automate all of this. So I’m looking into setting up GitLab self hosting on my NAS.

My thinking (bear with me, this is all new to me) is I’d need to:

  • have YAML files in each of A, B, C and D that run the build scripts for the various platforms, and copy the output to P and commit these changes. That seems pretty straightforward as a concept. A commit is made, and they get rebuilt. So far so good.

  • am I right in thinking I’d have to use triggers to express A and B’s dependency on C? I.e. when C has finished it triggers A and B to rebuild. Is that the way to achieve this? Ie I cannot express it the other way around and say that A and B should rebuild if something specific (a folder) is updated in P? That would seem more logical, but I can’t do that, right?

  • similarly, X would self-rebuild when it’s own code changes, but I‘d also need triggers in each of A, B, C, and D to trigger an additional build of X. Again it seems sort of upside down in that I’m telling A, B, C, D to rebuild X, rather than be able to say “X depends on these specific folders in P”.

Assuming that’s the way I have to do this, let’s say I change some code in C. It then rebuilds itself, and after doing so it triggers builds if A and B, and presumably X. A and B then rebuild and then they would also trigger X. So wouldn’t up it lead to multiple wasteful interim builds of X? Or would I not specify that C triggers X because I know that A and B will do that? Also, if multiple builds of X are queued up, what does it do? Does it run them all, or just the last one or something?

Or am I planning this completely the wrong way?

Thanks for any help.