Starting off with full disclosure - this is a cross post. I originally posed the question here. But, having received no response for a couple days, I’m hoping someone in the larger audience here might be able to answer.
So, I’ve recently started using Eclipse with Sloeber and Egit plugins for Arduino code development. Using Google and YouTube, I’m groping my way through the learning process and can build and download projects as well as do basic version management with Egit.
Now I’d like to apply the process to library development and maintenance. These instructions explain how to move .cpp and .h files from your Eclipse project to an Arduino library folder. But, how do you then maintain the library and do version control on it? After moving the files Egit seems to forget about them. Plus, a basic Arduino library folder contains not only the .cpp and .h files but probably an ‘examples’ folder that contains sketch sub-folders with .ino files.
So, how do you work with and Egit-manage this library structure as a unit? I want to be able to make changes to the both the library sources files and example .ino files then compile / test them and maintain version control over them. Do you maintain the files in the Arduino library folder? Or, in your git folder structure and just manually move latest version over to the Arduino library?
Right now, I just interested in doing this on my local computer. But, eventually, I might want to push some of the libraries up to GitHub for others to use.
Juraj:
I make a file system link from git project folder (root or subfolder) into libraries folder.
OK, I have only the vaguest understanding of that means. Do the files physically reside in the git folder and virtually in the Library folder? Or, vice versa? Can you provide a link where I can learn about doing this in Win 7/10?
Also, it’s still not clear to me how to work with libraries and examples in Eclipse (Egit-management issues aside). Here’s a picture of the project structure I know how to work with. It has a main source .ino file (MyProject.ino), some .cpp / .h files and an included library (Bounce2 in this case). The library also contains example sketches, but they are crossed out and not part of the project.
As I said, I know how to work with this project structure to develop, debug, and download code. I can even edit and re-save the library files (although they reside in the Arduino library folder). But how instead do I work do this with the example .ino files? Meaning, make one of them the basis of the project rather than the .ino/.cpp/.h files that are at the bottom of the project tree? I know I can use the “New Arduino Sketch” wizard to make a new project BASED on a library example. But, then I’m working with a NEW COPY of the example code, not the original. Maybe I do it that way and then move it back into the library’s examples folder when I’m done?
on Windows you can make file system links on command line with admin access. the command is mklink.
I have the link in libraries folder and the real folder in git folder.
After the initial development I change the project to library. I remove it from Eclipse projects and I create a test project for the library. In that project the new library is attached as all other libraries. I can change the library code and the change is reflected i all my projects with that library.
Debuging of examples: I copy the content of the tested example to and from the main ino file of test project.
OK, thanks! If I may, couple more questions before I go off and start playing with this new knowledge. What exact steps do you follow to do this:
Juraj:
After the initial development I change the project to library.
Do you already have the .cpp / .h files under Egit control when you do the above?
How do you add the examples folder and get it under Egit control?
Do you have to bring the library back into the Eclipse workspace to commit new changes with Egit? Or, do you do git-management with a different tool outside of Eclipse / Egit?
gfvalvo:
Do you already have the .cpp / .h files under Egit control when you do the above?
I created only one new library and by chance I did put it under git when I converted the project to library. Other libraries are forked.
gfvalvo:
How do you add the examples folder and get it under Egit control?
I copy them into git project folder with Windows Explorer :-).
gfvalvo:
Do you have to bring the library back into the Eclipse workspace to commit new changes with Egit? Or, do you do git-management with a different tool outside of Eclipse / Egit?
One interesting thing I noted -- if I have the library included in a test project, then I can open its files from the “Project Explorer” tab under “libraries” (ask expected). However, if I make any changes to that file (and save it), those changes aren’t picked up upon by Egit -- nothing shows up on the “Git Staging” tab.
If I want Egit to catch these changes so I can commit them, I need to open the file from the “Git Repositories” tab. Then, it shows up in “Git Staging” as soon as I save the file.