3

Let's say someone was developing a game development framework. There's a graphics rendering project, a window/context handling project, and a math library project.

Let's further say that the developer wanted to have each section as a separate repository, in case someone just wanted a library for windows handling or just wanted to math library, etc.

So, each of these are added to the game framework as a submodule. The graphics library is dependent on the math library so it's added as a submodule to the graphics library but now we have two copies of the math library in the main framework. OK, so we delete the math lib from the main framework and get the project from the graphics submodule. Things are already starting to smell.

To make things worse, now the developer wants to make a physics library repo (again as it's own working repo in case someone only wants physics and not the whole giant framework) for the framework except it also depends on the math library.

How can we have this kind of complicated superintendency/modularity without this headache?

tl;dr:

game framework ------> graphics, gui, physics, math  
graphics --------------> math  
physics ---------------> math

but each part should be able to work on its own.

where ------> means "is dependent on"
Rory Hunter
  • 3,425
  • 1
  • 14
  • 16

1 Answers1

1

A good rule to follow in order to manage potentially overlapping dependencies with submodules is:

  • to declare all submodules in the parent repo, that is a repo which would include game framework, graphics, physics (the main repos) as well as their dependencies (gui, math)
  • to check if there are any discrepancies in the SHA1 for those submodules, by git ls-files --stage in order to list the index and pick the 1600000 special entry
  • replacing any submodule folder( which aren't there until you do a git submodule update) by a symlink

    parent repo
      game framework ------> graphics (ln -s ../graphics)
                     ------> gui  (ln -s ../gui), 
                     ------> physics (ln -s ../physics), 
                     ------> math (ln -s ../math)
      graphics ------------> math (ln -s ../math)
      physics -------------> math (ln -s ../math)
      gui
      math
    

That forces you to pick one version for each dependency.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250