cancel
Showing results for 
Search instead for 
Did you mean: 

How do you structure folders for a project?

Dave Jones
Associate III
Posted on March 06, 2017 at 04:54

I notice that in the example projects within the STM32L4 firmware package that all the examples have a parent folder that contains a SRC folder with the C files, and INC folder with the local include files, and a project folder that has the .project and .cproject files. Then in the project all of the C files and headers are linked with relative links, relative to the project folder.

When I took one of the examples and exported it as an archive and placed it elsewhere, the archive created a different structure. It created folders within the project folder for all the C files. Both the local ones and the external shared ones. It didn't export any header files at all. So the resulting project was broken and I had to go find all the header files. I placed them in an 'includes' folder within the project folder, next to the various folders holding the C files. When I did that the project seemed to automatically assume they were source files and included that folder in the project. Not in the 'Includes' virtual folder for headers, directly under the project name, but as a regular folder full of source files just like the various source folders full of C files. I then had to select it and exclude it from the build in order to not have it all automatically added.

I'm guessing that if I had created that include folder in a parent directory outside the project folder then that wouldn't have happened. But then if the norm is to put all source and headers outside the project folder, why did creating the archive place all of the C files in folders within the project folder? And why didn't the archive add any .h files?

So, how do you normally structure your files/folders for your projects?

2 REPLIES 2
Sirma Siang
ST Employee
Posted on March 06, 2017 at 17:48

Hello,

The example code constraints are to keep it small, and compatible with several IDE.

Then to be able to use a unique HAL code, combined with a unique project source code for several IDE and several projects, This structur has been set-up.

This shows, as well, that you can have HAL code in a common location, and have several projects using it.

If I remeber right, you have an option, when creating a zip, to keep the links.

Or instead of zip you can copy/paste the directory structure.

Everyon has a different environment and strucutre. Those examples must anyway,  be adapted accordingly.

Kind regards

Sirma

Posted on March 06, 2017 at 20:42

I realize that the files can be arranged in many different ways. It makes sense to have shared files in one area, if they're not going to be customized for a given project. What I am curious about is the most common ways that experienced users here are organizing their files for their projects. If there are advantages or disadvantages to keeping files in the project forlder or keeping them out of the project folder. From what I've seen it seems like there are disadvantages to keeping them inside the project folder and that using a parent folder to contain the source files and the project folder might be a better approach.

But I wanted to get opinions from the more experienced users here about how they find it best to organize their files for their projects, and why.