Jump to content
  • Advertisement
Sign in to follow this  
SymLinked

How do you manage multiple builds sharing the same code?

This topic is 4260 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I have been playing around with different ways of seperating my two build. Both share alot of code and both need to have some parts synced or they won't be able to communicate. I tried two things and I would like to know which one you find the best: 1. Keeping both builds in the same project, and putting two preprocessor defines. One each for Build1 and Build2. This actually works great, but the code looks like sh*t. Very cluttered by all the ifdefs. 2. Two different projects and keeping both updated by the changes made to them. This way it looks cleaner (IMO, of course) but on the other hand mistakes are more common when you forget to copy/paste over the updates from the other project. I prefer number 2 myself, because then I can customize both projects perfectly, deleting the project files/code I don't need, instead of having to ifdef them out. Any thoughts?

Share this post


Link to post
Share on other sites
Advertisement
3. Separate the common code into it's own project, a library of sorts that the first two projects depend on.

Share this post


Link to post
Share on other sites
Thanks for your suggestion but that is not practical in my case for a number of reasons, which is why I asked: Which of the two would you prefer?

Share this post


Link to post
Share on other sites
I would refactor those reasons and still go for number 3 :)

If I would really have to pick between the first two, then I'd probably pick number one to avoid the whole cut-and-paste desynchonisation mess. I would postulate that ugly code that always works is better than beautiful code that only works 50% of the time.

Share this post


Link to post
Share on other sites
Definately 1 IMO. Code doesn't have to be pretty to be functional. Managing 2 projects would get real old real fast.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Tough question. If your two builds differ only by a particular set of files, go with option 2. If you need to make changes here and there and everywhere defines are the better option of the two you've presented.

The "right" way (as mentioned) to do this is to put shared code into libraries. Where possible, non-shared code should share a common set of interface files, but separate implementation files.

Share this post


Link to post
Share on other sites
You could create an abstraction layer that gave each set of code a common interface. And then put #defines around the portion of code that implements the abstraction layer. Sort of like abstracting out a renderer or file system access.

Share this post


Link to post
Share on other sites
Quote:
Original post by DrEvil
Definately 1 IMO. Code doesn't have to be pretty to be functional. Managing 2 projects would get real old real fast.


Thanks.

Quote:
Original post by Anonymous Poster
Tough question. If your two builds differ only by a particular set of files, go with option 2. If you need to make changes here and there and everywhere defines are the better option of the two you've presented.

The "right" way (as mentioned) to do this is to put shared code into libraries. Where possible, non-shared code should share a common set of interface files, but separate implementation files.


Aye, I would had used a shared library if the code wasn't so much dependant on different parts. It would require alot of recoding and that's alot of work.

Quote:
Original post by jkleinecke
You could create an abstraction layer that gave each set of code a common interface. And then put #defines around the portion of code that implements the abstraction layer. Sort of like abstracting out a renderer or file system access.


I made two abstraction layers for the renderer and audio system, but I'm not sure how to handle the rest.

Your opinions are greatly appreciated and thanks again for the suggestions.

Share this post


Link to post
Share on other sites
After some thinking, I have decided to go with option 2. I just couldn't get my head around all those ifdefs, and I just realized the differences are mostly in a particular set of files, and some random ones.

Thanks again for your opinions.

Share this post


Link to post
Share on other sites
I would use number 3 as suggested above but as an alternative, I would create two project/solution files that only compiles/includes the files needed for the build.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!