Reputation: 255
currently, I'm working on an Embedded Project. At the moment, I have only a local git repository, as I'm the only developer. However, I'm thinking about making it OpenSource and move it to github (if a certain level of functionality is reached :-) ). So, I'm thinking a lot about making a good project structure, so other developers can join.
Well, at the moment, the project is a very easy setup.
I have a folder structure like:
/ (project root)
|-- .git
|-- documentation
|-- software
| |
| |-- subfolder_1
| | |
| | |-- someLib
| | |-- someOtherLib
| |
| |-- subfolder_2
|
|-- hardware
You see, just a bunch of nested folders, with the .git folder in the project's root.
For the project, I need to develop a library, lets call it someLib (with the someLib folder in the "picture" above being empty at the moment, because I haven't started with the lib).
This lib will probably get very big. And, more important, it does not contain any features related to this specific project. I, or maybe even someone else, might use it in another project as well.
So, I think it's a good idea making the lib its own project. Then, I might use git submodule or subtree to "link" the lib into my project.
What's the problem now?
Well, when I move the lib into its own project I will have additional files. Developing the lib in the main project would be easy, but in its own project, I need additional testcode, makefile, a "main.c", and (because it's embedded) hardware drivers. Without this additional stuff, I cannot run/test the lib.
This would look like:
/ (someLib root)
|-- .git
|-- documentation
|-- makefile
|-- main.c
|-- hardwareDriver_1
|-- hardwareDriver_2
|-- someLib
|
|-- someLib.c
|-- someLib.h
As you see, I don't want all this stuff in my main project.
So, when using the submodule or subtree approach, is there a way to exclude that stuff from being pulled into the main project?
Or, more important, how would you solve this?
I doubt I'm the first one who is facing this problem. Any good hints?
Upvotes: 2
Views: 131
Reputation: 14629
Then, I might use git submodule or subtree to "link" the lib into my project.
Rather than using submodules or subtrees, what about using this library as a library?
You could use this submodule to produce a .so
, and have your main code use that package. Both projects (the library and the main one) files would then be completely decoupled, hence solving your issue.
Upvotes: 2
Reputation: 1326782
I need additional testcode, makefile, a "main.c"
That sounds like another submodule, with:
That parent repo is there to record which versions of the lib sources goes with with version of the lib test files/code.
Separating test code from actual code would help keeping the lib project more easily embedded into other projects.
Upvotes: 0