Click here to Skip to main content
15,920,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm targeting multiple platforms. Typically, when I develop an application, I write a firmware for some microcontroller family (AVR, ARM, ...) and a driver library/program (in Visual C++, Qt, C#...) for that piece of hardware. So one application consists of several projects (AVR project with firmware, Qt project with driver, maybe some test projects...).

Currently, I use single Git repository and its structure is following:

C++
Repository
 - Library // shared code, each folder represents code for a platform/compiler/application
  - AVR
   - I2C
   - Uart
   - Spi
   - Lcd
   - Rtc
   - ....
  - Cortex M4
  - GNU
  - Win32
  - Qt
  - ....
  - MyApplication // application shared code, used in AVR and Qt projects
  - AnotherApplication // another application shared code...
 - Project
  - AVR
   - MyApplicationProjectForAvrMcu
   - AnotherApplicationProjectForAvrMcu
  - VisualC
  - Qt
   - MyApplicationProjectForQt
   - AnotherApplicationProjectForQt
  - ...


I can see many difficulties maintaining this big monolithic repository.

I think I need separate repository for each application. Something like this:

C++
MyApplicationRepository
 - Library
  - AVR
   - I2C
   - Uart
  - Win32
   - Uart
  - Qt // some Qt specific code, e.g. some widgets
  - MyApplication // application's source code shared between AVR project and Qt project
 - Project
  - AVR
   - MyApplicationProjectForAvrMcu
  - Qt
   - MyApplicationProjectForQt


However new problem arises - for each application I will have most code in Library folder duplicated - platform/compiler specific code (Library/AVR, Library/Win32, Library/Qt, ...) will be duplicated in all repositories.

This is ideal workflow I would like to use: I create an application repository. I pull platform/compiler specific code (shared code) needed by that application from my shared code repository (whole folders or separate files - e.g. Library/AVR/I2C, Library/AVR/Uart, Library/Qt/Something/SomeCode.cpp). I create all application specific code and projects in my application repository. Later I realize that I need to tweak some shared code (e.g. Library/AVR/I2C) so I add some special functionality and test it with my application. Then it would be useful to push that tweak back to the shared repository to be able to pull that tweak from another applications repositories later if needed by that applications.

Can you recommend me some instruments to accomplish this workflow?
Posted

1 solution

Never ever duplicate any code. Instead, consider each library as a separate product, even if don't use separate compilation for them. This is the top priority. If you need to tweak some library code, create some experimental branches and work with them separately, not touching the trunk. What if you need one version of the library for one application and another version for another application? It means that both versions are not good enough even for putting either of of them in the trunk. You need to unify the library to have only one, more universal version.

Good luck.
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900