Skip to main content
po221
Senior
January 24, 2022
Solved

Same codebase across multiple projects

  • January 24, 2022
  • 4 replies
  • 2074 views

Hello

I'm using STM32cubeide with STM32L

I have several applications that are based on the same code base.

What are the good solution(s) to handle this common code with stm32cubeide?

I can consider several solutions, one application = one project or one project for all applications (how? not too dirty ?), codebase like a library (how ?)... what else ?

All applications/projects are for the same target.

thanks

    This topic has been closed for replies.
    Best answer by TDK

    As I said, drag and drop, choose linked.

    0693W00000JNomqQAD.png

    4 replies

    KnarfB
    Super User
    January 24, 2022

    If you are using git or other source control, its straightforward to use several projects (==several git repositories) plus one extra repository for the common codebase. For git, this could be a submodule. This works well as long as the common codebase sits in a dedicated folder of your project(s). You can easily pin specific commits of your common codebase in individual projects for reproducible builds.

    Note that modern compilers support whole program optimization and source-level debugging is easier if you have all sources in one project.

    I would consider a static library only if I want to sell the stuff without sources, or the compilation time of the common codebase is hindering and the common codebase is already stable enough to allow binary (library) releases. STMCubeIDE can create and use static libraries.

    hth

    KnarfB

    po221
    po221Author
    Senior
    January 24, 2022

    'Note that modern compilers support whole program optimization and source-level debugging is easier if you have all sources in one project.'

    it's a strong argument ! -> no library.

    I look at the git submodules... it requires a bit of reading

    thanks

    TDK
    Super User
    January 24, 2022

    You can add source or header files as linked files and they will be included in the project. Drag and drop will let you do this.

    I don’t like sharing code between projects unless it is third party code that won’t change.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    po221
    po221Author
    Senior
    January 28, 2022

    @TDK

    what do you mean by linked file?

    for the git submodule I am doubtful; it's oribly complex from a git point of view

    KnarfB
    Super User
    January 29, 2022

    You're right with git submodules. Actually, I prefer the repo tool for mixing git repos.