views:

133

answers:

5

I'm developing a mobile phone application that targets a lot of mobile devices based on the capabilities they offer. There would be a base feature set which all phones are expected to support and then there would be additional features that would depend on specific set of phones.

How do I manage such a code base in terms of a version control system?

I have experience with CVS and VSS but both don't quite fit into my needs for this kind of an application. The last thing I would want to do is branch the code for each of these device sets.

Let me make this a bit more clear with the help of an example. Lets say I'm developing a J2ME application using MIDP 2.0. This is the base feature set that I would expect all phones supporting MIDP 2.0 to have. On top of this I would extend this application for specific sets of phones using their SDK's. For eg. Nokia S40, Nokia S60, Sony Ericsson, Blackberry etc. All these provide additional functionalities which lets you build more on top of your base application and most of the times these would affect your whole code base from UI to core logic.

One way to achieve this is to use a combination of a build system with preprocessor flags and trying to separate the differences enough to not have too many dependencies. This can get quite complicated at times. I am wondering if there is an easier way to handle this using a smart source control system....

+1  A: 

Hi, I like Subversion for projects which don't have a lot of developers on it. From your problem statement, to me it sounds like you should be able to acheive what you want with a good build system. So I don't think the source control itself would make much a difference. But I may be misunderstanding your problem.

Sayed Ibrahim Hashimi
+2  A: 

I would look at Subversion's svn:externals.

With svn 1.5 you can use relative references for directories, and svn 1.6 supports file-based externals.

For example a structure like,

  • /Phone1/Base
  • /Phone1/Feature1
  • /Phone1/Feature2
  • /Phone2/Base
  • /Phone2/Feature1
  • /Phone2/Feature3

Would be easily acheived using svn:externals.

In Subversion, your repository structure is very flexible, here is one way (of many) you could lay that out:

  • trunk/Features/Base
  • trunk/Features/Feature1
  • trunk/Features/Feature2
  • trunk/Features/Feature2
  • trunk/Phones/Phone1 (with svn:externals to Base, Feature1, ...)
  • trunk/Phones/Phone2 (with svn:externals to Base, Feature3, ...)

One hint though: Make sure that you use a specific Subversion revision for each external reference, it may not seem important when starting out, but 6 months down the track it will :)

Si
Thanks for the pointer, this could be very useful for an application we are working on which has multiple input libraries and a soup of different checkouts to pull the source in for some builds.
Tom Leys
Thanks for this tip. This could probably work. Im currently in the process of refactoring the code to split it into core libs and phone specific stuff. Will try this out after that.
Prashast
You're welcome guys, one thing I wasn't sure about was the level of sophistication you're after; If each phone has a defined set of features and you are manually declaring them in code then svn:externals should work fine on its own, but if you wanted some automated build process for each phone i.e. not have to declare (in code) each feature, then you may still need to look at some build tasks to work in conjunction with svn:externals. e.g. You just define the features in externals, and the build script works out what to include/link/compile.
Si
A: 

If you organize your code into some core modules and some phone-specific modules which depend on the core modules then it doesn't really matter which VCS you use. I would recommend a decentralized VCS anyway (Mercurial, Bazaar, Git).

You could consider describing how do you want to achieve what you want (different app versions with different feature sets) to get a more reasonable advice

artemb
A: 

If you use Perforce, you can use different mappings between the depot and your workspaces and do something like:

depot/
  common/
  platform1/
    someportedfile
  platform2/
    someportedfile

and have it mapped in your workspace to:

platform1/
  someportedfile
  common/
platform2/
  somtportedfile
  common/
Tal Pressman
+1  A: 

I don't think VCS will solve your problem.

Your best bet maybe to abstract out the phone specific functionality as much as possible and/or go with a plugin type model.

I've only had experience with Subversion, CVS, Starteam, and VSS. Branches are a pain no matter what... especially if you have multiple active branches. You won't get around doing constant merges , branch comparisons, and trying to track if you've made a change to all branches.

i_like_caffeine
+1 for suggesting how to avoid branching
Tom Leys
I don't get it? What's wrong with svn:externals? We use it quite successfully!
Si