cancel
Showing results for 
Search instead for 
Did you mean: 

How to use common sources in multiple STM32Cube IDE projects

kris2399
Associate II

We have developped a set of recources - C en H files - which are used in many projects. How can we easily integrate these files in new and existing STM32Cube projects (CubeIDE version 1.8.0) and workspaces?

1 ACCEPTED SOLUTION

Accepted Solutions
Andrew Neil
Evangelist III

I would prefer to just copy them - then you get to choose when updates get merged into each project which uses them.

Otherwise, you might find that changes to the common code break your dependent projects at inconvenient times...

Version control systems such as Git or SVN allow you to do this.

But, if you really do want to do it, you can add a file as a "link":

0693W00000Nq0olQAB.pngThis takes you to:

0693W00000Nq0pFQAR.pngChoose 'Advanced>>'

Then choose ‘Link to alternate location’, and enter the path to your source files:

0693W00000Nq0ptQAB.png 

View solution in original post

11 REPLIES 11
Andrew Neil
Evangelist III

I would prefer to just copy them - then you get to choose when updates get merged into each project which uses them.

Otherwise, you might find that changes to the common code break your dependent projects at inconvenient times...

Version control systems such as Git or SVN allow you to do this.

But, if you really do want to do it, you can add a file as a "link":

0693W00000Nq0olQAB.pngThis takes you to:

0693W00000Nq0pFQAR.pngChoose 'Advanced>>'

Then choose ‘Link to alternate location’, and enter the path to your source files:

0693W00000Nq0ptQAB.png 

"I would prefer to just copy them - then you get to choose when updates get merged into each project which uses them"

It also means that you can make working changes in the copy without affecting other projects - and only merge them back when you're ready ...

kris2399
Associate II

Thanks.

Seems like trying to include H-files from this common folder needs the full path specification in the C-file.(I tried to add the include path to the build settings, but this doesn't do the trick)

How do I instruct CubeIDE to also include the H-files from this added folder?

kris2399
Associate II

Sorry, please disregard previous comment: adding the path to the project does solve the issue.

Relative paths should work.

another advantage of actually copying the files into your project location is that it makes this easier.

Also easier to distribute the project - you can just zip it up & ship it.

0693W000008y9fZQAQ.png 

kris2399
Associate II

I totally agree with your suggestions, however the idea we use works a little different from the procedures generally in practice. If we do modifications to the commons sources - which are extremely seldom - these must be incorporated in all projects relying on them. So copying them looks like risky

Anyhow, the issue seems resolved - time to mark the solution?

Pavel A.
Evangelist III

The best way to share a set of common files among several projects indeed is version control.

But not git or svn. There is a different kind of version control systems, such as Perforce, Synergy, Clearcase - based on concept of "virtual views" rather than on state of a tree.

These systems allow to express the user intent directly: say, I have set of shared files in a folder, and I want to put copy of this file in that project, in certain location. Then I can track where are all copies of the shared file. If the file changes in one of projects, other projects still can keep older version of it.

The down side of this is that these version control products are more complex than an individual can afford, they are expensive, typically require a dedicated handler. Perforce has a free version for very small teams.

kris2399
Associate II

Usually I use git, but since this code changes something like once-in-10-years, I wanted to skip the overhead.

I'll also take a look at Perforce, etc... BTW version control remains a very interesting topic, maybe something to integrate in CubeIDE?

Thanks for your input!