Managing multiple qt sub-projects with git submodules
-
wrote on 25 Oct 2017, 10:46 last edited by
I had that dream in which I could have multiple "small" projects like "mainApp", "utils", "worker" where eg. all other projects uses utils. In that dream, each imaginary project would be kept in a separate git repository and if needed, it would have submodules for other-imaginary-project that it uses.
And that is the time I wake up screaming with dread. The fear of complex hand-held building one after the other and versions mismatch between submodules gave me insomnia.
But I feel there is a solution for my torment. Maybe qt SUBDIRS (sequenced building) with properly created "shared" git tag for each repo (for not sharing submodules of submodules) and separate branch (for standalone module testing with all the needed submodules) ?
There is also a question (that has no proper answer) what should be used - shared libs or "code-include" like sharing.
Do you had such problems? Maybe some articles?
-
Hi,
How many levels of subprojects do you have in mind and what kind of dependencies ?
-
wrote on 26 Oct 2017, 05:15 last edited by BePie
Hi,
How many levels of subprojects
I think at least 3 (main project, subproject, subproject's subproject)
what kind of dependencies
I mean code reusing done by just sharing source code or by linking to a library (not sure what will be better, probably "it depends").
for instance (let's put 'dependencies' in brackets)
Utils ()
Renderer(Utils)
Loader(Utils)
Main(Renderer, Loader, Utils)and I'd like to have separate repos for each and use git submodules for easier access and edits. But If I make it like that, there are two problems:
(1). when I update (download) submoudle Loader in Main I'll also downlaod it's Utils (same for Renderer) and in given situation I'll have 3 Utils.
(2). Those 3 Utils can have different versions
So to fix this (1) I can make 2 branches for each (not Main) subproject: one for standalone testing and hacking (let's say "master" as it is) that contains needed submodules and one for using as a subproject (let's name it "shared"). Main pulls shared branch of Renderer that does not contain Utils and Main has to include (in it's repo's submodules) Utils that is shared also for eg. Loader. Submodules would be stored as Qt SUBDIR project structure for easy building.
So as to (partly) fix (2) I can make a tag for specific release or keep the branch as minimal as I can (release-branch like).
Another, maybe simpler approach is to use some environment for keeping those submodules as libraries (shared or static) in some environment but than there are problems too:
- No auto-download all the dependencies while pulling repo
- No version restriction (some1 can use Main with Reader 2.0 and some1 can with Reader 2.1)
- One can not simply hack a subproject(s) from "Main" repo
So basically what I have in mind is probably some C++ packaging system magically built on top of git and qmake.
-
Something like qt-pods ?
-
wrote on 27 Oct 2017, 05:28 last edited by
Something like qt-pods ?
Yea!
Please be careful. This software is in early state, use it with caution. Make backups of your repositories.
This line scares me, but I'll look the project up, thanks!
-
wrote on 15 Jan 2024, 13:41 last edited by
Hi
Try to using symlinks.
F.e.:
base subprojects (git repo every):- simple_txt_handle
-
- simple_statistic
- simple_int_handle
-
- simple_statistic
- simple_statistic
if main prj using all of above subdirs, than duplication occur. To avoid duplication may using symlinks. So, - simple_txt_handle
-
- symlink[simple_statistic]
- simple_int_handle
-
- symlink[simple_statistic]
- simple_statistic
result: simple_statistic alone in project, git ok.
my OS: win10, NTFS