Subject: Re: Project With Reusable Libraries

From: Andreas Ericsson <[email-masked]>
Date: Wed, 25 Mar 2009 09:13:39 +0100

John Dlugosz wrote:
> Consider a directory tree something like this:
> 
> 	...
> 	foo\
> 	  bar\
> 	   project-root\
> 	     app1\
> 	         contents of app1
> 	     app2\
> 	         contents of app2
> 	     lib1\
> 	         contents of library 1
> 	     lib2\
> 	         contents of library 2
> 
> 
> Each project, whether application or library, has its own git repository
> already.  A program, say app1, is now dependant on the libraries.  The
> libraries are meant to be used in multiple applications.
> 
> This is not like what is described under subprojects, since the libs are
> not "under" the application, but are peers in the directory structure.
> It would be wrong to put lib1 and lib2 as subdirectories of app1 because
> they are also used by app2, right?
> 
> Then again... if app1 and app2 are not always built as part of the same
> set, they might have different versions of the libs specified.  I
> understand that the newer versions of msysgit do hard linking so having
> multiple repositories for the same thing won't waste disk space, but
> still requires fetching to keep them in sync?
> 
> Anyway, how would you do it?
> 

If app1 and app2 requires different versions of the same library, I'd
make them separate git projects entirely.

If they have to stay in the same project, I'd put their respective
libraries as a submodule under each app. You could get away without
having to fetch them if you stash the lib projects in the super
project and then link the app project's lib-submodules to the one
in the super-project, but it gets messy when you try to explain
that without some simple means of drawing things, so if you can't
write a "sync-submodules" script, I guess it's not really worth
the problem. Especially if the lib-repositories aren't huge.

-- 
Andreas Ericsson                   [email-masked]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.