Hello, I'm preparing an Arduino library for submission to Arduino (that will be a first for me). At the same time I will make the corresponding GitHub repository public.
I have studied the documentation and I believe I have a good understanding of the process etc., but one thing is not yet clear to me (probably because of a misconception on my part):
What with the main .ino file ? As part of my development project, it's part of many commits, it's visible on my GitHub site and I still need it in the future to continue working on bugs, enhancements etc. But it's not something to share with the community (my example .ino files are in other folders as per Arduino specification). Is there a best practice (or a misunderstanding from my side) ?
Many thanks for enlightening me
Herwig
Hi @herwig9820.
I am not certain I understand what you mean by "main .ino file". think it will be best if you make the repository public now and then add a reply here with a link to it so that we can look at the contents and understand fully.
Your test sketches ( .ino files ) should not be part of your library's github repository. Separate them. E.g. the testsketches for my MobaTools library are all local git repositories only.
Hi, thanks for your reply and I apologize if my question was not clear. I'll try to clarify things here:
Current status:
I use Visual Studio with the vmicro extension for development of what will become a library that I will submit to Arduino and make available on Github (I don't want to be make it public on Github while it is not ready for that). My project consists of an .ino file (which I use for development and test purposes), 8.cpp files and a header file, all part of the same "sketch" (in Arduino terms) or "project" (in Visual Studio terms). I use (integrated) version control with Git and my many commits sync with Github. The .ino file (containing code to test the future library) is part of these many commits, which is a good thing, because sometimes I make big changes in that .ino file and it happens that I need to compare with a previous version, retrieve parts of a previous version etc. Hence, the Git .gitignore file has no ".ino" entry and the .ino file is visible in Github.
Only for the sake of being complete: apart from this "sketch", I have several other sketches, only containing .ino files that will become library examples (in the library examples folder) and containing an appropriate #include "... .h" file to access my (future) library. These sketches (visual studio projects) do not use version control and have nothing to do with my question.
Now, it's time to turn all this into a library (.cpp and .h files).
The submission process to Arduino is clear to me.
My question: how do I proceed in order to be able to continue development (bugs, enhancements, etc.), with version control for at least my .cpp and .h files. (together thousands of lines), syncing to my current gitHub repository, if I remove my .ino file and it becomes part of a separate sketch ?
My folder structure (in the Arduino sketchbook folder):
The src subfolder:

The Visual Studio project structure:

Hope this makes it a little clearer.
Hello MicroBahner
I am totally aware of that - my problem is: how to do that. Please have a look at my clarification I sent to Ptillish.
Many thanks as well !
Herwig
Hello again
After a lot of thinking and trying, and after a little chat with my friend Mister Copilot, this is the best approach I could find (using Visual Studio with vmicro extension), taking into account that I also want version control for my .ino file:
- create a separate (new) 'project' (Visual Studio solution) and move the .ino file over there
- in the .ino file include ... .h directive, modify the path to point to the .h file in the original repository
- add the .h and .cpp files (residing in the original repository) to the new project ('add existing item' and select files). This DOES NOT MOVE OR COPY the .h and .cpp files.
- add version control to the new project. This will only apply to the .ino file
- open a second (concurrent) instance of Visual Studio and open the original project (visual studio solution). Make changes to the .h and .cpp files here, with full version control: undoing a specific change, comparing the change with the unmodified version, committing changes etc.
- Before build and upload, make sure changes to .h files and .cpp files are saved, switch to the (new) project with the .ino file and build.
This seems to work for me. Any comments or suggestions ?
Thanks
Herwig
Thanks for the clarification. I guessed this is what you meant, but didn't want to proceed based on assumptions. I am familiar with this technique (I used it during the development of several libraries in order to allow me to write the library code in Arduino IDE). In my case, the "main .ino file" didn't contain anything that needed to be under version control so I simply added it to the .gitignore file.
Great! Thanks for taking the time to share a detailed description of the solution you found.
I have essentially zero experience with Visual Micro (I did try it for a few days back in 2013 before going back to Arduino IDE, but that doesn't mean much) so I'm not able to evaluate your approach. If I was in a similar situation, but using Arduino IDE instead of Visual Micro, I would do this:
- Create a dedicated repository for the "main
.inofile" and move the file from the library repository to that dedicated repo. - Create a symlink in the library repository to the "main
.inofile" in the other repository. - Configure the
.gitignorefile in the library repository to exclude the symlink from the repository.
A library developer using Windows might have some difficulty getting started using symlinks, since by default Windows only allows them to be used when in administrative mode, but they are fully supported in Windows and (with Windows 10 onward) you can configure Windows to allow using symlinks in non-elevated contexts.
Since you say this, I would guess you would not even want to include it in the public repository on GitHub (which is completely reasonable). However, since it is generally related to the subject of the discussion and has been asked about previously, I'll also mention the idea of a mechanism in the Arduino Library Manager indexer system that would allow the exclusion of files in the repository from being included in the installation of the library on the user's machine. This is not currently supported. There is a request for the addition of such a capability here:
Well, I can tell how I do it ( with Arduino IDE ):
The library under development resides in the standard library folder of the IDE ( I think Visual Studio should also have such a library folder? ). The library directory there is under control of git ( and it is what git copies to gitHub ).
So all .ino files to test the library use this library as any other downloaded library too. E.g. it is very easy to test compatibility to other libraries. Not all .ino files are under git control, but if they are, this is a separate local git repository, idependent from the library repository. The github repository is a copy of the local library repository and contains only the files that comprise the library for the library manager. If a new version is to be released, I create a new tag on this commit, and this is automatically fetched by the library manager.
So testsketches and the library itself are strictly separated - and I think that's how it should be. In the end the test environment is exactly the same as for a user who downloaded the lib.
In fact, I will publish the project once the doc. is complete (development is) and I'm ready to submit the library to Arduino.
That would probably be a good idea. And apart from that, wouldn't it be a good idea to incorporate some kind of guidelines related to separating the ino file, at least for the people using the Arduino IDE, in the library specification (presenting it as a 'possible procedure'), because I can imagine that I'm not the only one that was really puzzled, trying a lot of things before stumbling into the solution.
Your help and suggestions were appreciated very much.
Yes, it uses the library path as set in the Arduino preferences.
Yes, correct. Very good solution and I believe similar to what I finally puzzled together.
Question: I guess you have two Arduino IDE instances open at the same time ? (one with the .ino file open and one with the .cpp and .h library files ? If you make a change to a .cpp or .h file and you save, you can immediately recompile and upload your ino file, correct ?
Thank you for your comments, they were really helpful.
No, only the .ino is open in the Arduino IDE. To edit the library files I use notepad++ in parallel. This is a very powerfull code editor.
Yes, that's true.
Yes, I use Notepad++ a lot, but with two sessions open (whether it's using Arduino IDE or Visual Studio, and apart from version control) one doesn't have to work with two color schemes at the same time (Notepad++ uses another color scheme for C++).
Although it is helpful to share this technique with other library developers in the community, it is not the sort of information that is appropriate for inclusion in the formal Arduino Library Specification.
The technique of putting a .ino file in a library in order to make it into a sketch instead of a library is a hack. Arduino IDE is a tool for developing sketches. There has never been any intention for it to serve as a tool for development of libraries. If some community members find a way to use it for that purpose, that is perfectly fine, but Arduino doesn't have any plans to formalize that use case.
Perhaps the situation is different for the 3rd party Visual Micro tool, I can't speak for the developers of that project. But even if they do intend it to be a tool for Arduino library development, the formal specification of their system would be part of the documentation they maintain rather than in Arduino's documentation since the scope of Arduino's documentation is limited to the official Arduino development tools.
That's true, but not a problem for me.
Yes, indeed, point taken.
A question though: it would be interesting to know wat tools are used to develop standard libs like SD, SPI etc. Can you maybe shed some light on this ?
I would guess that all the firmware developers at Arduino are using either VS Code or the open source VSCodium.
Similar to the workflow described by @MicroBahner, while a general purpose development editor such as VS Code is in use for writing the library code, one of the Arduino tools would be used in tandem to compile and upload sketches that use the library for testing. In this case, a developer comfortable with using command line tools will prefer the Arduino CLI tool. This can be used from the editor's integrated terminal.
Very clear answer. Thanks again
You are welcome. I'm glad if I was able to be of assistance.
Regards,
Per
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
